home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 3.iso / dist / fw_mysql.idb / usr / freeware / info / mysql.info.z / mysql.info
Text File  |  2002-10-07  |  2MB  |  52,623 lines

  1. This is mysql.info, produced by makeinfo version 4.0 from manual.texi.
  2.  
  3. START-INFO-DIR-ENTRY
  4. * mysql: (mysql).               MySQL documentation.
  5. END-INFO-DIR-ENTRY
  6.  
  7. 
  8. File: mysql.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
  9.  
  10. This is a manual for MySQL. This version is about the 3.23.52 version
  11. of MySQL.  You can find a manual about any older version of MySQL in
  12. the binary or source distribution for that version.
  13.  
  14. * Menu:
  15.  
  16. * Introduction::                General Information about MySQL
  17. * Installing::                  Installing MySQL
  18. * Tutorial::                    MySQL Tutorial
  19. * MySQL Database Administration::  MySQL Database Administration
  20. * MySQL Optimization::          MySQL Optimization
  21. * Reference::                   MySQL language reference
  22. * Table types::                 MySQL table types
  23. * Clients::                     MySQL client tools and APIs
  24. * Extending MySQL::             Extending MySQL
  25. * Problems::                    Problems
  26. * Users::                       Some MySQL users
  27. * MySQL customer usage::        MySQL customer usage
  28. * Contrib::                     Contributed programs
  29. * Credits::                     Contributors to MySQL
  30. * News::                        MySQL change history
  31. * Porting::                     Comments on porting to other systems
  32. * Environment variables::       MySQL environment variables
  33. * Regexp::                      Description of MySQL regular expression syntax
  34. * Unireg::                      What is Unireg?
  35. * GPL license::                 GNU General Public License
  36. * LGPL license::                GNU Library General Public License
  37. * Placeholder::                 Pieces of the manual in transit
  38. * Function Index::              SQL command, type and function index
  39. * Concept Index::               Concept Index
  40.  
  41. 
  42. File: mysql.info,  Node: Introduction,  Next: Installing,  Prev: Top,  Up: Top
  43.  
  44. General Information About MySQL
  45. *******************************
  46.  
  47. This is the MySQL reference manual; it documents MySQL Version
  48. 3.23.52.  As MySQL is work in progress, the manual gets updated
  49. frequently.  There is a very good chance that this version is out of
  50. date, unless you are looking at it online.  The most recent version of
  51. this manual is available at `http://www.mysql.com/documentation/' in
  52. many different formats.  If you have a hard time finding information in
  53. the manual, you can try the searchable PHP version at
  54. `http://www.mysql.com/documentation/manual.php'.
  55.  
  56. MySQL is a very fast, multi-threaded, multi-user, and robust SQL
  57. (Structured Query Language) database server.
  58.  
  59. MySQL is free software.  It is licensed with the *GNU GENERAL PUBLIC
  60. LICENSE* `http://www.gnu.org/'.  *Note Licensing and Support::.
  61.  
  62. The MySQL home page (http://www.mysql.com/) provides the latest
  63. information about MySQL.
  64.  
  65. The following list describes some useful sections of the manual:
  66.  
  67.    * For information about the company behind MySQL, see *Note What is
  68.      MySQL AB::.
  69.  
  70.    * For a discussion of MySQL's capabilities, see *Note Features::.
  71.  
  72.    * For installation instructions, see *Note Installing::.
  73.  
  74.    * For tips on porting MySQL to new architectures or operating
  75.      systems, see *Note Porting::.
  76.  
  77.    * For information about upgrading from a Version 3.22 release, see
  78.      *Note Upgrading-from-3.22::.
  79.  
  80.    * For a tutorial introduction to MySQL, see *Note Tutorial::.
  81.  
  82.    * For examples of SQL and benchmarking information, see the
  83.      benchmarking directory (`sql-bench' in the distribution).
  84.  
  85.    * For a history of new features and bug fixes, see *Note News::.
  86.  
  87.    * For a list of currently known bugs and misfeatures, see *Note
  88.      Bugs::.
  89.  
  90.    * For future plans, see *Note TODO::.
  91.  
  92.    * For a list of all the contributors to this project, see *Note
  93.      Credits::.
  94.  
  95. *IMPORTANT:*
  96.  
  97. Reports of errors (often called bugs), as well as questions and
  98. comments, should be sent to the mailing list at <mysql@lists.mysql.com>.
  99. *Note Bug reports::.  The `mysqlbug' script should be used to generate
  100. bug reports.  For source distributions, the `mysqlbug' script can be
  101. found in the `scripts' directory.  For binary distributions, `mysqlbug'
  102. can be found in the `bin' directory. If you have found a sensitive
  103. security bug in MySQL, you should send an email to <security@mysql.com>.
  104.  
  105. If you have any suggestions concerning additions or corrections to this
  106. manual, please send them to the manual team at <docs@mysql.com>.
  107.  
  108. This is a reference manual; it does not provide general instruction on
  109. SQL or relational database concepts.  If you want general information
  110. about SQL, see *Note General-SQL::.  For books that focus more
  111. specifically on MySQL, see *Note MySQL-Books::.
  112.  
  113. * Menu:
  114.  
  115. * MySQL and MySQL AB::          MySQL, MySQL AB, and Open Source
  116. * MySQL Information Sources::   MySQL Information Sources
  117. * Licensing and Support::       MySQL Licensing and Support
  118. * Compatibility::               How Standards-compatible Is MySQL?
  119. * Comparisons::                 How MySQL Compares to Other Databases
  120. * TODO::                        MySQL and the future (The TODO)
  121.  
  122. 
  123. File: mysql.info,  Node: MySQL and MySQL AB,  Next: MySQL Information Sources,  Prev: Introduction,  Up: Introduction
  124.  
  125. MySQL, MySQL AB, and Open Source
  126. ================================
  127.  
  128. * Menu:
  129.  
  130. * What-is::                     What is MySQL?
  131. * What is MySQL AB::            What is MySQL AB?
  132. * Manual-info::                 About this manual
  133. * Manual conventions::          Conventions used in this manual
  134. * History::                     History of MySQL
  135. * Features::                    The main features of MySQL
  136. * Stability::                   How stable is MySQL?
  137. * Table size::                  How Big Can MySQL Tables Be?
  138. * Year 2000 compliance::        Year 2000 compliance
  139.  
  140. 
  141. File: mysql.info,  Node: What-is,  Next: What is MySQL AB,  Prev: MySQL and MySQL AB,  Up: MySQL and MySQL AB
  142.  
  143. What Is MySQL
  144. -------------
  145.  
  146. MySQL, the most popular Open Source SQL database, is provided by MySQL
  147. AB.  MySQL AB is a commercial company that builds its business
  148. providing services around the MySQL database.  *Note What is MySQL AB::.
  149.  
  150. MySQL is a database management system.
  151.      A database is a structured collection of data.  It may be anything
  152.      from a simple shopping list to a picture gallery or the vast
  153.      amounts of information in a corporate network.  To add, access,
  154.      and process data stored in a computer database, you need a
  155.      database management system such as MySQL.  Since computers are
  156.      very good at handling large amounts of data, database management
  157.      plays a central role in computing, as stand-alone utilities, or as
  158.      parts of other applications.
  159.  
  160. MySQL is a relational database management system.
  161.      A relational database stores data in separate tables rather than
  162.      putting all the data in one big storeroom.  This adds speed and
  163.      flexibility.  The tables are linked by defined relations making it
  164.      possible to combine data from several tables on request.  The SQL
  165.      part of MySQL stands for "Structured Query Language" - the most
  166.      common standardized language used to access databases.
  167.  
  168. MySQL is Open Source Software.
  169.      Open Source means that it is possible for anyone to use and modify.
  170.      Anybody can download MySQL from the Internet and use it without
  171.      paying anything.  Anybody so inclined can study the source code
  172.      and change it to fit their needs.  MySQL uses the GPL (GNU General
  173.      Public License) `http://www.gnu.org', to define what you may and
  174.      may not do with the software in different situations.  If you feel
  175.      uncomfortable with the GPL or need to embed MySQL into a
  176.      commercial application you can buy a commercially licensed version
  177.      from us.
  178.  
  179. Why use MySQL?
  180.      MySQL is very fast, reliable, and easy to use.  If that is what
  181.      you are looking for, you should give it a try.  MySQL also has a
  182.      very practical set of features developed in very close cooperation
  183.      with our users.  You can find a performance comparison of MySQL to
  184.      some other database managers on our benchmark page.  *Note MySQL
  185.      Benchmarks::.
  186.  
  187.      MySQL was originally developed to handle very large databases much
  188.      faster than existing solutions and has been successfully used in
  189.      highly demanding production environments for several years.  Though
  190.      under constant development, MySQL today offers a rich and very
  191.      useful set of functions.  The connectivity, speed, and security
  192.      make MySQL highly suited for accessing databases on the Internet.
  193.  
  194. The technical features of MySQL
  195.      For advanced technical information, see *Note Reference::.  MySQL
  196.      is a client/server system that consists of a multi-threaded SQL
  197.      server that supports different backends, several different client
  198.      programs and libraries, administrative tools, and several
  199.      programming interfaces.
  200.  
  201.      We also provide MySQL as a multi-threaded library which you can
  202.      link into your application to get a smaller, faster, easier to
  203.      manage product.
  204.  
  205. MySQL has a lot of contributed software available.
  206.      It is very likely that you will find that your favorite
  207.      application or language already supports MySQL.
  208.  
  209. The official way to pronounce MySQL is "My Ess Que Ell" (not
  210. MY-SEQUEL). But we try to avoid correcting people who say MY-SEQUEL.
  211.  
  212. 
  213. File: mysql.info,  Node: What is MySQL AB,  Next: Manual-info,  Prev: What-is,  Up: MySQL and MySQL AB
  214.  
  215. What Is MySQL AB
  216. ----------------
  217.  
  218. MySQL AB is the Swedish company owned and run by the MySQL founders and
  219. main developers.  We are dedicated to developing MySQL and spreading
  220. our database to new users.  MySQL AB owns the copyright to the MySQL
  221. server source code and the MySQL trademark.  A significant amount of
  222. revenues from our services goes to developing MySQL.  *Note What-is::.
  223.  
  224. MySQL AB has been profitable providing MySQL from the start.  We don't
  225. get any outside funding, but have earned all our money ourselves.
  226.  
  227. We are searching after partners that would like to support our
  228. development of MySQL so that we could accelerate the development pace.
  229. If you are interested in doing this, you can email <partner@mysql.com>
  230. about this!
  231.  
  232. MySQL AB has currently 20+ people
  233. (`http://www.mysql.com/development/team.html') on its payroll and is
  234. growing rapidly.
  235.  
  236. Our main sources of income are:
  237.  
  238.    * Commercial high quality support for MySQL provided by the MySQL
  239.      developers themselves.  If you are interested in purchasing a
  240.      support contract, please visit `https://order.mysql.com/' to view
  241.      our support options or to order support.
  242.  
  243.    * Consulting services.  We have developers and consultants in 12
  244.      countries and partners in many other countries that can help you
  245.      with almost any MySQL related issues.  If you need consulting
  246.      services, please email a good description of your needs to
  247.      <info@mysql.com>!  If we can't handle this ourselves we can
  248.      usually find a partner or a developer that can help you with your
  249.      problems.
  250.  
  251.    * We sell licenses for using MySQL as an embedded database.  *Note
  252.      Cost::.  If you have a commercial product for which you need a
  253.      fast, high quality database, but you can't afford to make your
  254.      product Open Source, you can buy the right to use the MySQL server
  255.      under a normal commercial copyright.  If you are interested in
  256.      this you can buy MySQL licenses at `https://order.mysql.com/' or
  257.      contact us at <licensing@mysql.com>.
  258.  
  259.    * Advertising. `http://www.mysql.com/' is a very popular web site
  260.      with more than 10,000,000 page views per months (January 2001).
  261.      By putting a banner on this you are guaranteed to reach a lot of
  262.      potential customers in the Open source, Linux and database
  263.      community. If you are interested in this email
  264.      <advertising@mysql.com>.
  265.  
  266.    * We are building a partner program to be able to provide MySQL
  267.      services in every country.  If you are interested in becoming a
  268.      partner of MySQL AB please visit
  269.      `http://www.mysql.com/information/partners.html' or email
  270.      <partner@mysql.com>.
  271.  
  272.    * We provide MySQL training through our partner programs.  For more
  273.      information, please email <info@mysql.com>.
  274.  
  275.    * The MySQL brand has, since 1995, been associated with speed and
  276.      reliability, and is known to be something you can depend upon.  If
  277.      you are interested in using the MySQL trademark in your marketing,
  278.      you can email <info@mysql.com> about this.
  279.  
  280. The MySQL core values show our dedication to MySQL and Open Source.
  281.  
  282. We want MySQL to be:
  283.  
  284.    * The best and the most used database in the world.
  285.  
  286.    * Available and affordable for all.
  287.  
  288.    * Easy to use.
  289.  
  290.    * Continuously improved while remaining fast and safe.
  291.  
  292.    * Fun to use and improve.
  293.  
  294.    * Free from bugs.
  295.  
  296. MySQL AB and the people of MySQL AB:
  297.  
  298.    * Promote Open Source Philosophy and support the Open Source
  299.      Community.
  300.  
  301.    * Aim to be good citizens.
  302.  
  303.    * Prefer partners that share our values and mind-set.
  304.  
  305.    * Answer mail and give support.
  306.  
  307.    * Are a virtual company, networking with others.
  308.  
  309.    * Work against software patents.
  310.  
  311. 
  312. File: mysql.info,  Node: Manual-info,  Next: Manual conventions,  Prev: What is MySQL AB,  Up: MySQL and MySQL AB
  313.  
  314. About This Manual
  315. -----------------
  316.  
  317. This manual is currently available in Texinfo, plain text, Info, HTML,
  318. PostScript, and PDF versions.  The primary document is the Texinfo file.
  319. The HTML version is produced automatically using a modified version of
  320. `texi2html'.  The plain text and Info versions are produced with
  321. `makeinfo'.  The Postscript version is produced using `texi2dvi' and
  322. `dvips'.  The PDF version is produced with `pdftex'.
  323.  
  324. This manual is written and maintained by David Axmark, Michael (Monty)
  325. Widenius, Jeremy Cole, and Paul DuBois.  For other contributors, see
  326. *Note Credits::.
  327.  
  328. 
  329. File: mysql.info,  Node: Manual conventions,  Next: History,  Prev: Manual-info,  Up: MySQL and MySQL AB
  330.  
  331. Conventions Used in This Manual
  332. -------------------------------
  333.  
  334. This manual uses certain typographical conventions:
  335.  
  336. `constant'
  337.      Constant-width font is used for command names and options; SQL
  338.      statements; database, table and column names; C and Perl code; and
  339.      environment variables.  Example: "To see how `mysqladmin' works,
  340.      invoke it with the `--help' option."
  341.  
  342. `filename'
  343.      Constant-width font with surrounding quotes is used for filenames
  344.      and pathnames.  Example: "The distribution is installed under the
  345.      `/usr/local/' directory."
  346.  
  347. `c'
  348.      Constant-width font with surrounding quotes is also used to
  349.      indicate character sequences.  Example: "To specify a wild card,
  350.      use the `%' character."
  351.  
  352. _italic_
  353.      Italic font is used for emphasis, _like this_.
  354.  
  355. *boldface*
  356.      Boldface font is used for access privilege names (for example, "do
  357.      not grant the *process* privilege lightly") and occasionally to
  358.      convey *especially strong emphasis*.
  359.  
  360. When commands are shown that are meant to be executed by a particular
  361. program, the program is indicated by a prompt shown before the command.
  362. For example, `shell>' indicates a command that you execute from your
  363. login shell, and `mysql>' indicates a command that you execute from the
  364. `mysql' client program:
  365.  
  366.      shell> type a shell command here
  367.      mysql> type a mysql command here
  368.  
  369. Shell commands are shown using Bourne shell syntax.  If you are using a
  370. `csh'-style shell, you may need to issue commands slightly differently.
  371. For example, the sequence to set an environment variable and run a
  372. command looks like this in Bourne shell syntax:
  373.  
  374.      shell> VARNAME=value some_command
  375.  
  376. For `csh', you would execute the sequence like this:
  377.  
  378.      shell> setenv VARNAME value
  379.      shell> some_command
  380.  
  381. Often, database, table, and column names must be substituted into
  382. commands.  To indicate that such substitution is necessary, this manual
  383. uses `db_name', `tbl_name' and `col_name'.  For example, you might see
  384. a statement like this:
  385.  
  386.      mysql> SELECT col_name FROM db_name.tbl_name;
  387.  
  388. This means that if you were to enter a similar statement, you would
  389. supply your own database, table, and column names, perhaps like this:
  390.  
  391.      mysql> SELECT author_name FROM biblio_db.author_list;
  392.  
  393. SQL statements may be written in uppercase or lowercase.  When this
  394. manual shows a SQL statement, uppercase is used for particular keywords
  395. if those keywords are under discussion (to emphasize them) and
  396. lowercase is used for the rest of the statement.  For example, you
  397. might see the following in a discussion of the `SELECT' statement:
  398.  
  399.      mysql> SELECT count(*) FROM tbl_name;
  400.  
  401. On the other hand, in a discussion of the `COUNT()' function, the same
  402. statement would be written like this:
  403.  
  404.      mysql> select COUNT(*) from tbl_name;
  405.  
  406. If no particular emphasis is intended, all keywords are written
  407. uniformly in uppercase.
  408.  
  409. In syntax descriptions, square brackets (`[' and `]') are used to
  410. indicate optional words or clauses:
  411.  
  412.      DROP TABLE [IF EXISTS] tbl_name
  413.  
  414. When a syntax element consists of a number of alternatives, the
  415. alternatives are separated by vertical bars (`|').  When one member
  416. from a set of choices *may* be chosen, the alternatives are listed
  417. within square brackets (`[' and `]'):
  418.  
  419.      TRIM([[BOTH | LEADING | TRAILING] [remstr] FROM] str)
  420.  
  421. When one member from a set of choices *must* be chosen, the
  422. alternatives are listed within braces (`{' and `}'):
  423.  
  424.      {DESCRIBE | DESC} tbl_name {col_name | wild}
  425.  
  426. 
  427. File: mysql.info,  Node: History,  Next: Features,  Prev: Manual conventions,  Up: MySQL and MySQL AB
  428.  
  429. History of MySQL
  430. ----------------
  431.  
  432. We once started out with the intention of using `mSQL' to connect to our
  433. tables using our own fast low-level (ISAM) routines. However, after some
  434. testing we came to the conclusion that `mSQL' was not fast enough nor
  435. flexible enough for our needs.  This resulted in a new SQL interface to
  436. our database but with almost the same API interface as `mSQL'.  This
  437. API was chosen to ease porting of third-party code.
  438.  
  439. The derivation of the name MySQL is not perfectly clear.  Our base
  440. directory and a large number of our libraries and tools have had the
  441. prefix "my" for well over 10 years.  However, Monty's daughter (some
  442. years younger) is also named My.  Which of the two gave its name to
  443. MySQL is still a mystery, even for us.
  444.  
  445. 
  446. File: mysql.info,  Node: Features,  Next: Stability,  Prev: History,  Up: MySQL and MySQL AB
  447.  
  448. The Main Features of MySQL
  449. --------------------------
  450.  
  451. The following list describes some of the important characteristics of
  452. MySQL:
  453.  
  454.    * Fully multi-threaded using kernel threads.  This means it can
  455.      easily use multiple CPUs if available.
  456.  
  457.    * C, C++, Eiffel, Java, Perl, PHP, Python and Tcl APIs.  *Note
  458.      Clients::.
  459.  
  460.    * Works on many different platforms.  *Note Which OS::.
  461.  
  462.    * Many column types: signed/unsigned integers 1, 2, 3, 4, and 8 bytes
  463.      long, `FLOAT', `DOUBLE', `CHAR', `VARCHAR', `TEXT', `BLOB',
  464.      `DATE', `TIME', `DATETIME', `TIMESTAMP', `YEAR', `SET', and `ENUM'
  465.      types.  *Note Column types::.
  466.  
  467.    * Very fast joins using an optimized one-sweep multi-join.
  468.  
  469.    * Full operator and function support in the `SELECT' and `WHERE'
  470.      parts of queries.  For example:
  471.  
  472.           mysql> SELECT CONCAT(first_name, " ", last_name) FROM tbl_name
  473.                      WHERE income/dependents > 10000 AND age > 30;
  474.  
  475.    * SQL functions are implemented through a highly optimized class
  476.      library and should be as fast as possible!  Usually there isn't
  477.      any memory allocation at all after query initialization.
  478.  
  479.    * Full support for SQL `GROUP BY' and `ORDER BY' clauses.  Support
  480.      for group functions (`COUNT()', `COUNT(DISTINCT ...)', `AVG()',
  481.      `STD()', `SUM()', `MAX()' and `MIN()').
  482.  
  483.    * Support for `LEFT OUTER JOIN' and `RIGHT OUTER JOIN' with ANSI SQL
  484.      and ODBC syntax.
  485.  
  486.    * You can mix tables from different databases in the same query (as
  487.      of Version 3.22).
  488.  
  489.    * A privilege and password system that is very flexible and secure,
  490.      and allows host-based verification.  Passwords are secure because
  491.      all password traffic is encrypted when you connect to a server.
  492.  
  493.    * ODBC (Open-DataBase-Connectivity) support for Win32 (with source).
  494.      All ODBC 2.5 functions and many others.  For example, you can use
  495.      MS Access to connect to your MySQL server.  *Note ODBC::.
  496.  
  497.    * Very fast B-tree disk tables with index compression.
  498.  
  499.    * Up to 32 indexes per table are allowed.  Each index may consist of
  500.      1 to 16 columns or parts of columns.  The maximum index length is
  501.      500 bytes (this may be changed when compiling MySQL).  An index
  502.      may use a prefix of a `CHAR' or `VARCHAR' field.
  503.  
  504.    * Fixed-length and variable-length records.
  505.  
  506.    * In-memory hash tables which are used as temporary tables.
  507.  
  508.    * Handles large databases.  We are using MySQL with some databases
  509.      that contain 50,000,000 records and we know of users that uses
  510.      MySQL with 60,000 tables and about 5,000,000,000 rows
  511.  
  512.    * All columns have default values.  You can use `INSERT' to insert a
  513.      subset of a table's columns; those columns that are not explicitly
  514.      given values are set to their default values.
  515.  
  516.    * Uses GNU Automake, Autoconf, and Libtool for portability.
  517.  
  518.    * Written in C and C++.  Tested with a broad range of different
  519.      compilers.
  520.  
  521.    * A very fast thread-based memory allocation system.
  522.  
  523.    * No memory leaks.  MySQL has been tested with Purify, a commercial
  524.      memory leakage detector.
  525.  
  526.    * Includes `myisamchk', a very fast utility for table checking,
  527.      optimization, and repair.  All of the functionality of `myisamchk'
  528.      is also available through the SQL interface as well.  *Note MySQL
  529.      Database Administration::.
  530.  
  531.    * Full support for several different character sets, including
  532.      ISO-8859-1 (Latin1), big5, ujis, and more.  For example, the
  533.      Scandinavian characters `a*', `a"' and `o"' are allowed in table
  534.      and column names.
  535.  
  536.    * All data are saved in the chosen character set.  All comparisons
  537.      for normal string columns are case insensitive.
  538.  
  539.    * Sorting is done according to the chosen character set (the Swedish
  540.      way by default).  It is possible to change this when the MySQL
  541.      server is started up.  To see an example of very advanced sorting,
  542.      look at the Czech sorting code.  MySQL supports many different
  543.      character sets that can be specified at compile and run time.
  544.  
  545.    * Aliases on tables and columns are allowed as in the SQL92 standard.
  546.  
  547.    * `DELETE', `INSERT', `REPLACE', and `UPDATE' return the number of
  548.      rows that were changed (affected).  It is possible to return the
  549.      number of rows matched instead by setting a flag when connecting
  550.      to the server.
  551.  
  552.    * Function names do not clash with table or column names.  For
  553.      example, `ABS' is a valid column name.  The only restriction is
  554.      that for a function call, no spaces are allowed between the
  555.      function name and the `(' that follows it.  *Note Reserved words::.
  556.  
  557.    * All MySQL programs can be invoked with the `--help' or `-?'
  558.      options to obtain online assistance.
  559.  
  560.    * The server can provide error messages to clients in many languages.
  561.      *Note Languages::.
  562.  
  563.    * Clients may connect to the MySQL server using TCP/IP Sockets, Unix
  564.      Sockets (Unix), or Named Pipes (NT).
  565.  
  566.    * The MySQL-specific `SHOW' command can be used to retrieve
  567.      information about databases, tables, and indexes.  The `EXPLAIN'
  568.      command can be used to determine how the optimizer resolves a
  569.      query.
  570.  
  571. 
  572. File: mysql.info,  Node: Stability,  Next: Table size,  Prev: Features,  Up: MySQL and MySQL AB
  573.  
  574. How Stable Is MySQL?
  575. --------------------
  576.  
  577. This section addresses the questions "How stable is MySQL?" and "Can I
  578. depend on MySQL in this project?"  We will try to clarify some issues
  579. and to answer some of the more important questions that seem to concern
  580. many people.  This section has been put together from information
  581. gathered from the mailing list (which is very active in reporting bugs).
  582.  
  583. At TcX, MySQL has worked without any problems in our projects since
  584. mid-1996.  When MySQL was released to a wider public, we noticed that
  585. there were some pieces of "untested code" that were quickly found by the
  586. new users who made queries in a manner different than our own.  Each new
  587. release has had fewer portability problems than the previous one (even
  588. though each has had many new features).
  589.  
  590. Each release of MySQL has been usable, and there have been problems
  591. only when users start to use code from the "gray zones."  Naturally,
  592. outside users don't know what the gray zones are; this section attempts
  593. to indicate those that are currently known.  The descriptions deal with
  594. Version 3.23 of MySQL.  All known and reported bugs are fixed in the
  595. latest version, with the exception of the bugs listed in the bugs
  596. section, which are things that are design-related.  *Note Bugs::.
  597.  
  598. MySQL is written in multiple layers and different independent modules.
  599. These modules are listed below with an indication of how well-tested
  600. each of them is:
  601.  
  602. *The ISAM table handler -- Stable*
  603.      This manages storage and retrieval of all data in MySQL Version
  604.      3.22 and earlier.  In all MySQL releases there hasn't been a single
  605.      (reported) bug in this code. The only known way to get a corrupted
  606.      table is to kill the server in the middle of an update.  Even that
  607.      is unlikely to destroy any data beyond rescue, because all data
  608.      are flushed to disk between each query.  There hasn't been a
  609.      single bug report about lost data because of bugs in MySQL.
  610.  
  611. *The MyISAM table handler -- Stable*
  612.      This is new in MySQL Version 3.23.  It's largely based on the ISAM
  613.      table code but has a lot of new and very useful features.
  614.  
  615. *The parser and lexical analyser -- Stable*
  616.      There hasn't been a single reported bug in this system for a long
  617.      time.
  618.  
  619. *The C client code -- Stable*
  620.      No known problems.  In early Version 3.20 releases, there were
  621.      some limitations in the send/receive buffer size.  As of Version
  622.      3.21, the buffer size is now dynamic up to a default of 16M.
  623.  
  624. *Standard client programs -- Stable*
  625.      These include `mysql', `mysqladmin', `mysqlshow', `mysqldump', and
  626.      `mysqlimport'.
  627.  
  628. *Basic SQL -- Stable*
  629.      The basic SQL function system and string classes and dynamic memory
  630.      handling.  Not a single reported bug in this system.
  631.  
  632. *Query optimizer -- Stable*
  633.  
  634. *Range optimizer -- Stable*
  635.  
  636. *Join optimizer -- Stable*
  637.  
  638. *Locking -- Gamma*
  639.      This is very system-dependent.  On some systems there are big
  640.      problems using standard OS locking (`fcntl()').  In these cases,
  641.      you should run the MySQL daemon with the `--skip-locking' flag.
  642.      Problems are known to occur on some Linux systems, and on SunOS
  643.      when using NFS-mounted file systems.
  644.  
  645. *Linux threads -- Stable*
  646.      The major problem found has been with the `fcntl()' call, which is
  647.      fixed by using the `--skip-locking' option to `mysqld'.  Some
  648.      people have reported lockup problems with Version 0.5.
  649.      LinuxThreads will need to be recompiled if you plan to use 1000+
  650.      concurrent connections.  Although it is possible to run that many
  651.      connections with the default LinuxThreads (however, you will never
  652.      go above 1021), the default stack spacing of 2 MB makes the
  653.      application unstable, and we have been able to reproduce a
  654.      coredump after creating 1021 idle connections.  *Note Linux::.
  655.  
  656. *Solaris 2.5+ pthreads -- Stable*
  657.      We use this for all our production work.
  658.  
  659. *MIT-pthreads (Other systems) -- Stable*
  660.      There have been no reported bugs since Version 3.20.15 and no
  661.      known bugs since Version 3.20.16.  On some systems, there is a
  662.      "misfeature" where some operations are quite slow (a 1/20 second
  663.      sleep is done between each query).  Of course, MIT-pthreads may
  664.      slow down everything a bit, but index-based `SELECT' statements
  665.      are usually done in one time frame so there shouldn't be a mutex
  666.      locking/thread juggling.
  667.  
  668. *Other thread implementions -- Beta - Gamma*
  669.      The ports to other systems are still very new and may have bugs,
  670.      possibly in MySQL, but most often in the thread implementation
  671.      itself.
  672.  
  673. *`LOAD DATA ...', `INSERT ... SELECT' -- Stable*
  674.      Some people thought they had found bugs here, but these usually
  675.      have turned out to be misunderstandings.  Please check the manual
  676.      before reporting problems!
  677.  
  678. *`ALTER TABLE' -- Stable*
  679.      Small changes in Version 3.22.12.
  680.  
  681. *DBD -- Stable*
  682.      Now maintained by Jochen Wiedmann (<wiedmann@neckar-alb.de>).
  683.      Thanks!
  684.  
  685. *`mysqlaccess' -- Stable*
  686.      Written and maintained by Yves Carlier (<Yves.Carlier@rug.ac.be>).
  687.      Thanks!
  688.  
  689. *`GRANT' -- Stable*
  690.      Big changes made in MySQL Version 3.22.12.
  691.  
  692. **MyODBC* (uses ODBC SDK 2.5) -- Gamma*
  693.      It seems to work well with some programs.
  694.  
  695. *Replication - Beta / Gamma*
  696.      We are still working on replication, so don't expect this to be
  697.      rock solid yet.  On the other hand, some MySQL users are already
  698.      using this with good results.
  699.  
  700. *BDB Tables - Beta*
  701.      The Berkeley DB code is very stable, but we are still improving
  702.      the interface between MySQL and BDB tables, so it will take some
  703.      time before this is as tested as the other table types.
  704.  
  705. *InnoDB Tables - Beta*
  706.      This is a recent addition to `MySQL'. They appear to work good and
  707.      can be used after some initial testing.
  708.  
  709. *Automatic recovery of MyISAM tables - Beta*
  710.      This only affects the new code that checks if the table was closed
  711.      properly on open and executes an automatic check/repair of the
  712.      table if it wasn't.
  713.  
  714. *MERGE tables - Beta / Gamma*
  715.      The usage of keys on `MERGE' tables is still not that tested.  The
  716.      other part of the `MERGE' code is quite well tested.
  717.  
  718. *FULLTEXT - Beta*
  719.      Text search seems to work, but is still not widely used.
  720.  
  721. MySQL AB provides e-mail support for paying customers, but the MySQL
  722. mailing list usually provides answers to common questions.  Bugs are
  723. usually fixed right away with a patch; for serious bugs, there is
  724. almost always a new release.
  725.  
  726. 
  727. File: mysql.info,  Node: Table size,  Next: Year 2000 compliance,  Prev: Stability,  Up: MySQL and MySQL AB
  728.  
  729. How Big Can MySQL Tables Be?
  730. ----------------------------
  731.  
  732. MySQL Version 3.22 has a 4G limit on table size. With the new `MyISAM'
  733. in MySQL Version 3.23 the maximum table size is pushed up to 8 million
  734. terabytes (2 ^ 63 bytes).
  735.  
  736. Note, however, that operating systems have their own file size limits.
  737. Here are some examples:
  738.  
  739. *Operating System*                   *File Size Limit*
  740. Linux-Intel 32 bit                   2G, 4G or more, depends on Linux
  741.                                      version
  742. Linux-Alpha                          8T (?)
  743. Solaris 2.5.1                        2G (possible 4G with patch)
  744. Solaris 2.6                          4G
  745. Solaris 2.7 Intel                    4G
  746. Solaris 2.7 ULTRA-SPARC              8T (?)
  747.  
  748. On Linux 2.2 you can get bigger tables than 2G by using the LFS patch
  749. for the ext2 file system.  On Linux 2.4 there exists also patches for
  750. ReiserFS to get support for big files.
  751.  
  752. This means that the table size for MySQL is normally limited by the
  753. operating system.
  754.  
  755. By default, MySQL tables have a maximum size of about 4G.  You can
  756. check the maximum table size for a table with the `SHOW TABLE STATUS'
  757. command or with the `myisamchk -dv table_name'.  *Note SHOW::.
  758.  
  759. If you need bigger tables than 4G (and your operating system supports
  760. this), you should set the `AVG_ROW_LENGTH' and `MAX_ROWS' parameter
  761. when you create your table.  *Note CREATE TABLE::.  You can also set
  762. these later with `ALTER TABLE'. *Note ALTER TABLE::.
  763.  
  764. If your big table is going to be read-only, you could use `myisampack'
  765. to merge and compress many tables to one.  `myisampack' usually
  766. compresses a table by at least 50%, so you can have, in effect, much
  767. bigger tables.  *Note `myisampack': myisampack.
  768.  
  769. You can go around the operating system file limit for `MyISAM' data
  770. files by using the `RAID' option. *Note CREATE TABLE::.
  771.  
  772. Another solution can be the included MERGE library, which allows you to
  773. handle a collection of identical tables as one. *Note MERGE tables:
  774. MERGE.
  775.  
  776. 
  777. File: mysql.info,  Node: Year 2000 compliance,  Prev: Table size,  Up: MySQL and MySQL AB
  778.  
  779. Year 2000 Compliance
  780. --------------------
  781.  
  782. MySQL itself has no problems with Year 2000 (Y2K) compliance:
  783.  
  784.    * MySQL uses Unix time functions and has no problems with dates
  785.      until `2069'; all 2-digit years are regarded to be in the range
  786.      `1970' to `2069', which means that if you store `01' in a `year'
  787.      column, MySQL treats it as `2001'.
  788.  
  789.    * All MySQL date functions are stored in one file `sql/time.cc' and
  790.      coded very carefully to be year 2000-safe.
  791.  
  792.    * In MySQL Version 3.22 and later, the new `YEAR' column type can
  793.      store years `0' and `1901' to `2155' in 1 byte and display them
  794.      using 2 or 4 digits.
  795.  
  796. You may run into problems with applications that use MySQL in a way
  797. that is not Y2K-safe.  For example, many old applications store or
  798. manipulate years using 2-digit values (which are ambiguous) rather than
  799. 4-digit values.  This problem may be compounded by applications that use
  800. values such as `00' or `99' as "missing" value indicators.
  801.  
  802. Unfortunately, these problems may be difficult to fix, because different
  803. applications may be written by different programmers, each of whom may
  804. use a different set of conventions and date-handling functions.
  805.  
  806. Here is a simple demonstration illustrating that MySQL doesn't have any
  807. problems with dates until the year 2030:
  808.  
  809.      mysql> DROP TABLE IF EXISTS y2k;
  810.      Query OK, 0 rows affected (0.01 sec)
  811.      
  812.      mysql> CREATE TABLE y2k (date date, date_time datetime, time_stamp timestamp);
  813.      Query OK, 0 rows affected (0.00 sec)
  814.      
  815.      mysql> INSERT INTO y2k VALUES
  816.          -> ("1998-12-31","1998-12-31 23:59:59",19981231235959),
  817.          -> ("1999-01-01","1999-01-01 00:00:00",19990101000000),
  818.          -> ("1999-09-09","1999-09-09 23:59:59",19990909235959),
  819.          -> ("2000-01-01","2000-01-01 00:00:00",20000101000000),
  820.          -> ("2000-02-28","2000-02-28 00:00:00",20000228000000),
  821.          -> ("2000-02-29","2000-02-29 00:00:00",20000229000000),
  822.          -> ("2000-03-01","2000-03-01 00:00:00",20000301000000),
  823.          -> ("2000-12-31","2000-12-31 23:59:59",20001231235959),
  824.          -> ("2001-01-01","2001-01-01 00:00:00",20010101000000),
  825.          -> ("2004-12-31","2004-12-31 23:59:59",20041231235959),
  826.          -> ("2005-01-01","2005-01-01 00:00:00",20050101000000),
  827.          -> ("2030-01-01","2030-01-01 00:00:00",20300101000000),
  828.          -> ("2050-01-01","2050-01-01 00:00:00",20500101000000);
  829.      Query OK, 13 rows affected (0.01 sec)
  830.      Records: 13  Duplicates: 0  Warnings: 0
  831.      
  832.      mysql> SELECT * FROM y2k;
  833.      +------------+---------------------+----------------+
  834.      | date       | date_time           | time_stamp     |
  835.      +------------+---------------------+----------------+
  836.      | 1998-12-31 | 1998-12-31 23:59:59 | 19981231235959 |
  837.      | 1999-01-01 | 1999-01-01 00:00:00 | 19990101000000 |
  838.      | 1999-09-09 | 1999-09-09 23:59:59 | 19990909235959 |
  839.      | 2000-01-01 | 2000-01-01 00:00:00 | 20000101000000 |
  840.      | 2000-02-28 | 2000-02-28 00:00:00 | 20000228000000 |
  841.      | 2000-02-29 | 2000-02-29 00:00:00 | 20000229000000 |
  842.      | 2000-03-01 | 2000-03-01 00:00:00 | 20000301000000 |
  843.      | 2000-12-31 | 2000-12-31 23:59:59 | 20001231235959 |
  844.      | 2001-01-01 | 2001-01-01 00:00:00 | 20010101000000 |
  845.      | 2004-12-31 | 2004-12-31 23:59:59 | 20041231235959 |
  846.      | 2005-01-01 | 2005-01-01 00:00:00 | 20050101000000 |
  847.      | 2030-01-01 | 2030-01-01 00:00:00 | 20300101000000 |
  848.      | 2050-01-01 | 2050-01-01 00:00:00 | 00000000000000 |
  849.      +------------+---------------------+----------------+
  850.      13 rows in set (0.00 sec)
  851.  
  852. This shows that the `DATE' and `DATETIME' types will not give any
  853. problems with future dates (they handle dates until the year 9999).
  854.  
  855. The `TIMESTAMP' type, which is used to store the current time, has a
  856. range up to only `2030-01-01'.  `TIMESTAMP' has a range of `1970' to
  857. `2030' on 32-bit machines (signed value).  On 64-bit machines it
  858. handles times up to `2106' (unsigned value).
  859.  
  860. Even though MySQL is Y2K-compliant, it is your responsibility to
  861. provide unambiguous input.  See *Note Y2K issues:: for MySQL's rules
  862. for dealing with ambiguous date input data (data containing 2-digit year
  863. values).
  864.  
  865. 
  866. File: mysql.info,  Node: MySQL Information Sources,  Next: Licensing and Support,  Prev: MySQL and MySQL AB,  Up: Introduction
  867.  
  868. MySQL Information Sources
  869. =========================
  870.  
  871. * Menu:
  872.  
  873. * MySQL-Books::                 Books About MySQL
  874. * General-SQL::                 General SQL Information and Tutorials
  875. * Useful Links::                Useful MySQL-related Links
  876. * Questions::                   MySQL Mailing Lists
  877.  
  878. 
  879. File: mysql.info,  Node: MySQL-Books,  Next: General-SQL,  Prev: MySQL Information Sources,  Up: MySQL Information Sources
  880.  
  881. Books About MySQL
  882. -----------------
  883.  
  884. For the latest book information, with user comments, please visit
  885. `http://www.mysql.com/portal/books/html/index.html'.
  886.  
  887. While this manual is still the right place for up to date technical
  888. information, its primary goal is to contain everything there is to know
  889. about MySQL.  It is sometimes nice to have a bound book to read in bed
  890. or while you travel.  Here is a list of books about MySQL and related
  891. subjects (in English).
  892.  
  893. By purchasing a book through these hyperlinks provided herein, you are
  894. contributing to the development of MySQL.
  895.  
  896. _MySQL_
  897. Available              Barnes and Noble
  898.                        (http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0735709211&bfmtype=book)
  899. Publisher              New Riders
  900. Author                 Paul DuBois
  901. Pub Date               1st Edition December 1999
  902. ISBN                   0735709211
  903. Pages                  800
  904. Price                  $49.99 US
  905. Downloadable examples   `samp_db' distribution
  906.                        (http://www.kitebird.com/mysql-book/)
  907. Errata                  are available here
  908.                        (http://www.kitebird.com/mysql-book/errata.html)
  909.  
  910. Foreword by Michael "Monty" Widenius, MySQL Moderator.
  911. In _MySQL_, Paul DuBois provides you with a comprehensive guide to one
  912. of the most popular relational database systems.  Paul has contributed
  913. to the online documentation for MySQL and is an active member of the
  914. MySQL community.  The principal MySQL developer, Monty Widenius, and a
  915. network of his fellow developers reviewed the manuscript, and provided
  916. Paul with the kind of insight no one else could supply.
  917. Instead of merely giving you a general overview of MySQL, Paul teaches
  918. you how to make the most of its capabilities.  Through two sample
  919. database applications that run throughout the book, he gives you
  920. solutions to problems you're sure to face.  He helps you integrate
  921. MySQL efficiently with third-party tools, such as PHP and Perl,
  922. enabling you to generate dynamic Web pages through database queries.
  923. He teaches you to write programs that access MySQL databases, and also
  924. provides a comprehensive set of references to column types, operators,
  925. functions, SQL syntax, MySQL programming, C API, Perl `DBI', and PHP
  926. API.  _MySQL_ simply gives you the kind of information you won't find
  927. anywhere else.
  928. If you use MySQL, this book provides you with:
  929.    * An introduction to MySQL and SQL.
  930.  
  931.    * Coverage of MySQL's data types and how to use them.
  932.  
  933.    * Thorough treatment of how to write client programs in C.
  934.  
  935.    * A guide to using the Perl `DBI' and PHP APIs for developing
  936.      command-line and Web-based applications.
  937.  
  938.    * Tips on administrative issues such as user accounts, backup, crash
  939.      recovery, and security.
  940.  
  941.    * Help in choosing an ISP for MySQL access.
  942.  
  943.    * A comprehensive reference for MySQL's data types, operators,
  944.      functions, and SQL statements and utilities.
  945.  
  946.    * Complete reference guides for MySQL's C API, the Perl `DBI' API,
  947.      and PHP's MySQL-related functions.
  948.  
  949. _MySQL & mSQL_
  950. Available              Barnes and Noble
  951.                        (http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=1565924347&bfmtype=book)
  952. Publisher              O'Reilly
  953. Authors                Randy Jay Yarger, George Reese & Tim King
  954. Pub Date               1st Edition July 1999
  955. ISBN                   1-56592-434-7, Order Number: 4347
  956. Pages                  506
  957. Price                  $34.95
  958.  
  959. This book teaches you how to use MySQL and `mSQL', two popular and
  960. robust database products that support key subsets of SQL on both Linux
  961. and Unix systems.  Anyone who knows basic C, Java, Perl, or Python can
  962. write a program to interact with a database, either as a stand-alone
  963. application or through a Web page.  This book takes you through the
  964. whole process, from installation and configuration to programming
  965. interfaces and basic administration.  Includes plenty of tutorial
  966. material.
  967. _Sams' Teach Yourself MySQL in 21 Days_
  968. Available              Barnes and Noble
  969.                        (http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0672319144&bfmtype=book)
  970. Publisher              Sams
  971. Authors                Mark Maslakowski and Tony Butcher
  972. Pub Date               June 2000
  973. ISBN                   0672319144
  974. Pages                  650
  975. Price                  $39.99
  976.  
  977. Sams' _Teach Yourself MySQL in 21 Days_ is for intermediate Linux users
  978. who want to move into databases.  A large share of the audience is Web
  979. developers who need a database to store large amounts of information
  980. that can be retrieved via the Web.
  981.  
  982. Sams' _Teach Yourself MySQL in 21 Days_ is a practical, step-by-step
  983. tutorial.  The reader will learn to design and employ this open source
  984. database technology into his or her Web site using practical, hands-on
  985. examples to follow.
  986. _E-Commerce Solutions with MySQL_
  987. Available              Barnes and Noble
  988.                        (http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0761524452&bfmtype=book)
  989. Publisher              Prima Communications, Inc.
  990. Authors                N/A
  991. Pub Date               January 2000
  992. ISBN                   0761524452
  993. Pages                  500
  994. Price                  $39.99
  995.  
  996. No description available.
  997. _MySQL and PHP from Scratch_
  998. Available              Barnes and Noble
  999.                        (http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0789724405&bfmtype=book)
  1000. Publisher              Que
  1001. Authors                N/A
  1002. Pub Date               September 2000
  1003. ISBN                   0789724405
  1004. Pages                  550
  1005. Price                  $34.99
  1006.  
  1007. This book puts together information on installing, setting up, and
  1008. troubleshooting Apache, MySQL, PHP3, and IMP into one complete volume.
  1009. You also learn how each piece is part of a whole by learning,
  1010. step-by-step, how to create a web-based e-mail system.  Learn to run
  1011. the equivalent of Active Server Pages (ASP) using PHP3, set up an
  1012. e-commerce site using a database and the Apache web server, and create
  1013. a data entry system (such as sales, product quality tracking, customer
  1014. preferences, etc) that no installation in the PC.
  1015. _Professional MySQL Programming_
  1016. Available              Barnes and Noble
  1017.                        (http://shop.barnesandnoble.com/bookSearch/isbnInquiry.asp?isbn=1861005164)
  1018. Publisher              Wrox Press, Inc.
  1019. Authors                N/A
  1020. Pub Date               Late 2001
  1021. ISBN                   1861005164
  1022. Pages                  1000
  1023. Price                  $49.99
  1024.  
  1025. No description available.
  1026. _Professional Linux Programming_
  1027. Available              Barnes and Noble
  1028.                        (http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=1861003013&bfmtype=book)
  1029. Publisher              Wrox Press, Inc.
  1030. Authors                N/A
  1031. Pub Date               September 2000
  1032. ISBN                   1861003013
  1033. Pages                  1155
  1034. Price                  $47.99
  1035.  
  1036. In this follow-up to the best-selling _Beginning Linux Programming_,
  1037. you will learn from the authors' real-world knowledge and experience of
  1038. developing software for Linux; you'll be taken through the development
  1039. of a sample 'DVD Store' application, with 'theme' chapters addressing
  1040. different aspects of its implementation.  Meanwhile, individual
  1041. "take-a-break" chapters cover important topics that go beyond the
  1042. bounds of the central theme.  All focus on the practical aspects of
  1043. programming, showing how crucial it is to choose the right tools for
  1044. the job, use them as they should be used, and get things right first
  1045. time.
  1046. _PHP and MySQL Web Development_
  1047. Available              Barnes and Noble
  1048.                        (http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0672317842&bfmtype=book)
  1049. Publisher              Sams
  1050. Authors                Luke Welling, Laura Thomson
  1051. Pub Date               March 2001
  1052. ISBN                   0672317842
  1053. Pages                  700
  1054. Price                  $49.99
  1055.  
  1056. _PHP and MySQL Web Development_ introduces you to the advantages of
  1057. implementing both MySQL and PHP.  These advantages are detailed through
  1058. the provision of both statistics and several case studies.  A practical
  1059. web application is developed throughout the book, providing you with
  1060. the tools necessary to implement a functional online database.  Each
  1061. function is developed separately, allowing you the choice to
  1062. incorporate only those parts that you would like to implement.
  1063. Programming concepts of the PHP language are highlighted, including
  1064. functions which tie MySQL support into a PHP script and advanced topics
  1065. regarding table manipulation.
  1066. *Books recommended by the MySQL Developers*
  1067.  
  1068. _SQL-99 Complete, Really_
  1069. Available              Barnes and Noble
  1070.                        (http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0879305681&bfmtype=book)
  1071. Publisher              CMP Books
  1072. Authors                Peter Gulutzan, Trudy Pelzer
  1073. Pub Date               April 1999
  1074. ISBN                   0879305681
  1075. Pages                  1104
  1076. Price                  $55.96
  1077.  
  1078. This book contains complete descriptions of the new standards for
  1079. syntax, data structures, and retrieval processes of SQL databases.  As
  1080. an example-based reference manual, it includes all of the CLI
  1081. functions, information, schema tables, and status codes, as well as a
  1082. working SQL database provided on the companion disk.
  1083. _C, A reference manual_
  1084. Available              Barnes and Noble
  1085.                        (http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0133262243&bfmtype=book)
  1086. Publisher              Prentice Hall
  1087. Authors                Samuel P. Harbison, Guy L. Steele
  1088. Pub Date               September 1994
  1089. ISBN                   0133262243
  1090. Pages                  480
  1091. Price                  $35.99
  1092.  
  1093. A new and improved revision of the bestselling C language reference.
  1094. This manual introduces the notion of "Clean C", writing C code that can
  1095. be compiled as a C++ program, C programming style that emphasizes
  1096. correctness, portability, maintainability, and incorporates the ISO C
  1097. Amendment 1 (1994) which specifies new facilities for writing portable,
  1098. international programs in C.
  1099. _C++ for Real Programmers_
  1100. Available              Barnes and Noble
  1101.                        (http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0120499428&bfmtype=book)
  1102. Publisher              Academic Press, Incorporated
  1103. Authors                Jeff Alger, Jim Keogh
  1104. Pub Date               February 1998
  1105. ISBN                   0120499428
  1106. Pages                  388
  1107. Price                  $39.95
  1108.  
  1109. _C++ For Real Programmers_ bridges the gap between C++ as described in
  1110. beginner and intermediate-level books and C++ as it is practiced by
  1111. experts.  Numerous valuable techniques are described, organized into
  1112. three simple themes: indirection, class hierarchies, and memory
  1113. management.  It also provides in-depth coverage of template creation,
  1114. exception handling, pointers and optimization techniques.  The focus of
  1115. the book is on ANSI C++ and, as such, is compiler independent.
  1116.  
  1117. _C++ For Real Programmers_ is a revision of _Secrets of the C++
  1118. Masters_ and includes a new appendix comparing C++ with Java.  The book
  1119. comes with a 3.5" disk for Windows with source code.
  1120. _Algorithms in C_
  1121. Available              Barnes and Noble
  1122.                        (http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0201514257&bfmtype=book)
  1123. Publisher              Addison Wesley Longman, Inc.
  1124. Authors                Robert Sedgewick
  1125. Pub Date               April 1990
  1126. ISBN                   0201514257
  1127. Pages                  648
  1128. Price                  $45.75
  1129.  
  1130. _Algorithms in C_ describes a variety of algorithms in a number of
  1131. areas of interest, including: sorting, searching, string-processing, and
  1132. geometric, graph and mathematical algorithms.  The book emphasizes
  1133. fundamental techniques, providing readers with the tools to confidently
  1134. implement, run, and debug useful algorithms.
  1135. _Multithreaded Programming with Pthreads_
  1136. Available              Barnes and Noble
  1137.                        (http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=0136807291&bfmtype=book)
  1138. Publisher              Prentice Hall
  1139. Authors                Bil Lewis, Daniel J. Berg
  1140. Pub Date               October 1997
  1141. ISBN                   0136807291
  1142. Pages                  432
  1143. Price                  $34.95
  1144.  
  1145. Based on the best-selling _Threads Primer_, _Multithreaded Programming
  1146. with Pthreads_ gives you a solid understanding of Posix threads: what
  1147. they are, how they work, when to use them, and how to optimize them. It
  1148. retains the clarity and humor of _Threads Primer_, but includes
  1149. expanded comparisons to Win32 and OS/2 implementations.  Code examples
  1150. tested on all of the major UNIX platforms are featured along with
  1151. detailed explanations of how and why they use threads.
  1152. _Programming the PERL DBI: Database Programming with PERL_
  1153. Available              Barnes and Noble
  1154.                        (http://service.bfast.com/bfast/click?bfmid=2181&sourceid=34233559&bfpid=1565926994&bfmtype=book)
  1155. Publisher              O'Reilly & Associates, Incorporated
  1156. Authors                Alligator Descartes, Tim Bunce
  1157. Pub Date               February 2000
  1158. ISBN                   1565926994
  1159. Pages                  400
  1160. Price                  $27.96
  1161.  
  1162. _Programming the Perl DBI_ is coauthored by Alligator Descartes, one of
  1163. the most active members of the DBI community, and by Tim Bunce, the
  1164. inventor of DBI.  For the uninitiated, the book explains the
  1165. architecture of DBI and shows you how to write DBI-based programs.  For
  1166. the experienced DBI dabbler, this book explains DBI's nuances and the
  1167. peculiarities of each individual DBD.
  1168.  
  1169. The book includes:
  1170.    * An introduction to DBI and its design.
  1171.  
  1172.    * How to construct queries and bind parameters.
  1173.  
  1174.    * Working with database, driver, and statement handles.
  1175.  
  1176.    * Debugging techniques.
  1177.  
  1178.    * Coverage of each existing DBD.
  1179.  
  1180.    * A complete reference to DBI.
  1181.  
  1182. 
  1183. File: mysql.info,  Node: General-SQL,  Next: Useful Links,  Prev: MySQL-Books,  Up: MySQL Information Sources
  1184.  
  1185. General SQL Information and Tutorials
  1186. -------------------------------------
  1187.  
  1188. The following book has been recommended by several people on the MySQL
  1189. mailing list:
  1190.  
  1191.      Judith S. Bowman, Sandra L. Emerson and Marcy Darnovsky
  1192.      _The Practical SQL Handbook: Using Structured Query Language_
  1193.      Second Edition
  1194.      Addison-Wesley
  1195.      ISBN 0-201-62623-3
  1196.      http://www.awl.com
  1197.  
  1198. The following book has also received some recommendations by MySQL
  1199. users:
  1200.  
  1201.      Martin Gruber
  1202.      _Understanding SQL_
  1203.      ISBN 0-89588-644-8
  1204.      Publisher Sybex 510 523 8233
  1205.      Alameda, CA USA
  1206.  
  1207. A SQL tutorial is available on the net at
  1208. http://w3.one.net/~jhoffman/sqltut.htm
  1209.  
  1210. 
  1211. File: mysql.info,  Node: Useful Links,  Next: Questions,  Prev: General-SQL,  Up: MySQL Information Sources
  1212.  
  1213. Useful MySQL-related Links
  1214. --------------------------
  1215.  
  1216. Apart from the following links, you can find and download a lot of
  1217. MySQL programs, tools and APIs from the Contrib directory
  1218. (http://www.mysql.com/Downloads/Contrib/).
  1219.  
  1220. MySQL
  1221.  
  1222. Tutorials and Manuals
  1223. ---------------------
  1224.  
  1225. MySQL Myths Debunked (http://michael.bacarella.com/research/mysqlmyths.html)
  1226.      MySQL used in the real world.
  1227.  
  1228. `http://www.4t2.com/mysql'
  1229.      Information about the German MySQL mailing list.
  1230.  
  1231. `http://www2.rent-a-database.de/mysql/'
  1232.      MySQL handbook in German.
  1233.  
  1234. `http://www.bitmover.com:8888//home/bk/mysql'
  1235.      Web access to the MySQL BitKeeper repository.
  1236.  
  1237. `http://www.analysisandsolutions.com/code/mybasic.htm'
  1238.      Beginners MySQL Tutorial on how to install and set up MySQL on a
  1239.      Windows machine.
  1240.  
  1241. `http://www.devshed.com/Server_Side/MySQL/'
  1242.      A lot of MySQL tutorials.
  1243.  
  1244. `http://mysql.hitstar.com/'
  1245.      MySQL manual in Chinese.
  1246.  
  1247. `http://www.linuxplanet.com/linuxplanet/tutorials/1046/1/'
  1248.      Setting Up a MySQL-based Web site.
  1249.  
  1250. `http://www.hotwired.com/webmonkey/backend/tutorials/tutorial1.html'
  1251.      MySQL-Perl tutorial.
  1252.  
  1253. `http://www.iserver.com/support/contrib/perl5/modules.html'
  1254.      Installing new Perl modules that require locally installed modules.
  1255.  
  1256. `http://www.hotwired.com/webmonkey/databases/tutorials/tutorial4.html'
  1257.      PHP/MySQL Tutorial.
  1258.  
  1259. `http://www.useractive.com/'
  1260.      Hands on tutorial for MySQL.
  1261.  
  1262. Porting MySQL/Using MySQL on Different Systems
  1263. ----------------------------------------------
  1264.  
  1265. `http://www.entropy.ch/software/macosx/mysql/'
  1266.      Binary of MySQL for Mac OS X Client.  Includes information of how
  1267.      to build and use MySQL on Mac OS X.
  1268.  
  1269. `http://xclave.macnn.com/MySQL/'
  1270.      The Mac OS Xclave.  Running MySQL on Mac OS X.
  1271.  
  1272. `http://www.prnet.de/RegEx/mysql.html'
  1273.      MySQL for Mac OS X Server.
  1274.  
  1275. `http://www.latencyzero.com/macosx/mysql.html'
  1276.      Building MySQL for Mac OS X.
  1277.  
  1278. `http://www.essencesw.com/Software/mysqllib.html'
  1279.      New Client libraries for the Mac OS Classic (Macintosh).
  1280.  
  1281. `http://www.lilback.com/macsql/'
  1282.      Client libraries for Mac OS Classic (Macintosh).
  1283.  
  1284. `http://sixk.maniasys.com/index_en.html'
  1285.      MySQL for Amiga
  1286.  
  1287. Perl-related Links
  1288. ------------------
  1289.  
  1290. `http://dbimysql.photoflux.com/'
  1291.      Perl DBI with MySQL FAQ.
  1292.  
  1293. MySQL Discussion Forums
  1294. -----------------------
  1295.  
  1296. `http://www.weberdev.com/'
  1297.      Examples using MySQL; (check Top 20)
  1298.  
  1299. `http://futurerealm.com/forum/futureforum.htm'
  1300.      FutureForum Web Discussion Software.
  1301.  
  1302. Commercial Applications that Support MySQL
  1303. ------------------------------------------
  1304.  
  1305. `http://www.supportwizard.com/'
  1306.      SupportWizard; Interactive helpdesk on the Web (This product
  1307.      includes a licensed copy of MySQL.)
  1308.  
  1309. `http://www.sonork.com/'
  1310.      Sonork,  Instant Messenger that is not only Internet oriented.
  1311.      It's focused on private networks and on small to medium companies.
  1312.      Client is free, server is free for up to 5 seats.
  1313.  
  1314. `http://www.stweb.org/'
  1315.      StWeb - Stratos Web and Application server - An easy-to-use, cross
  1316.      platform, Internet/Intranet development and deployment system for
  1317.      development of web-enabled applications.  The standard version of
  1318.      StWeb has a native interface to MySQL database.
  1319.  
  1320. `http://www.rightnowtech.com/'
  1321.      Right Now Web; Web automation for customer service.
  1322.  
  1323. `http://www.icaap.org/Bazaar/'
  1324.      Bazaar; Interactive Discussion Forums with Web interface.
  1325.  
  1326. `http://www.phonesweep.com/'
  1327.      PhoneSweepT is the world's first commercial Telephone Scanner.
  1328.      Many break-ins in recent years have come not through the Internet,
  1329.      but through unauthorized dial-up modems.  PhoneSweep lets you find
  1330.      these modems by repeatedly placing phone calls to every phone
  1331.      number that your organization controls.  PhoneSweep has a built-in
  1332.      expert system that can recognize more than 250 different kinds of
  1333.      remote-access programs, including Carbon Copy(TM), pcANYWHERE(TM),
  1334.      and Windows NT RAS.  All information is stored in the SQL
  1335.      database.  It then generates a comprehensive report detailing
  1336.      which services were discovered on which dial-up numbers in your
  1337.      organization.
  1338.  
  1339. SQL Clients and Report Writers
  1340. ------------------------------
  1341.  
  1342. urSQL (http://www.urbanresearch.com/software/utils/urbsql/index.html)
  1343.      SQL Editor and Query Utility. Custom syntax highlighting, editable
  1344.      results grid, exportable result-sets, basic MySQL admin functions,
  1345.      Etc.. For Windows.
  1346.  
  1347. MySQL Data Manager (http://www.edatanew.com/)
  1348.      MySQL Data Manager * is platform independent web client (written
  1349.      in perl) for MySQL server over TCP/IP.
  1350.  
  1351. `http://ksql.sourceforge.net/'
  1352.      KDE MySQL client.
  1353.  
  1354. `http://www.ecker-software.de'
  1355.      A Windows GUI client by David Ecker.
  1356.  
  1357. `http://www.icaap.org/software/kiosk/'
  1358.      Kiosk; a MySQL client for database management.  Written in Perl.
  1359.      Will be a part of Bazaar.
  1360.  
  1361. `http://www.casestudio.com/'
  1362.      Db design tool that supports MySQL 3.23.
  1363.  
  1364. `http://home.skif.net/~voland/zeos/eng/index.html'
  1365.      Zeos - A client that supports MySQL, Interbase and PostgreSQL.
  1366.  
  1367. `http://www.geocities.com/SiliconValley/Ridge/4280/GenericReportWriter/grwhome.html'
  1368.      A free report writer in Java
  1369.  
  1370. `http://www.javaframework.de'
  1371.      MySQLExport - Export of MySQL create statements and data in a lot
  1372.      of different formats (SQL, HTML, CVS, text, ZIP, GZIP...)
  1373.  
  1374. `http://dlabs.4t2.com'
  1375.      M2D, a MySQL Administration client for Windows.  M2D supports
  1376.      administration of MySQL databases, creation of new databases and
  1377.      tables, editing, and more.
  1378.  
  1379. `http://dlabs.4t2.com'
  1380.      Dexter, a small server written in Perl which can be used as a
  1381.      proxy server for MySQL or as a database extender.
  1382.  
  1383. `http://www.scibit.com/Products/Software/Utils/Mascon.asp'
  1384.      Mascon is a powerful Win32 GUI for administering MySQL databases.
  1385.  
  1386. `http://www.rtlabs.com/'
  1387.      MacSQL Monitor.  GUI for MySQL, ODBC, and JDBC databases for the
  1388.      Mac OS.
  1389.  
  1390. Distributions that Include MySQL
  1391. --------------------------------
  1392.  
  1393. `http://www.suse.com/'
  1394.      SuSE Linux (6.1 and above)
  1395.  
  1396. `http://www.redhat.com/'
  1397.      RedHat Linux (7.0 and above)
  1398.  
  1399. `http://distro.conectiva.com.br'
  1400.      Conectiva Linux (4.0 and above)
  1401.  
  1402. Web Development Tools that Support MySQL
  1403. ----------------------------------------
  1404.  
  1405. `http://www.php.net/'
  1406.      PHP: A server-side HTML-embedded scripting language.
  1407.  
  1408. `http://www.midgard-project.org'
  1409.      The Midgard Application Server; a powerful Web development
  1410.      environment based on MySQL and PHP.
  1411.  
  1412. `http://www.smartworker.org'
  1413.      SmartWorker is a platform for Web application development.
  1414.  
  1415. `http://xsp.lentus.se/'
  1416.      XSP: e(X)tendible (S)erver (P)ages and is a HTML embedded tag
  1417.      language written in Java (previously known as XTAGS.)
  1418.  
  1419. `http://www.dbServ.de/'
  1420.      dbServ is an extension to a web server to integrate database
  1421.      output into your HTML code.  You may use any HTML function in your
  1422.      output.  Only the client will stop you.  It works as standalone
  1423.      server or as Java servlet.
  1424.  
  1425. `http://www.chilisoft.com/'
  1426.      Platform independent ASP from Chili!Soft
  1427.  
  1428. `http://www.voicenet.com/~zellert/tjFM'
  1429.      A JDBC driver for MySQL.
  1430.  
  1431. `http://www.wernhart.priv.at/php/'
  1432.      MySQL + PHP demos.
  1433.  
  1434. `http://www.dbwww.com/'
  1435.      ForwardSQL: HTML interface to manipulate MySQL databases.
  1436.  
  1437. `http://www.daa.com.au/~james/www-sql/'
  1438.      WWW-SQL: Display database information.
  1439.  
  1440. `http://www.minivend.com/minivend/'
  1441.      Minivend: A Web shopping cart.
  1442.  
  1443. `http://www.heitml.com/'
  1444.      HeiTML: A server-side extension of HTML and a 4GL language at the
  1445.      same time.
  1446.  
  1447. `http://www.metahtml.com/'
  1448.      Metahtml: A Dynamic Programming Language for WWW Applications.
  1449.  
  1450. `http://www.binevolve.com/'
  1451.      VelocityGen for Perl and Tcl.
  1452.  
  1453. `http://hawkeye.net/'
  1454.      Hawkeye Internet Server Suite.
  1455.  
  1456. `http://www.fastflow.com/'
  1457.      Network Database Connection For Linux
  1458.  
  1459. `http://www.wdbi.net/'
  1460.      WDBI: Web browser as a universal front end to databases which
  1461.      supports MySQL well.
  1462.  
  1463. `http://www.webgroove.com/'
  1464.      WebGroove Script: HTML compiler and server-side scripting language.
  1465.  
  1466. `http://www.ihtml.com/'
  1467.      A server-side Web site scripting language.
  1468.  
  1469. `ftp://ftp.igc.apc.org/pub/myodbc/README'
  1470.      How to use MySQL with ColdFusion on Solaris.
  1471.  
  1472. `http://calistra.com/MySQL/'
  1473.      Calistra's ODBC MySQL Administrator.
  1474.  
  1475. `http://www.webmerger.com'
  1476.      Webmerger -  This CGI tool interprets files and generates dynamic
  1477.      output based on a set of simple tags.  Ready-to-run drivers for
  1478.      MySQL and PostgreSQL through ODBC.
  1479.  
  1480. `http://phpclub.net/'
  1481.      PHPclub - Tips and tricks for PHP.
  1482.  
  1483. `http://www.penguinservices.com/scripts'
  1484.      MySQL and Perl Scripts.
  1485.  
  1486. `http://www.widgetchuck.com'
  1487.      The Widgetchuck; Web Site Tools and Gadgets
  1488.  
  1489. `http://www.adcycle.com/'
  1490.      AdCycle - advertising management software.
  1491.  
  1492. `http://sourceforge.net/projects/pwpage/'
  1493.      pwPage - provides an extremely fast and simple approach to the
  1494.      creation of database forms.  That is, if a database table exists
  1495.      and an HTML page has been constructed using a few simple
  1496.      guidelines, pwPage can be immediately used for table data
  1497.      selections, insertions, updates, deletions and selectable table
  1498.      content reviewing.
  1499.  
  1500. `http://www.omnis-software.com/products/studio/studio.html'
  1501.      OMNIS Studio is a rapid application development (RAD) tool.
  1502.  
  1503. `http://www.webplus.com'
  1504.      talentsoft Web+ 4.6 - a powerful and comprehensive development
  1505.      language for use in creating web-based client/server applications
  1506.      without writing complicated, low-level, and time-consuming CGI
  1507.      programs.
  1508.  
  1509. Database Design Tools with MySQL Support
  1510. ----------------------------------------
  1511.  
  1512. `http://www.mysql.com/documentation/dezign/'
  1513.      "DeZign for databases" is a database development tool that uses an
  1514.      entity relationship diagram (ERD).
  1515.  
  1516. Web Servers with MySQL Tools
  1517. ----------------------------
  1518.  
  1519. `ftp://ftp.kcilink.com/pub/'
  1520.      mod_auth_mysql, An Apache authentication module.
  1521.  
  1522. `http://www.roxen.com/'
  1523.      The Roxen Challenger Web server.
  1524.  
  1525. Extensions for Other Programs
  1526. -----------------------------
  1527.  
  1528. `http://www.seawood.org/msql_bind/'
  1529.      MySQL support for BIND (The Internet Domain Name Server).
  1530.  
  1531. `http://www.inet-interactive.com/sendmail/'
  1532.      MySQL support for Sendmail and Procmail.
  1533.  
  1534. Using MySQL with Other Programs
  1535. -------------------------------
  1536.  
  1537. `http://www.iserver.com/support/addonhelp/database/mysql/msaccess.html'
  1538.      Using MySQL with Access.
  1539.  
  1540. `http://www.iserver.com/support/contrib/perl5/modules.html'
  1541.      Installing new Perl modules that require locally installed modules.
  1542.  
  1543. ODBC-related Links
  1544. ------------------
  1545.  
  1546. `http://www.iodbc.org/'
  1547.      Popular iODBC Driver Manager (libiodbc) now available as Open
  1548.      Source.
  1549.  
  1550. `http://users.ids.net/~bjepson/freeODBC/'
  1551.      The FreeODBC Pages.
  1552.  
  1553. `http://genix.net/unixODBC/'
  1554.      The unixODBC Project goals are to develop and promote unixODBC to
  1555.      be the definitive standard for ODBC on the Linux platform.  This
  1556.      is to include GUI support for KDE.
  1557.  
  1558. `http://www.sw-soft.com/products/BtrieveODBC/'
  1559.      A MySQL-based ODBC driver for Btrieve.
  1560.  
  1561. *API*-related Links
  1562. -------------------
  1563.  
  1564. `http://www.jppp.com/'
  1565.      Partially implemented TDataset-compatible components for MySQL.
  1566.  
  1567. `http://www.riverstyx.net/qpopmysql/'
  1568.      qpopmysql - A patch to allow POP3 authentication from a MySQL
  1569.      database.  There's also a link to Paul Khavkine's patch for
  1570.      Procmail to allow any MTA to deliver to users in a MySQL database.
  1571.  
  1572. `http://www.pbc.ottawa.on.ca'
  1573.      Visual Basic class generator for Active X.
  1574.  
  1575. `http://www.essencesw.com/Software/mysqllib.html'
  1576.      New Client libraries for the Mac OS Classic (Macintosh).
  1577.  
  1578. `http://www.lilback.com/macsql/'
  1579.      Client libraries for the Macintosh.
  1580.  
  1581. `http://www.essencesw.com/Plugins/mysqlplug.html'
  1582.      Plugin for REALbasic (for Macintosh)
  1583.  
  1584. `http://www.iis.ee.ethz.ch/~neeri/macintosh/gusi-qa.html'
  1585.      A library that emulates BSD sockets and pthreads on Macintosh.
  1586.      This can be used if you want to compile the MySQL client library
  1587.      on Mac.  It could probably even be sued to port MySQL to
  1588.      Macintosh, but we don't know of anyone that has tried that.
  1589.  
  1590. `http://www.dedecker.net/jessie/scmdb/'
  1591.      SCMDB - an add-on for SCM that ports the MySQL C library to scheme
  1592.      (SCM).  With this library scheme developers can make connections
  1593.      to a MySQL database and use embedded SQL in their programs.
  1594.  
  1595. Other MySQL-related Links
  1596. -------------------------
  1597.  
  1598. SAT (http://www.satisoft.com/)
  1599.      The Small Application Toolkit (SAT) is a collection of utilities
  1600.      intended to simplify the development of small, multi-user, GUI
  1601.      based applications in a (Microsoft -or- X) Windows Client / Unix
  1602.      Server environment.
  1603.  
  1604. `http://www.wix.com/mysql-hosting/'
  1605.      Registry of Web providers who support MySQL.
  1606.  
  1607. `http://www.softagency.co.jp/mysql/index.en.html'
  1608.      Links about using MySQL in Japan/Asia.
  1609.  
  1610. `http://abattoir.cc.ndsu.nodak.edu/~nem/mysql/udf/'
  1611.      MySQL UDF Registry.
  1612.  
  1613. `http://www.open.com.au/products.html'
  1614.      Commercial Web defect tracking system.
  1615.  
  1616. `http://www.stonekeep.com/pts/'
  1617.      PTS: Project Tracking System.
  1618.  
  1619. `http://tomato.nvgc.vt.edu/~hroberts/mot'
  1620.      Job and software tracking system.
  1621.  
  1622. `http://www.cynergi.net/exportsql/'
  1623.      ExportSQL: A script to export data from Access95+.
  1624.  
  1625. `http://SAL.KachinaTech.COM/H/1/MYSQL.html'
  1626.      SAL (Scientific Applications on Linux) MySQL entry.
  1627.  
  1628. `http://www.infotech-nj.com/itech/index.shtml'
  1629.      A consulting company which mentions MySQL in the right company.
  1630.  
  1631. `http://www.pmpcs.com/'
  1632.      PMP Computer Solutions.  Database developers using MySQL and
  1633.      `mSQL'.
  1634.  
  1635. `http://www.aewa.org/'
  1636.      Airborne Early Warning Association.
  1637.  
  1638. `http://www.dedserius.com/y2kmatrix/'
  1639.      Y2K tester.
  1640.  
  1641. SQL and Database Interfaces
  1642. ---------------------------
  1643.  
  1644. `http://java.sun.com/products/jdbc/'
  1645.      The JDBC database access API.
  1646.  
  1647. `http://www.gagme.com/mysql'
  1648.      Patch for `mSQL' Tcl.
  1649.  
  1650. `http://www.amsoft.ru/easysql/'
  1651.      EasySQL: An ODBC-like driver manager.
  1652.  
  1653. `http://www.lightlink.com/hessling/rexxsql.html'
  1654.      A REXX interface to SQL databases.
  1655.  
  1656. `http://www.mytcl.cx/'
  1657.      Tcl interface based on tcl-sql with many bugfixes.
  1658.  
  1659. `http://www.binevolve.com/~tdarugar/tcl-sql/'
  1660.      Tcl interface.
  1661.  
  1662. `http://www.contrib.andrew.cmu.edu/~shadow/sql.html'
  1663.      SQL Reference Page with a lot of interesting links.
  1664.  
  1665. Examples of MySQL Use
  1666. ---------------------
  1667.  
  1668. `http://www.little6.com/about/linux/'
  1669.      Little6 Inc., An online contract and job finding site that is
  1670.      powered by MySQL, PHP3, and Linux.
  1671.  
  1672. `http://www.delec.com/is/products/prep/examples/BookShelf/index.html'
  1673.      DELECis - A tool that makes it very easy to create an
  1674.      automatically generated table documentation. They have used MySQL
  1675.      as an example.
  1676.  
  1677. `http://www.worldrecords.com'
  1678.      World Records - A search engine for information about music that
  1679.      uses MySQL and PHP.
  1680.  
  1681. `http://www.webtechniques.com/archives/1998/01/note/'
  1682.      A Contact Database using MySQL and PHP.
  1683.  
  1684. `http://modems.rosenet.net/mysql/'
  1685.      Web based interface and Community Calendar with PHP.
  1686.  
  1687. `http://www.odbsoft.com/cook/sources.htm'
  1688.      Perl package to generate html from a SQL table structure and for
  1689.      generating SQL statements from an html form.
  1690.  
  1691. `http://www.gusnet.cx/proj/telsql/'
  1692.      Basic telephone database using `DBI'/`DBD'.
  1693.  
  1694. `http://tecfa.unige.ch/guides/java/staf2x/ex/jdbc/coffee-break'
  1695.      JDBC examples by Daniel K. Schneider.
  1696.  
  1697. `http://www.spade.com/linux/howto/PostgreSQL-HOWTO-41.html'
  1698.      SQL BNF
  1699.  
  1700. `http://www.ooc.com/'
  1701.      Object Oriented Concepts Inc; CORBA applications with examples in
  1702.      source.
  1703.  
  1704. `http://www.pbc.ottawa.on.ca/'
  1705.      DBWiz; Includes an example of how to manage cursors in VB.
  1706.  
  1707. `http://keilor.cs.umass.edu/pluribus/'
  1708.      Pluribus is a free search engine that learns to improve the
  1709.      quality of its results over time.  Pluribus works by recording
  1710.      which pages a user prefers among those returned for a query.  A
  1711.      user votes for a page by selecting it; Pluribus then uses that
  1712.      knowledge to improve the quality of the results when someone else
  1713.      submits the same (or similar) query.  Uses PHP and MySQL.
  1714.  
  1715. `http://www.stopbit.com/'
  1716.      Stopbit - A technology news site using MySQL and PHP.
  1717.  
  1718. `http://www.linuxsupportline.com/~kalendar/'
  1719.      KDE based calendar manager - The calendar manager has both single
  1720.      user (file based) and multi-user (MySQL database) support.
  1721.  
  1722. `http://tim.desert.net/~tim/imger/'
  1723.      Example of storing/retrieving images with MySQL and CGI.
  1724.  
  1725. `http://www.penguinservices.com/scripts'
  1726.      Online shopping cart system.
  1727.  
  1728. `http://www.city-gallery.com/album/'
  1729.      Old Photo Album - The album is a collaborative popular history of
  1730.      photography project that generates all pages from data stored in a
  1731.      MySQL database.  Pages are dynamically generated through a php3
  1732.      interface to the database content.  Users contribute images and
  1733.      descriptions.  Contributed images are stored on the web server to
  1734.      avoid storing them in the database as BLOBs.  All other
  1735.      information is stored on the shared MySQL server.
  1736.  
  1737. General Database Links
  1738. ----------------------
  1739.  
  1740. `http://www.pcslink.com/~ej/dbweb.html'
  1741.      Database Jump Site
  1742.  
  1743. `http://black.hole-in-the.net/guy/webdb/'
  1744.      Homepage of the webdb-l (Web Databases) mailing list.
  1745.  
  1746. `http://www.symbolstone.org/technology/perl/DBI/index.html'
  1747.      Perl `DBI'/`DBD' modules homepage.
  1748.  
  1749. `http://www.student.uni-koeln.de/cygwin/'
  1750.      Cygwin tools.  Unix on top of Windows.
  1751.  
  1752. `http://dbasecentral.com/'
  1753.      dbasecentral.com; Development and distribution of powerful and
  1754.      easy-to-use database applications and systems.
  1755.  
  1756. `http://www.tek-tips.com/'
  1757.      Tek-Tips Forums are 800+ independent peer-to-peer non-commercial
  1758.      support forums for Computer Professionals.  Features include
  1759.      automatic e-mail notification of responses, a links library, and
  1760.      member confidentiality guaranteed.
  1761.  
  1762. `http://www.public.asu.edu/~peterjn/btree/'
  1763.      B-Trees: Balanced Tree Data Structures.
  1764.  
  1765. `http://www.fit.qut.edu.au/~maire/baobab/lecture/sld001.htm'
  1766.      A lecture about B-Trees.
  1767.  
  1768. There are also many Web pages that use MySQL.  *Note Users::.  Send any
  1769. additions to this list to <webmaster@mysql.com>. We now require that
  1770. you show a MySQL logo somewhere if you wish your site to be added.  It
  1771. is okay to have it on a "used tools" page or something similar.
  1772.  
  1773. 
  1774. File: mysql.info,  Node: Questions,  Prev: Useful Links,  Up: MySQL Information Sources
  1775.  
  1776. MySQL Mailing Lists
  1777. -------------------
  1778.  
  1779. * Menu:
  1780.  
  1781. * Mailing-list::                The MySQL mailing lists
  1782. * Asking questions::            Asking questions or reporting bugs
  1783. * Bug reports::                 How to report bugs or problems
  1784. * Answering questions::         Guidelines for answering questions on the mailing list
  1785.  
  1786. This section introduces you to the MySQL mailing lists, and gives some
  1787. guidelines as to how to use them.
  1788.  
  1789. 
  1790. File: mysql.info,  Node: Mailing-list,  Next: Asking questions,  Prev: Questions,  Up: Questions
  1791.  
  1792. The MySQL Mailing Lists
  1793. .......................
  1794.  
  1795. To subscribe to the main MySQL mailing list, send a message to the
  1796. electronic mail address <mysql-subscribe@lists.mysql.com>.
  1797.  
  1798. To unsubscribe from the main MySQL mailing list, send a message to the
  1799. electronic mail address <mysql-unsubscribe@lists.mysql.com>.
  1800.  
  1801. Only the address to which you send your messages is significant.  The
  1802. subject line and the body of the message are ignored.
  1803.  
  1804. If your reply address is not valid, you can specify your address
  1805. explicitly.  Adding a hyphen to the subscribe or unsubscribe command
  1806. word, followed by your address with the `@' character in your address
  1807. replaced by a `='.  For example, to subscribe `your_name@host.domain',
  1808. send a message to
  1809. `mysql-subscribe-your_name=host.domain@lists.mysql.com'.
  1810.  
  1811. Mail to <mysql-subscribe@lists.mysql.com> or
  1812. <mysql-unsubscribe@lists.mysql.com> is handled automatically by the
  1813. ezmlm mailing list processor.  Information about ezmlm is available at
  1814. The ezmlm Website (http://www.ezmlm.org).
  1815.  
  1816. To post a message to the list itself, send your message to
  1817. `mysql@lists.mysql.com'.  However, please _do not_ send mail about
  1818. subscribing or unsubscribing to <mysql@lists.mysql.com>, because any
  1819. mail sent to that address is distributed automatically to thousands of
  1820. other users.
  1821.  
  1822. Your local site may have many subscribers to <mysql@lists.mysql.com>.
  1823. If so, it may have a local mailing list, so that messages sent from
  1824. `lists.mysql.com' to your site are propagated to the local list.  In
  1825. such cases, please contact your system administrator to be added to or
  1826. dropped from the local MySQL list.
  1827.  
  1828. If you wish to have traffic for a mailing list go to a separate mailbox
  1829. in your mail program, set up a filter based on the message headers.
  1830. You can use either the `List-ID:' or `Delivered-To:' headers to identify
  1831. list messages.
  1832.  
  1833. The following MySQL mailing lists exist:
  1834.  
  1835. `<announce-subscribe@lists.mysql.com> announce'
  1836.      This is for announcement of new versions of MySQL and related
  1837.      programs.  This is a low volume list all MySQL users should
  1838.      subscribe to.
  1839.  
  1840. `<mysql-subscribe@lists.mysql.com> mysql'
  1841.      The main list for general MySQL discussion.  Please note that some
  1842.      topics are better discussed on the more-specialized lists.  If you
  1843.      post to the wrong list, you may not get an answer!
  1844.  
  1845. `<mysql-digest-subscribe@lists.mysql.com> mysql-digest'
  1846.      The `mysql' list in digest form.  That means you get all individual
  1847.      messages, sent as one large mail message once a day.
  1848.  
  1849. `<bugs-subscribe@lists.mysql.com> bugs'
  1850.      On this list you should only post a full, repeatable bug report
  1851.      using the `mysqlbug' script (if you are running on Windows, you
  1852.      should include a description of the operating system and the MySQL
  1853.      version).  Preferably, you should test the problem using the
  1854.      latest stable or development version of MySQL before posting!
  1855.      Anyone should be able to repeat the bug by just using `mysql test
  1856.      < script' on the included test case.  All bugs posted on this list
  1857.      will be corrected or documented in the next MySQL release!  If
  1858.      there are only small code changes involved, we will also post a
  1859.      patch that fixes the problem.
  1860.  
  1861. `<bugs-digest-subscribe@lists.mysql.com> bugs-digest'
  1862.      The `bugs' list in digest form.
  1863.  
  1864. `<internals-subscribe@lists.mysql.com> internals'
  1865.      A list for people who work on the MySQL code.  On this list one
  1866.      can also discuss MySQL development and post patches.
  1867.  
  1868. `<internals-digest-subscribe@lists.mysql.com> internals-digest'
  1869.      A digest version of the `internals' list.
  1870.  
  1871. `<java-subscribe@lists.mysql.com> java'
  1872.      Discussion about MySQL and Java.  Mostly about the JDBC drivers.
  1873.  
  1874. `<java-digest-subscribe@lists.mysql.com> java-digest'
  1875.      A digest version of the `java' list.
  1876.  
  1877. `<win32-subscribe@lists.mysql.com> win32'
  1878.      All things concerning MySQL on Microsoft operating systems such as
  1879.      Win95, Win98, NT, and Win2000.
  1880.  
  1881. `<win32-digest-subscribe@lists.mysql.com> win32-digest'
  1882.      A digest version of the `win32' list.
  1883.  
  1884. `<myodbc-subscribe@lists.mysql.com> myodbc'
  1885.      All things about connecting to MySQL with ODBC.
  1886.  
  1887. `<myodbc-digest-subscribe@lists.mysql.com> myodbc-digest'
  1888.      A digest version of the `myodbc' list.
  1889.  
  1890. `<plusplus-subscribe@lists.mysql.com> plusplus'
  1891.      All things concerning programming with the C++ API to MySQL.
  1892.  
  1893. `<plusplus-digest-subscribe@lists.mysql.com> plusplus-digest'
  1894.      A digest version of the `plusplus' list.
  1895.  
  1896. `<msql-mysql-modules-subscribe@lists.mysql.com> msql-mysql-modules'
  1897.      A list about the Perl support in MySQL. msql-mysql-modules
  1898.  
  1899. `<msql-mysql-modules-digest-subscribe@lists.mysql.com> msql-mysql-modules-digest'
  1900.      A digest version of the `msql-mysql-modules' list.
  1901.  
  1902. You subscribe or unsubscribe to all lists in the same way as described
  1903. above.  In your subscribe or unsubscribe message, just put the
  1904. appropriate mailing list name rather than `mysql'.  For example, to
  1905. subscribe to or unsubscribe from the `myodbc' list, send a message to
  1906. <myodbc-subscribe@lists.mysql.com> or
  1907. <myodbc-unsubscribe@lists.mysql.com>.
  1908.  
  1909. If you can't get an answer for your questions from the mailing list, one
  1910. option is to pay for support from MySQL AB, which will put you in
  1911. direct contact with MySQL developers. *Note Support::.
  1912.  
  1913. The following table shows some MySQL mailing in other languages than
  1914. English.  Note that these are not operated by MySQL AB, so we can't
  1915. guarantee the quality on these.
  1916.  
  1917. `<mysql-france-subscribe@yahoogroups.com> A French mailing list'
  1918.  
  1919. `<list@tinc.net> A Korean mailing list'
  1920.      Email `subscribe mysql your@email.address' to this list.
  1921.  
  1922. `<mysql-de-request@lists.4t2.com> A German mailing list'
  1923.      Email `subscribe mysql-de your@email.address' to this list.  You
  1924.      can find information about this mailing list at
  1925.      `http://www.4t2.com/mysql'.
  1926.  
  1927. `<mysql-br-request@listas.linkway.com.br> A Portugese mailing list'
  1928.      Email `subscribe mysql-br your@email.address' to this list.
  1929.  
  1930. `<mysql-alta@elistas.net> A Spanish mailing list'
  1931.      Email `subscribe mysql your@email.address' to this list.
  1932.  
  1933. 
  1934. File: mysql.info,  Node: Asking questions,  Next: Bug reports,  Prev: Mailing-list,  Up: Questions
  1935.  
  1936. Asking Questions or Reporting Bugs
  1937. ..................................
  1938.  
  1939. Before posting a bug report or question, please do the following:
  1940.  
  1941.    * Start by searching the MySQL online manual at:
  1942.      `http://www.mysql.com/documentation/manual.php'
  1943.      We try to keep the manual up to date by updating it frequently with
  1944.      solutions to newly found problems!
  1945.  
  1946.    * Search the MySQL mailing list archives:
  1947.      `http://www.mysql.com/documentation/'
  1948.    * You can also use `http://www.mysql.com/search.html' to search all
  1949.      the Web pages (including the manual) that are located at
  1950.      `http://www.mysql.com/'.
  1951.  
  1952. If you can't find an answer in the manual or the archives, check with
  1953. your local MySQL expert.  If you still can't find an answer to your
  1954. question, go ahead and read the next section about how to send mail to
  1955. <mysql@lists.mysql.com>.
  1956.  
  1957. 
  1958. File: mysql.info,  Node: Bug reports,  Next: Answering questions,  Prev: Asking questions,  Up: Questions
  1959.  
  1960. How to Report Bugs or Problems
  1961. ..............................
  1962.  
  1963. Writing a good bug report takes patience, but doing it right the first
  1964. time saves time for us and for you.  A good bug report containing a full
  1965. test case for the bug will make it very likely that we will fix it in
  1966. the next release.  This section will help you write your report
  1967. correctly so that you don't waste your time doing things that may not
  1968. help us much or at all.
  1969.  
  1970. We encourage everyone to use the `mysqlbug' script to generate a bug
  1971. report (or a report about any problem), if possible.  `mysqlbug' can be
  1972. found in the `scripts' directory in the source distribution, or, for a
  1973. binary distribution, in the `bin' directory under your MySQL
  1974. installation directory.  If you are unable to use `mysqlbug', you should
  1975. still include all the necessary information listed in this section.
  1976.  
  1977. The `mysqlbug' script helps you generate a report by determining much
  1978. of the following information automatically, but if something important
  1979. is missing, please include it with your message!  Please read this
  1980. section carefully and make sure that all the information described here
  1981. is included in your report.
  1982.  
  1983. The normal place to report bugs and problems is
  1984. <mysql@lists.mysql.com>.  If you can make a test case that clearly
  1985. demonstrates the bug, you should post it to the <bugs@lists.mysql.com>
  1986. list.  Note that on this list you should only post a full, repeatable
  1987. bug report using the `mysqlbug' script.  If you are running on Windows,
  1988. you should include a description of the operating system and the MySQL
  1989. version.  Preferably, you should test the problem using the latest
  1990. stable or development version of MySQL before posting!  Anyone should
  1991. be able to repeat the bug by just using "`mysql test < script'" on the
  1992. included test case or run the shell or perl script that is included in
  1993. the bug report.  All bugs posted on the `bugs' list will be corrected
  1994. or documented in the next MySQL release!  If there are only small code
  1995. changes involved to correct this problem, we will also post a patch
  1996. that fixes the problem.
  1997.  
  1998. Remember that it is possible to respond to a message containing too much
  1999. information, but not to one containing too little.  Often people omit
  2000. facts because they think they know the cause of a problem and assume
  2001. that some details don't matter.  A good principle is: if you are in
  2002. doubt about stating something, state it!  It is a thousand times faster
  2003. and less troublesome to write a couple of lines more in your report
  2004. than to be forced to ask again and wait for the answer because you
  2005. didn't include enough information the first time.
  2006.  
  2007. The most common errors are that people don't indicate the version
  2008. number of the MySQL distribution they are using, or don't indicate what
  2009. platform they have MySQL installed on (including the platform version
  2010. number).  This is highly relevant information, and in 99 cases out of
  2011. 100 the bug report is useless without it!  Very often we get questions
  2012. like, "Why doesn't this work for me?" then we find that the feature
  2013. requested wasn't implemented in that MySQL version, or that a bug
  2014. described in a report has been fixed already in newer MySQL versions.
  2015. Sometimes the error is platform dependent; in such cases, it is next to
  2016. impossible to fix anything without knowing the operating system and the
  2017. version number of the platform.
  2018.  
  2019. Remember also to provide information about your compiler, if it is
  2020. related to the problem.  Often people find bugs in compilers and think
  2021. the problem is MySQL-related.  Most compilers are under development all
  2022. the time and become better version by version.  To determine whether or
  2023. not your problem depends on your compiler, we need to know what
  2024. compiler is used.  Note that every compiling problem should be regarded
  2025. as a bug report and reported accordingly.
  2026.  
  2027. It is most helpful when a good description of the problem is included
  2028. in the bug report.  That is, a good example of all the things you did
  2029. that led to the problem and the problem itself exactly described.  The
  2030. best reports are those that include a full example showing how to
  2031. reproduce the bug or problem.  *Note Reproduceable test case::.
  2032.  
  2033. If a program produces an error message, it is very important to include
  2034. the message in your report!  If we try to search for something from the
  2035. archives using programs, it is better that the error message reported
  2036. exactly matches the one that the program produces.  (Even the case
  2037. should be observed!)  You should never try to remember what the error
  2038. message was; instead, copy and paste the entire message into your
  2039. report!
  2040.  
  2041. If you have a problem with MyODBC, you should try to generate a MyODBC
  2042. trace file.  *Note MyODBC bug report::.
  2043.  
  2044. Please remember that many of the people who will read your report will
  2045. do so using an 80-column display.  When generating reports or examples
  2046. using the `mysql' command line tool, you should therefore use the
  2047. `--vertical' option (or the `\G' statement terminator) for output that
  2048. would exceed the available width for such a display (for example, with
  2049. the `EXPLAIN SELECT' statement; see the example below).
  2050.  
  2051. Please include the following information in your report:
  2052.  
  2053.    * The version number of the MySQL distribution you are using (for
  2054.      example, MySQL Version 3.22.22). You can find out which version you
  2055.      are running by executing `mysqladmin version'.  `mysqladmin' can be
  2056.      found in the `bin' directory under your MySQL installation
  2057.      directory.
  2058.  
  2059.    * The manufacturer and model of the machine you are working on.
  2060.  
  2061.    * The operating system name and version.  For most operating
  2062.      systems, you can get this information by executing the Unix
  2063.      command `uname -a'.
  2064.  
  2065.    * Sometimes the amount of memory (real and virtual) is relevant. If
  2066.      in doubt, include these values.
  2067.  
  2068.    * If you are using a source distribution of MySQL, the name and
  2069.      version number of the compiler used is needed.  If you have a
  2070.      binary distribution, the distribution name is needed.
  2071.  
  2072.    * If the problem occurs during compilation, include the exact error
  2073.      message(s) and also a few lines of context around the offending
  2074.      code in the file where the error occurred.
  2075.  
  2076.    * If `mysqld' died, you should also report the query that crashed
  2077.      `mysqld'.  You can usually find this out by running `mysqld' with
  2078.      logging enabled.  *Note Using log files::.
  2079.  
  2080.    * If any database table is related to the problem, include the
  2081.      output from `mysqldump --no-data db_name tbl_name1 tbl_name2 ...'.
  2082.      This is very easy to do and is a powerful way to get information
  2083.      about any table in a database that will help us create a situation
  2084.      matching the one you have.
  2085.  
  2086.    * For speed-related bugs or problems with `SELECT' statements, you
  2087.      should always include the output of `EXPLAIN SELECT ...', and at
  2088.      least the number of rows that the `SELECT' statement produces.
  2089.      The more information you give about your situation, the more
  2090.      likely it is that someone can help you!  For example, the
  2091.      following is an example of a very good bug report (it should of
  2092.      course be posted with the `mysqlbug' script):
  2093.  
  2094.      Example run using the `mysql' command line tool (note the use of
  2095.      the `\G' statement terminator for statements whose output width
  2096.      would otherwise exceed that of an 80-column display device):
  2097.  
  2098.           mysql> SHOW VARIABLES;
  2099.           mysql> SHOW COLUMNS FROM ...\G
  2100.                  <output from SHOW COLUMNS>
  2101.           mysql> EXPLAIN SELECT ...\G
  2102.                  <output from EXPLAIN>
  2103.           mysql> FLUSH STATUS;
  2104.           mysql> SELECT ...;
  2105.                  <A short version of the output from SELECT,
  2106.                  including the time taken to run the query>
  2107.           mysql> SHOW STATUS;
  2108.                  <output from SHOW STATUS>
  2109.  
  2110.    * If a bug or problem occurs while running *mysqld*, try to provide
  2111.      an input script that will reproduce the anomaly.  This script
  2112.      should include any necessary source files.  The more closely the
  2113.      script can reproduce your situation, the better.  If you can make
  2114.      a repeatable test case, you should post this to
  2115.      <bugs@lists.mysql.com> for a high priority treatment!
  2116.  
  2117.      If you can't provide a script, you should at least include the
  2118.      output from `mysqladmin variables extended-status processlist' in
  2119.      your mail to provide some information of how your system is
  2120.      performing!
  2121.  
  2122.    * If you can't produce a test case in a few rows, or if the test
  2123.      table is too big to be mailed to the mailing list (more than 10
  2124.      rows), you should dump your tables using `mysqldump' and create a
  2125.      `README' file that describes your problem.
  2126.  
  2127.      Create a compressed archive of your files using `tar' and `gzip'
  2128.      or `zip', and use `ftp' to transfer the archive to
  2129.      `ftp://support.mysql.com/pub/mysql/secret/'.  Then send a short
  2130.      description of the problem to <bugs@lists.mysql.com>.
  2131.  
  2132.    * If you think that MySQL produces a strange result from a query,
  2133.      include not only the result, but also your opinion of what the
  2134.      result should be, and an account describing the basis for your
  2135.      opinion.
  2136.  
  2137.    * When giving an example of the problem, it's better to use the
  2138.      variable names, table names, etc., that exist in your actual
  2139.      situation than to come up with new names.  The problem could be
  2140.      related to the name of a variable or table!  These cases are rare,
  2141.      perhaps, but it is better to be safe than sorry.  After all, it
  2142.      should be easier for you to provide an example that uses your
  2143.      actual situation, and it is by all means better for us.  In case
  2144.      you have data you don't want to show to others, you can use `ftp'
  2145.      to transfer it to `ftp://support.mysql.com/pub/mysql/secret/'.  If
  2146.      the data are really top secret and you don't want to show them
  2147.      even to us, then go ahead and provide an example using other
  2148.      names, but please regard this as the last choice.
  2149.  
  2150.    * Include all the options given to the relevant programs, if
  2151.      possible.  For example, indicate the options that you use when you
  2152.      start the `mysqld' daemon and that you use to run any MySQL client
  2153.      programs.  The options to programs like `mysqld' and `mysql', and
  2154.      to the `configure' script, are often keys to answers and are very
  2155.      relevant!  It is never a bad idea to include them anyway!  If you
  2156.      use any modules, such as Perl or PHP, please include the version
  2157.      number(s) of those as well.
  2158.  
  2159.    * If your question is related to the privilege system, please
  2160.      include the output of `mysqlaccess', the output of `mysqladmin
  2161.      reload', and all the error messages you get when trying to
  2162.      connect!  When you test your privileges, you should first run
  2163.      `mysqlaccess'.  After this, execute `mysqladmin reload version'
  2164.      and try to connect with the program that gives you trouble.
  2165.      `mysqlaccess' can be found in the `bin' directory under your MySQL
  2166.      installation directory.
  2167.  
  2168.    * If you have a patch for a bug, that is good, but don't assume the
  2169.      patch is all we need, or that we will use it, if you don't provide
  2170.      some necessary information, such as test cases showing the bug
  2171.      that your patch fixes.  We might find problems with your patch or
  2172.      we might not understand it at all; if so, we can't use it.
  2173.  
  2174.      If we can't verify exactly what the patch is meant for, we won't
  2175.      use it.  Test cases will help us here.  Show that the patch will
  2176.      handle all the situations that may occur.  If we find a borderline
  2177.      case (even a rare one) where the patch won't work, it may be
  2178.      useless.
  2179.  
  2180.    * Guesses about what the bug is, why it occurs, or what it depends
  2181.      on, are usually wrong.  Even the MySQL team can't guess such things
  2182.      without first using a debugger to determine the real cause of a
  2183.      bug.
  2184.  
  2185.    * Indicate in your mail message that you have checked the reference
  2186.      manual and mail archive so others know that you have tried to
  2187.      solve the problem yourself.
  2188.  
  2189.    * If you get a `parse error', please check your syntax closely!  If
  2190.      you can't find something wrong with it, it's extremely likely that
  2191.      your current version of MySQL doesn't support the query you are
  2192.      using.  If you are using the current version and the manual at
  2193.      `http://www.mysql.com/documentation/manual.php' doesn't cover the
  2194.      syntax you are using, MySQL doesn't support your query.  In this
  2195.      case, your only options are to implement the syntax yourself or
  2196.      e-mail <mysql-licensing@mysql.com> and ask for an offer to
  2197.      implement it!
  2198.  
  2199.      If the manual covers the syntax you are using, but you have an
  2200.      older version of MySQL, you should check the MySQL change history
  2201.      to see when the syntax was implemented.  In this case, you have
  2202.      the option of upgrading to a newer version of MySQL.  *Note News::.
  2203.  
  2204.    * If you have a problem such that your data appears corrupt or you
  2205.      get errors when you access some particular table, you should first
  2206.      check and then try repairing your tables with `myisamchk' or
  2207.      `CHECK TABLE' and `REPAIR TABLE'.  *Note MySQL Database
  2208.      Administration::.
  2209.  
  2210.    * If you often get corrupted tables you should try to find out when
  2211.      and why this happens!  In this case, the
  2212.      `mysql-data-directory/'hostname'.err' file may contain some
  2213.      information about what happened.  *Note Error log::.  Please
  2214.      include any relevant information from this file in your bug
  2215.      report!  Normally `mysqld' should *NEVER* crash a table if nothing
  2216.      killed it in the middle of an update!  If you can find the cause
  2217.      of `mysqld' dying, it's much easier for us to provide you with a
  2218.      fix for the problem!  *Note What is crashing::.
  2219.  
  2220.    * If possible, download and install the most recent version of MySQL
  2221.      and check whether or not it solves your problem.  All versions of
  2222.      MySQL are thoroughly tested and should work without problems!  We
  2223.      believe in making everything as backward compatible as possible,
  2224.      and you should be able to switch MySQL versions in minutes!  *Note
  2225.      Which version::.
  2226.  
  2227. If you are a support customer, please cross-post the bug report to
  2228. <mysql-support@mysql.com> for higher priority treatment, as well as to
  2229. the appropriate mailing list to see if someone else has experienced (and
  2230. perhaps solved) the problem.
  2231.  
  2232. For information on reporting bugs in *MyODBC*, see *Note ODBC
  2233. Problems::.
  2234.  
  2235. For solutions to some common problems, see *Note Problems::.
  2236.  
  2237. When answers are sent to you individually and not to the mailing list,
  2238. it is considered good etiquette to summarize the answers and send the
  2239. summary to the mailing list so that others may have the benefit of
  2240. responses you received that helped you solve your problem!
  2241.  
  2242. 
  2243. File: mysql.info,  Node: Answering questions,  Prev: Bug reports,  Up: Questions
  2244.  
  2245. Guidelines for Answering Question on the Mailing List
  2246. .....................................................
  2247.  
  2248. If you consider your answer to have broad interest, you may want to
  2249. post it to the mailing list instead of replying directly to the
  2250. individual who asked.  Try to make your answer general enough that
  2251. people other than the original poster may benefit from it.  When you
  2252. post to the list, please make sure that your answer is not a
  2253. duplication of a previous answer.
  2254.  
  2255. Try to summarize the essential part of the question in your reply;
  2256. don't feel obliged to quote the entire original message.
  2257.  
  2258. Please don't post mail messages from your browser with HTML mode turned
  2259. on!  Many users don't read mail with a browser!
  2260.  
  2261. 
  2262. File: mysql.info,  Node: Licensing and Support,  Next: Compatibility,  Prev: MySQL Information Sources,  Up: Introduction
  2263.  
  2264. MySQL Licensing and Support
  2265. ===========================
  2266.  
  2267. * Menu:
  2268.  
  2269. * Licensing policy::            MySQL licensing policy
  2270. * Copyright::                   Copyrights used by MySQL
  2271. * Licensing examples::          Example licensing situations
  2272. * Cost::                        MySQL licensing and support costs
  2273. * Support::                     Types of commercial support
  2274.  
  2275. This section describes MySQL support and licensing arrangements:
  2276.  
  2277.    * The copyrights under which MySQL is distributed (*note Copyright::)
  2278.  
  2279.    * Sample situations illustrating when a license is required (*note
  2280.      Licensing examples::)
  2281.  
  2282.    * Support costs (*note Cost::) and support benefits (*note Support::)
  2283.  
  2284.    * Commercial licensing costs
  2285.  
  2286. 
  2287. File: mysql.info,  Node: Licensing policy,  Next: Copyright,  Prev: Licensing and Support,  Up: Licensing and Support
  2288.  
  2289. MySQL Licensing Policy
  2290. ----------------------
  2291.  
  2292. The formal terms of the GPL license can be found at *Note GPL license::.
  2293. Basically, our licensing policy and interpretation of the GPL is as
  2294. follows:
  2295.  
  2296. Note that older versions of MySQL are still using a more strict license
  2297. (http://www.mysql.com/support/arrangements/mypl.html).  See the
  2298. documentation for that version for more information. If you need a
  2299. commercial MySQL license, because the GPL license doesn't suit your
  2300. application, you can buy one at `https://order.mysql.com/'.
  2301.  
  2302. For normal internal use, MySQL costs nothing.  You do not have to pay
  2303. us if you do not want to.
  2304.  
  2305. A license is required if:
  2306.  
  2307.    - You link a program, that is not free software, with code from the
  2308.      MySQL server or clients that has the GPL copyright. This happens
  2309.      for example when you use MySQL as an embedded server in your
  2310.      applications or when you add not free extensions to the MySQL
  2311.      server.  In this case your application/code would also become GPL
  2312.      through the GPL license that acts as a virus.  By licensing MySQL
  2313.      server from MySQL AB under a commercial license you will avoid
  2314.      this problem.  See `http://www.gnu.org/copyleft/gpl-faq.html'.
  2315.  
  2316.    - You have a commercial application that ONLY works with MySQL and
  2317.      ships the application with the MySQL server.  This is because we
  2318.      view this as linking even if it is done over the network.
  2319.  
  2320.    - You have a distribution of MySQL and you don't provide the source
  2321.      code for your copy of the MySQL server, as defined in the GPL
  2322.      license.
  2323.  
  2324. A license is *NOT* required if:
  2325.  
  2326.    - You do not need a license to include the client code in commercial
  2327.      programs.  The client part of MySQL licensed with the LGPL `GNU
  2328.      Library General Public License'.  The `mysql' command-line client
  2329.      includes code from the `readline' library that is under the `GPL'.
  2330.  
  2331.    - If your use of MySQL does not require a license, but you like
  2332.      MySQL and want to encourage further development, you are certainly
  2333.      welcome to purchase a license or MySQL support anyway.
  2334.  
  2335.    - If you use MySQL in a commercial context such that you profit by
  2336.      its use, we ask that you further the development of MySQL by
  2337.      purchasing some level of support.  We feel that if MySQL helps
  2338.      your business, it is reasonable to ask that you help MySQL.
  2339.      (Otherwise, if you ask us support questions, you are not only
  2340.      using for free something into which we've put a lot a work, you're
  2341.      asking us to provide free support, too.)
  2342.  
  2343. For circumstances under which a MySQL license is required, you need a
  2344. license per machine that runs the `mysqld' server.  However, a
  2345. multiple-CPU machine counts as a single machine, and there is no
  2346. restriction on the number of MySQL servers that run on one machine, or
  2347. on the number of clients concurrently connected to a server running on
  2348. that machine!
  2349.  
  2350. If you have any questions as to whether or not a license is required for
  2351. your particular use of MySQL, please read this again and then contact
  2352. us.  *Note Contact information::.
  2353.  
  2354. If you require a MySQL license, the easiest way to pay for it is to use
  2355. the license form on MySQL's secure server at
  2356. `https://order.mysql.com/'.  Other forms of payment are discussed in
  2357. *Note Payment information::.
  2358.  
  2359. 
  2360. File: mysql.info,  Node: Copyright,  Next: Licensing examples,  Prev: Licensing policy,  Up: Licensing and Support
  2361.  
  2362. Copyrights Used by MySQL
  2363. ------------------------
  2364.  
  2365. * Menu:
  2366.  
  2367. * Copyright changes::           Possible future copyright changes
  2368.  
  2369. There are several different copyrights on the MySQL distribution:
  2370.  
  2371.   1. The MySQL-specific source needed to build the `mysqlclient'
  2372.      library is licensed under the `LGPL' and programs in the `client'
  2373.      directory is GPL. Each file has a header that shows which
  2374.      copyright is used for that file.
  2375.  
  2376.   2. The client library and the (GNU `getopt') library are covered by
  2377.      the "GNU LIBRARY GENERAL PUBLIC LICENSE."  *Note LGPL license::.
  2378.  
  2379.   3. Some parts of the source (the `regexp' library) are covered by a
  2380.      Berkeley-style copyright.
  2381.  
  2382.   4. All the source in the server and the (GNU `readline') library is
  2383.      covered by the "GNU GENERAL PUBLIC LICENSE."  *Note GPL license::.
  2384.      This is also available as the file `COPYING' in the distributions.
  2385.  
  2386.  
  2387. One goal is that the SQL client library should be free enough that it is
  2388. possible to add MySQL support into commercial products without a
  2389. license.  For this reason, we chose the LGPL license for the client
  2390. code.
  2391.  
  2392. This means that you can use MySQL for free with any program that uses
  2393. any of the free software licenses.  MySQL is also free for any end user
  2394. for his own or company usage.
  2395.  
  2396. However, if you use MySQL for something important to you, you may want
  2397. to help secure its development by purchasing licenses or a support
  2398. contract.  *Note Support::.
  2399.  
  2400. 
  2401. File: mysql.info,  Node: Copyright changes,  Prev: Copyright,  Up: Copyright
  2402.  
  2403. Copyright Changes
  2404. .................
  2405.  
  2406. Version 3.22 of MySQL is still using a more strict license.  See the
  2407. documentation for that version for more information.
  2408.  
  2409. 
  2410. File: mysql.info,  Node: Licensing examples,  Next: Cost,  Prev: Copyright,  Up: Licensing and Support
  2411.  
  2412. Example Licensing Situations
  2413. ----------------------------
  2414.  
  2415. * Menu:
  2416.  
  2417. * Products that use MySQL::     Selling products that use MySQL
  2418. * ISP::                         ISP MySQL services
  2419. * Web server::                  Running a web server using MySQL.
  2420.  
  2421. This section describes some situations illustrating whether or not you
  2422. must license the MySQL server.  Generally these examples involve
  2423. providing MySQL as an integral part of a product.
  2424.  
  2425. Note that a single MySQL license covers any number of CPUs and `mysqld'
  2426. servers on a machine!  There is no artificial limit on the number of
  2427. clients that connect to the server in any way.
  2428.  
  2429. 
  2430. File: mysql.info,  Node: Products that use MySQL,  Next: ISP,  Prev: Licensing examples,  Up: Licensing examples
  2431.  
  2432. Selling Products that use MySQL
  2433. ...............................
  2434.  
  2435. To determine whether or not you need a MySQL license when selling your
  2436. application, you should ask whether the proper functioning of your
  2437. application is dependent on the use of MySQL and whether you include
  2438. the MySQL server with your product.  There are several cases to
  2439. consider:
  2440.  
  2441.    * Does your application require MySQL to function properly?
  2442.  
  2443.    * If your product requires MySQL, you need a license for any machine
  2444.      that runs the `mysqld' server.  For example, if you've designed
  2445.      your application around MySQL, then you've really made a
  2446.      commercial product that requires the engine, so you need a license.
  2447.  
  2448.    * If your application does not require MySQL, you do not need to
  2449.      obtain a license.  For example, if using MySQL just adds some new
  2450.      optional features to your product (such as adding logging to a
  2451.      database if MySQL is used rather than logging to a text file), it
  2452.      should fall within normal use, and a license would not be required.
  2453.  
  2454.    * In other words, you need a license if you sell a product designed
  2455.      specifically for use with MySQL or that requires the MySQL server
  2456.      to function at all.  This is true whether or not you provide MySQL
  2457.      for your client as part of your product distribution.
  2458.  
  2459.    * It also depends on what you're doing for the client.  Do you plan
  2460.      to provide your client with detailed instructions on installing
  2461.      MySQL with your software?  Then your product may be contingent on
  2462.      the use of MySQL; if so, you need to buy a license.  If you are
  2463.      simply tying into a database that you expect already to have been
  2464.      installed by the time your software is purchased, then you probably
  2465.      don't need a license.
  2466.  
  2467.  
  2468. 
  2469. File: mysql.info,  Node: ISP,  Next: Web server,  Prev: Products that use MySQL,  Up: Licensing examples
  2470.  
  2471. ISP MySQL Services
  2472. ..................
  2473.  
  2474. Internet Service Providers (ISPs) often host MySQL servers for their
  2475. customers.  With the GPL license this does not require a license.
  2476.  
  2477. On the other hand, we do encourage people to use ISPs that have MySQL
  2478. support, as this will give them the confidence that if they have some
  2479. problem with their MySQL installation, their ISP will be able to solve
  2480. the problem for them (in some cases with the help from the MySQL
  2481. development team).
  2482.  
  2483. All ISPs that want to keep themselves up-to-date should subscribe to
  2484. our `announce' mailing list so that they can be aware of fatal issues
  2485. that may be relevant for their MySQL installations.
  2486.  
  2487. Note that if the ISP doesn't have a license for MySQL, it should give
  2488. its customers at least read access to the source of the MySQL
  2489. installation so that its customer can verify that it is patched
  2490. correctly.
  2491.  
  2492. 
  2493. File: mysql.info,  Node: Web server,  Prev: ISP,  Up: Licensing examples
  2494.  
  2495. Running a Web Server Using MySQL
  2496. ................................
  2497.  
  2498. If you use MySQL in conjunction with a Web server on Unix, you don't
  2499. have to pay for a license.
  2500.  
  2501. This is true even if you run a commercial Web server that uses MySQL,
  2502. because you are not selling an embedded MySQL version yourself.
  2503. However, in this case we would like you to purchase MySQL support,
  2504. because MySQL is helping your enterprise.
  2505.  
  2506. 
  2507. File: mysql.info,  Node: Cost,  Next: Support,  Prev: Licensing examples,  Up: Licensing and Support
  2508.  
  2509. MySQL Licensing and Support Costs
  2510. ---------------------------------
  2511.  
  2512. * Menu:
  2513.  
  2514. * Payment information::         Payment information
  2515. * Contact information::         Contact information
  2516.  
  2517. Our current license prices are shown below. To make a purchase, please
  2518. visit `https://order.mysql.com/'.
  2519.  
  2520. If you pay by credit card, the currency is EURO (European Union Euro)
  2521. so the prices will differ slightly.
  2522.  
  2523. *Number of licenses*   *Per copy*             
  2524. 1-9                    230 EURO               
  2525. 10-24                  138 EURO               
  2526. 25-49                  117 EURO               
  2527. 50-99                  102 EURO               
  2528. 100-249                91 EURO                
  2529. 250-499                76 EURO                
  2530. 500-999                66 EURO                
  2531.  
  2532. For high volume (OEM) purchases, please contact <sales@mysql.com>.
  2533.  
  2534. For OEM purchases, you must act as the middle-man for eventual problems
  2535. or extension requests from your users.  We also require that OEM
  2536. customers have at least an extended e-mail support contract.  Note that
  2537. OEM licenses only apply for products where the user doesn't have direct
  2538. access to the MySQL server (embedded system).  In other words, the
  2539. MySQL server should only be used with the application that was supplied
  2540. you.
  2541.  
  2542. If you have a low-margin, high-volume product, you can always talk to us
  2543. about other terms (for example, a percent of the sale price).  If you
  2544. do, please be informative about your product, pricing, market, and any
  2545. other information that may be relevant.
  2546.  
  2547. A full-price license is not a support agreement and includes very
  2548. minimal support.  This means that we try to answer any relevant
  2549. questions.  If the answer is in the documentation, we will direct you
  2550. to the appropriate section.  If you have not purchased a license or
  2551. support, we probably will not answer at all.
  2552.  
  2553. If you discover what we consider a real bug, we are likely to fix it in
  2554. any case.  But if you pay for support we will notify you about the fix
  2555. status instead of just fixing it in a later release.
  2556.  
  2557. More comprehensive support is sold separately.  Descriptions of what
  2558. each level of support includes are given in *Note Support::.  Costs for
  2559. the various types of commercial support are shown below.  Support level
  2560. prices are in EURO (European Union Euro).  One EURO is about 1.06 USD.
  2561.  
  2562. *Type of support*                    *Cost per year*
  2563. Basic e-mail support. *Note Basic    EURO 200
  2564. email support::.                     
  2565. Extended e-mail support *Note        EURO 1000
  2566. Extended email support::.            
  2567. Login support *Note Login            EURO 2000
  2568. support::.                           
  2569. Extended login support *Note         EURO 5000
  2570. Extended login support::.            
  2571. Telephone support *Note Telephone    EURO 12000
  2572. support::.                           
  2573.  
  2574. You may upgrade from any lower level of support to a higher level of
  2575. support for the difference in price between the two support levels.
  2576.  
  2577. We do also provide telephone support (mostly emergency support but also
  2578. 24/7 support).  This support option doesn't however have a fixed price
  2579. but is negotiated for case to case.  If you are interested in this
  2580. option you can email <sales@mysql.com> and tell us about your needs.
  2581.  
  2582. Note that as our sales staff is very busy, it may take some time until
  2583. your request is handled.  Our support staff does however always answer
  2584. promptly to support questions!
  2585.  
  2586. 
  2587. File: mysql.info,  Node: Payment information,  Next: Contact information,  Prev: Cost,  Up: Cost
  2588.  
  2589. Payment information
  2590. ...................
  2591.  
  2592. Currently we can take SWIFT payments, checks, or credit cards.
  2593.  
  2594. Payment should be made to:
  2595.  
  2596.      Postgirot Bank AB
  2597.      105 06 STOCKHOLM, SWEDEN
  2598.      
  2599.      MySQL AB
  2600.      BOX 6434
  2601.      11382 STOCKHOLM, SWEDEN
  2602.      
  2603.      SWIFT address: PGSI SESS
  2604.      Account number: 96 77 06 - 3
  2605.  
  2606. Specify: license and/or support and your name and e-mail address.
  2607.  
  2608. In Europe and Japan you can use EuroGiro (that should be less
  2609. expensive) to the same account.
  2610.  
  2611. If you want to pay by check, make it payable to "MySQL Finland AB" and
  2612. mail it to the address below:
  2613.  
  2614.      MySQL AB
  2615.      BOX 6434, Torsgatan 21
  2616.      11382 STOCKHOLM, SWEDEN
  2617.  
  2618. If you want to pay by credit card over the Internet, you can use MySQL
  2619. AB's secure license form (https://order.mysql.com/).
  2620.  
  2621. You can also print a copy of the license form, fill it in, and send it
  2622. by fax to:
  2623.  
  2624. +46-8-729 69 05
  2625.  
  2626. If you want us to bill you, you can use the license form and write "bill
  2627. us" in the comment field.  You can also mail a message to
  2628. <sales@mysql.com> (*not* `mysql@lists.mysql.com'!)  with your company
  2629. information and ask us to bill you.
  2630.  
  2631. 
  2632. File: mysql.info,  Node: Contact information,  Prev: Payment information,  Up: Cost
  2633.  
  2634. Contact Information
  2635. ...................
  2636.  
  2637. For commercial licensing, please contact the MySQL licensing team.  The
  2638. much preferred method is by e-mail to <licensing@mysql.com>.  Fax is
  2639. also possible but handling of these may take much longer (Fax +46-8-729
  2640. 69 05).
  2641.  
  2642. If you represent a business that is interested in partnering with
  2643. MySQL, please send e-mail to <partner@mysql.com>.
  2644.  
  2645. For timely, precise answers to technical questions about MySQL you
  2646. should order (https://order.mysql.com/) one of our support contracts
  2647. (http://www.mysql.com/support/arrangements/types.html).  MySQL support
  2648. is provided by the MySQL developers so the standard is extremely high.
  2649.  
  2650. If you are interested in placing a banner advertisement on our Web site,
  2651. please send e-mail to <advertising@mysql.com>.
  2652.  
  2653. If you are interested in any of the jobs listed in our jobs
  2654. (http://www.mysql.com/development/jobs/) section, please send e-mail to
  2655. <jobs@mysql.com>.
  2656.  
  2657. For general discussion amongst our many users, please direct your
  2658. attention to the appropriate mailing list
  2659. (http://www.mysql.com/documentation/lists.html).
  2660.  
  2661. For general information inquires, please send e-mail to
  2662. <info@mysql.com>.
  2663.  
  2664. For questions or comments about the workings or content of the Web site,
  2665. please send e-mail to <webmaster@mysql.com>.
  2666.  
  2667. 
  2668. File: mysql.info,  Node: Support,  Prev: Cost,  Up: Licensing and Support
  2669.  
  2670. Types of Commercial Support
  2671. ---------------------------
  2672.  
  2673. * Menu:
  2674.  
  2675. * Basic email support::         Basic email support
  2676. * Extended email support::      Extended email support
  2677. * Login support::               Login support
  2678. * Extended login support::      Extended login support
  2679. * Telephone support::           Telephone support
  2680. * Table handler support::       Support for other table handlers
  2681.  
  2682. The following is true of all support options:
  2683.  
  2684.    * The support is per year.
  2685.  
  2686.    * We will fix, or provide a reasonable workaround for any repeatable
  2687.      bug.
  2688.  
  2689.    * We will give a reasonable effort to find and fix any other MySQL
  2690.      related bug.
  2691.  
  2692.    * The higher level of support contract the more effort we will put
  2693.      into finding a solution to your problems.
  2694.  
  2695.    * The following is true for all support contracts except Basic email
  2696.      support:
  2697.  
  2698.      For non-bug related things, like helping you optimize your queries
  2699.      or your system, extending MySQL with new functionality, etc., we
  2700.      charge 200 EURO/hour, which is deducted from your support
  2701.      contract.  In other words, if you have login support (2000 EURO),
  2702.      you can expect us to work up to 10 hours to help you with things
  2703.      like this.
  2704.  
  2705. 
  2706. File: mysql.info,  Node: Basic email support,  Next: Extended email support,  Prev: Support,  Up: Support
  2707.  
  2708. Basic E-mail Support
  2709. ....................
  2710.  
  2711. Basic e-mail support is a very inexpensive support option and should be
  2712. thought of more as a way to support our development of MySQL than as a
  2713. real support option.  We at MySQL do give a lot of free support in all
  2714. the different MySQL lists, and the money we get from basic e-mail
  2715. support is largely used to make this possible.
  2716.  
  2717. At this support level, the MySQL mailing lists are the preferred means
  2718. of communication.  Questions normally should be mailed to the primary
  2719. mailing list (<mysql@lists.mysql.com>) or one of the other regular
  2720. lists (for example, <win32@lists.mysql.com> for Windows-related MySQL
  2721. questions), as someone else already may have experienced and solved the
  2722. problem you have.  *Note Asking questions::.
  2723.  
  2724. However, by purchasing basic e-mail support, you also have access to the
  2725. support address <mysql-support@mysql.com>, which is not available as
  2726. part of the minimal support that you get by purchasing a MySQL license.
  2727. This means that for especially critical questions, you can cross-post
  2728. your message to <mysql-support@mysql.com>.  (If the message contains
  2729. sensitive data, you should post only to <mysql-support@mysql.com>.)
  2730.  
  2731. *REMEMBER!* to ALWAYS include your registration number and expiration
  2732. date when you send a message to <mysql-support@mysql.com>.
  2733.  
  2734. Note that if you have encountered a critical, repeatable bug, and follow
  2735. the rules outlined in the manual section of how to report bugs and send
  2736. it to <bugs@lists.mysql.com>, we promise to try to fix this as soon as
  2737. possible, regardless of your support level!  *Note Bug reports::.
  2738.  
  2739. Basic e-mail support includes the following types of service:
  2740.  
  2741.    * If your question is already answered in the manual, we will inform
  2742.      you of the correct section in which you can find the answer.  If
  2743.      the answer is not in the manual, we will point you in the right
  2744.      direction to solve your problem.
  2745.  
  2746.    * We guarantee a timely answer for your e-mail messages.  We can't
  2747.      guarantee that we can solve any problem, but at least you will
  2748.      receive an answer if we can contact you by e-mail.
  2749.  
  2750.    * We will help with unexpected problems when you install MySQL from a
  2751.      binary distribution on supported platforms.  This level of support
  2752.      does not cover installing MySQL from a source distribution.
  2753.      Supported platforms are those for which MySQL is known to work.
  2754.      *Note Which OS::.
  2755.  
  2756.    * We will help you with bugs and missing features.  Any bugs that
  2757.      are found are fixed for the next MySQL release.  If the bug is
  2758.      critical for you, we will mail you a patch for it as soon the bug
  2759.      is fixed.  Critical bugs always have the highest priority for us,
  2760.      and we ensure that they are fixed as soon as possible.
  2761.  
  2762.    * Your suggestions for the further development of MySQL will be
  2763.      taken into consideration.  By taking email support you have already
  2764.      helped the further development of MySQL.  If you want to have more
  2765.      input, upgrade to a higher level of support.
  2766.  
  2767.    * If you want us to help optimize your system, you must upgrade to a
  2768.      higher level of support.
  2769.  
  2770. 
  2771. File: mysql.info,  Node: Extended email support,  Next: Login support,  Prev: Basic email support,  Up: Support
  2772.  
  2773. Extended E-mail Support
  2774. .......................
  2775.  
  2776. Extended e-mail support includes everything in basic e-mail support with
  2777. these additions:
  2778.  
  2779.    * Your e-mail will be dealt with before mail from basic e-mail
  2780.      support users and non-registered users.
  2781.  
  2782.    * Your suggestions for the further development of MySQL will receive
  2783.      strong consideration.  Simple extensions that suit the basic goals
  2784.      of MySQL are implemented in a matter of days.  By taking extended
  2785.      e-mail support you have already helped the further development of
  2786.      MySQL.
  2787.  
  2788.    * Typical situations that are covered by extended e-mail support are:
  2789.  
  2790.         - We will answer and (within reason) solve questions that
  2791.           relate to possible bugs in MySQL.  As soon as the bug is
  2792.           found and corrected, we will mail a patch for it.
  2793.  
  2794.         - We will help with unexpected problems when you install MySQL
  2795.           from a source or binary distribution on supported platforms.
  2796.  
  2797.         - We will answer questions about missing features and offer
  2798.           hints how to work around them.
  2799.  
  2800.         - We will provide hints on optimizing `mysqld' for your
  2801.           situation.
  2802.  
  2803.    * You are allowed to influence the priority of items on the MySQL
  2804.      TODO List.  *Note TODO::.  This will ensure that the features you
  2805.      really need will be implemented sooner than they might be
  2806.      otherwise.
  2807.  
  2808. 
  2809. File: mysql.info,  Node: Login support,  Next: Extended login support,  Prev: Extended email support,  Up: Support
  2810.  
  2811. Login Support
  2812. .............
  2813.  
  2814. Login support includes everything in extended e-mail support with these
  2815. additions:
  2816.  
  2817.    * Your e-mail will be dealt with even before e-mail from extended
  2818.      e-mail support users.
  2819.  
  2820.    * Your suggestions for the further development of MySQL will be
  2821.      taken into very high consideration.  Realistic extensions that can
  2822.      be implemented in a couple of hours and that suit the basic goals
  2823.      of MySQL will be implemented as soon as possible.
  2824.  
  2825.    * If you have a very specific problem, we can try to log in on your
  2826.      system to solve the problem "in place."
  2827.  
  2828.    * Like any database vendor, we can't guarantee that we can rescue
  2829.      any data from crashed tables, but if the worst happens, we will
  2830.      help you rescue as much as possible.  MySQL has proven itself very
  2831.      reliable, but anything is possible due to circumstances beyond our
  2832.      control (for example, if your system crashes or someone kills the
  2833.      server by executing a `kill -9' command).
  2834.  
  2835.    * We will provide hints on optimizing your system and your queries.
  2836.  
  2837.    * You are allowed to call a MySQL developer (in moderation) and
  2838.      discuss your MySQL-related problems.  This option is however only
  2839.      to be used as a last result during an emergency after we have
  2840.      failed to grasp the total problem with email.  To make efficient
  2841.      use of our time we need to first get all facts about the problem,
  2842.      before talking on phone, to be able to work as efficiently as
  2843.      possible on solving the problem.
  2844.  
  2845. 
  2846. File: mysql.info,  Node: Extended login support,  Next: Telephone support,  Prev: Login support,  Up: Support
  2847.  
  2848. Extended Login Support
  2849. ......................
  2850.  
  2851. Extended login support includes everything in login support with these
  2852. additions:
  2853.  
  2854.    * Your e-mail has the highest possible priority.
  2855.  
  2856.    * We will actively examine your system and help you optimize it and
  2857.      your queries.  We may also optimize and/or extend MySQL to better
  2858.      suit your needs.
  2859.  
  2860.    * You may also request special extensions just for you.  For example:
  2861.           mysql> select MY_FUNC(col1,col2) from table;
  2862.  
  2863.    * We will provide a binary distribution of all important MySQL
  2864.      releases for your system, as long as we can get an account on a
  2865.      similar system.  In the worst case, we may require access to your
  2866.      system to be able to create a binary distribution.
  2867.  
  2868.    * If you can provide accommodations and pay for traveler fares, you
  2869.      can even get a MySQL developer to visit you and offer you help with
  2870.      your troubles.  Extended login support entitles you to one personal
  2871.      encounter per year, but we are always very flexible towards our
  2872.      customers!  If the visit takes 16 hours or more, the first 8 hours
  2873.      is without charge.  For the hours above 8 hours, you will be
  2874.      charged with a rate that is at least 20 % less than our standard
  2875.      rates.
  2876.  
  2877. 
  2878. File: mysql.info,  Node: Telephone support,  Next: Table handler support,  Prev: Extended login support,  Up: Support
  2879.  
  2880. Telephone Support
  2881. .................
  2882.  
  2883. Telephone support includes everything in extended login support with
  2884. these additions:
  2885.  
  2886.    * We will provide you with a dynamic web page showing the current
  2887.      list of `MySQL' developers that you can phone when you have a
  2888.      critical problem.
  2889.  
  2890.    * For non critical problem, you can request a MySQL developer to
  2891.      phone back within 48 hours to discuss `MySQL' related issues.
  2892.  
  2893. 
  2894. File: mysql.info,  Node: Table handler support,  Prev: Telephone support,  Up: Support
  2895.  
  2896. Support for other table handlers
  2897. ................................
  2898.  
  2899. To get support for `BDB' tables, `InnoDB' tables you have to pay an
  2900. additional 30% on the standard support price for each of the table
  2901. handlers you would like to have support for.
  2902.  
  2903. We at `MySQL AB' will help you create a proper bug report for the table
  2904. handler and submit it to the developers for the specific table handler.
  2905. We will also do our best to ensure that you will get a timely answer
  2906. or solution from the developers of the table handler.
  2907.  
  2908. Even if we are quite confident that we can solve most problems within a
  2909. timely manner, we can't guarantee a quick solution for any problems you
  2910. can get with the different table handlers.  We will however do our best
  2911. to help you get the problem solved.
  2912.  
  2913. 
  2914. File: mysql.info,  Node: Compatibility,  Next: Comparisons,  Prev: Licensing and Support,  Up: Introduction
  2915.  
  2916. How Standards-compatible Is MySQL?
  2917. ==================================
  2918.  
  2919. * Menu:
  2920.  
  2921. * Extensions to ANSI::          MySQL extensions to ANSI SQL92
  2922. * Differences from ANSI::       MySQL differences compared to ANSI SQL92
  2923. * ANSI mode::                   Running MySQL in ANSI mode
  2924. * Missing functions::           Functionality missing from MySQL
  2925. * Standards::                   What standards does MySQL follow?
  2926. * Commit-rollback::             How to cope without `COMMIT'-`ROLLBACK'
  2927. * Bugs::                        Known errors and design deficiencies in MySQL
  2928.  
  2929. This section describes how MySQL relates to the ANSI SQL standards.
  2930. MySQL has many extensions to the ANSI SQL standards, and here you will
  2931. find out what they are, and how to use them.  You will also find
  2932. information about functionality missing from MySQL, and how to work
  2933. around some differences.
  2934.  
  2935. 
  2936. File: mysql.info,  Node: Extensions to ANSI,  Next: Differences from ANSI,  Prev: Compatibility,  Up: Compatibility
  2937.  
  2938. MySQL Extensions to ANSI SQL92
  2939. ------------------------------
  2940.  
  2941. MySQL includes some extensions that you probably will not find in other
  2942. SQL databases.  Be warned that if you use them, your code will not be
  2943. portable to other SQL servers.  In some cases, you can write code that
  2944. includes MySQL extensions, but is still portable, by using comments of
  2945. the form `/*! ... */'.  In this case, MySQL will parse and execute the
  2946. code within the comment as it would any other MySQL statement, but
  2947. other SQL servers will ignore the extensions.  For example:
  2948.  
  2949.      SELECT /*! STRAIGHT_JOIN */ col_name FROM table1,table2 WHERE ...
  2950.  
  2951. If you add a version number after the `'!'', the syntax will only be
  2952. executed if the MySQL version is equal to or newer than the used
  2953. version number:
  2954.  
  2955.      CREATE /*!32302 TEMPORARY */ TABLE (a int);
  2956.  
  2957. The above means that if you have Version 3.23.02 or newer, then MySQL
  2958. will use the `TEMPORARY' keyword.
  2959.  
  2960. MySQL extensions are listed below:
  2961.  
  2962.    * The field types `MEDIUMINT', `SET', `ENUM', and the different
  2963.      `BLOB' and `TEXT' types.
  2964.  
  2965.    * The field attributes `AUTO_INCREMENT', `BINARY', `NULL',
  2966.      `UNSIGNED', and `ZEROFILL'.
  2967.  
  2968.    * All string comparisons are case insensitive by default, with sort
  2969.      ordering determined by the current character set (ISO-8859-1
  2970.      Latin1 by default).  If you don't like this, you should declare
  2971.      your columns with the `BINARY' attribute or use the `BINARY' cast,
  2972.      which causes comparisons to be done according to the ASCII order
  2973.      used on the MySQL server host.
  2974.  
  2975.    * MySQL maps each database to a directory under the MySQL data
  2976.      directory, and tables within a database to filenames in the
  2977.      database directory.
  2978.  
  2979.      This has a few implications:
  2980.  
  2981.         - Database names and table names are case sensitive in MySQL on
  2982.           operating systems that have case-sensitive filenames (like
  2983.           most Unix systems). *Note Name case sensitivity::.
  2984.  
  2985.         - Database, table, index, column, or alias names may begin with
  2986.           a digit (but may not consist solely of digits).
  2987.  
  2988.         - You can use standard system commands to backup, rename, move,
  2989.           delete, and copy tables.  For example, to rename a table,
  2990.           rename the `.MYD', `.MYI', and `.frm' files to which the
  2991.           table corresponds.
  2992.  
  2993.    * In SQL statements, you can access tables from different databases
  2994.      with the `db_name.tbl_name' syntax.  Some SQL servers provide the
  2995.      same functionality but call this `User space'.  MySQL doesn't
  2996.      support tablespaces as in: `create table ralph.my_table...IN
  2997.      my_tablespace'.
  2998.  
  2999.    * `LIKE' is allowed on numeric columns.
  3000.  
  3001.    * Use of `INTO OUTFILE' and `STRAIGHT_JOIN' in a `SELECT' statement.
  3002.      *Note `SELECT': SELECT.
  3003.  
  3004.    * The `SQL_SMALL_RESULT' option in a `SELECT' statement.
  3005.  
  3006.    * `EXPLAIN SELECT' to get a description on how tables are joined.
  3007.  
  3008.    * Use of index names, indexes on a prefix of a field, and use of
  3009.      `INDEX' or `KEY' in a `CREATE TABLE' statement. *Note `CREATE
  3010.      TABLE': CREATE TABLE.
  3011.  
  3012.    * Use of `TEMPORARY' or `IF NOT EXISTS' with `CREATE TABLE'.
  3013.  
  3014.    * Use of `COUNT(DISTINCT list)' where 'list' is more than one
  3015.      element.
  3016.  
  3017.    * Use of `CHANGE col_name', `DROP col_name', or `DROP INDEX',
  3018.      `IGNORE' or `RENAME' in an `ALTER TABLE' statement. *Note `ALTER
  3019.      TABLE': ALTER TABLE.
  3020.  
  3021.    * Use of `RENAME TABLE'. *Note `RENAME TABLE': RENAME TABLE.
  3022.  
  3023.    * Use of multiple `ADD', `ALTER', `DROP', or `CHANGE' clauses in an
  3024.      `ALTER TABLE' statement.
  3025.  
  3026.    * Use of `DROP TABLE' with the keywords `IF EXISTS'.
  3027.  
  3028.    * You can drop multiple tables with a single `DROP TABLE' statement.
  3029.  
  3030.    * The `LIMIT' clause of the `DELETE' statement.
  3031.  
  3032.    * The `DELAYED' clause of the `INSERT' and `REPLACE' statements.
  3033.  
  3034.    * The `LOW_PRIORITY' clause of the `INSERT', `REPLACE', `DELETE',
  3035.      and `UPDATE' statements.
  3036.  
  3037.    * Use of `LOAD DATA INFILE'. In many cases, this syntax is
  3038.      compatible with Oracle's `LOAD DATA INFILE'. *Note `LOAD DATA':
  3039.      LOAD DATA.
  3040.  
  3041.    * The `ANALYZE TABLE', `CHECK TABLE', `OPTIMIZE TABLE', and `REPAIR
  3042.      TABLE' statements.
  3043.  
  3044.    * The `SHOW' statement.  *Note `SHOW': SHOW.
  3045.  
  3046.    * Strings may be enclosed by either `"' or `'', not just by `''.
  3047.  
  3048.    * Use of the escape `\' character.
  3049.  
  3050.    * The `SET OPTION' statement. *Note `SET OPTION': SET OPTION.
  3051.  
  3052.    * You don't need to name all selected columns in the `GROUP BY' part.
  3053.      This gives better performance for some very specific, but quite
  3054.      normal queries.  *Note Group by functions::.
  3055.  
  3056.    * One can specify `ASC' and `DESC' with `GROUP BY'.
  3057.  
  3058.    * To make it easier for users who come from other SQL environments,
  3059.      MySQL supports aliases for many functions. For example, all string
  3060.      functions support both ANSI SQL syntax and ODBC syntax.
  3061.  
  3062.    * MySQL understands the `||' and `&&' operators to mean logical OR
  3063.      and AND, as in the C programming language.  In MySQL, `||' and
  3064.      `OR' are synonyms, as are `&&' and `AND'.  Because of this nice
  3065.      syntax, MySQL doesn't support the ANSI SQL `||' operator for
  3066.      string concatenation; use `CONCAT()' instead. Because `CONCAT()'
  3067.      takes any number of arguments, it's easy to convert use of the
  3068.      `||' operator to MySQL.
  3069.  
  3070.    * `CREATE DATABASE' or `DROP DATABASE'.  *Note `CREATE DATABASE':
  3071.      CREATE DATABASE.
  3072.  
  3073.    * The `%' operator is a synonym for `MOD()'.  That is, `N % M' is
  3074.      equivalent to `MOD(N,M)'.  `%' is supported for C programmers and
  3075.      for compatibility with PostgreSQL.
  3076.  
  3077.    * The `=', `<>', `<=' ,`<', `>=',`>', `<<', `>>', `<=>', `AND',
  3078.      `OR', or `LIKE' operators may be used in column comparisons to the
  3079.      left of the `FROM' in `SELECT' statements.  For example:
  3080.  
  3081.           mysql> SELECT col1=1 AND col2=2 FROM tbl_name;
  3082.  
  3083.    * The `LAST_INSERT_ID()' function.  *Note `mysql_insert_id()':
  3084.      mysql_insert_id.
  3085.  
  3086.    * The `REGEXP' and `NOT REGEXP' extended regular expression
  3087.      operators.
  3088.  
  3089.    * `CONCAT()' or `CHAR()' with one argument or more than two
  3090.      arguments.  (In MySQL, these functions can take any number of
  3091.      arguments.)
  3092.  
  3093.    * The `BIT_COUNT()', `CASE', `ELT()', `FROM_DAYS()', `FORMAT()',
  3094.      `IF()', `PASSWORD()', `ENCRYPT()', `md5()', `ENCODE()', `DECODE()',
  3095.      `PERIOD_ADD()', `PERIOD_DIFF()', `TO_DAYS()', or `WEEKDAY()'
  3096.      functions.
  3097.  
  3098.    * Use of `TRIM()' to trim substrings. ANSI SQL only supports removal
  3099.      of single characters.
  3100.  
  3101.    * The `GROUP BY' functions `STD()', `BIT_OR()', and `BIT_AND()'.
  3102.  
  3103.    * Use of `REPLACE' instead of `DELETE' + `INSERT'.  *Note `REPLACE':
  3104.      REPLACE.
  3105.  
  3106.    * The `FLUSH', `RESET' and `DO' statements.
  3107.  
  3108.    * The possibility to set variables in a statement with `:=':
  3109.           SELECT @a:=SUM(total),@b=COUNT(*),@a/@b AS avg FROM test_table;
  3110.           SELECT @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
  3111.  
  3112.  
  3113. 
  3114. File: mysql.info,  Node: Differences from ANSI,  Next: ANSI mode,  Prev: Extensions to ANSI,  Up: Compatibility
  3115.  
  3116. MySQL Differences Compared to ANSI SQL92
  3117. ----------------------------------------
  3118.  
  3119. We try to make MySQL follow the ANSI SQL standard and the ODBC SQL
  3120. standard, but in some cases MySQL does some things differently:
  3121.  
  3122.    * `--' is only a comment if followed by a white space. *Note Missing
  3123.      comments::.
  3124.  
  3125.    * For `VARCHAR' columns, trailing spaces are removed when the value
  3126.      is stored. *Note Bugs::.
  3127.  
  3128.    * In some cases, `CHAR' columns are silently changed to `VARCHAR'
  3129.      columns. *Note Silent column changes::.
  3130.  
  3131.    * Privileges for a table are not automatically revoked when you
  3132.      delete a table. You must explicitly issue a `REVOKE' to revoke
  3133.      privileges for a table. *Note `GRANT': GRANT.
  3134.  
  3135.    * `NULL AND FALSE' will evaluate to `NULL' and not to `FALSE'.  This
  3136.      is because we don't think it's good to have to evaluate a lot of
  3137.      extra conditions in this case.
  3138.  
  3139. 
  3140. File: mysql.info,  Node: ANSI mode,  Next: Missing functions,  Prev: Differences from ANSI,  Up: Compatibility
  3141.  
  3142. Running MySQL in ANSI Mode
  3143. --------------------------
  3144.  
  3145. If you start `mysqld' with the `--ansi' option, the following behavior
  3146. of MySQL changes:
  3147.  
  3148.    * `||' is string concatenation instead of `OR'.
  3149.  
  3150.    * You can have any number of spaces between a function name and the
  3151.      `('.  This forces all function names to be treated as reserved
  3152.      words.
  3153.  
  3154.    * `"' will be an identifier quote character (like the MySQL ``'
  3155.      quote character) and not a string quote character.
  3156.  
  3157.    * `REAL' will be a synonym for `FLOAT' instead of a synonym of
  3158.      `DOUBLE'.
  3159.  
  3160.    * The default transaction isolation level is `SERIALIZABLE'.  *Note
  3161.      SET TRANSACTION::.
  3162.  
  3163. This is the same as using
  3164. `--sql-mode=REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,SERIALIZE,ONLY_FULL_GROUP_BY'.
  3165.  
  3166. 
  3167. File: mysql.info,  Node: Missing functions,  Next: Standards,  Prev: ANSI mode,  Up: Compatibility
  3168.  
  3169. Functionality Missing from MySQL
  3170. --------------------------------
  3171.  
  3172. The following functionality is missing in the current version of MySQL.
  3173. For a prioritized list indicating when new extensions may be added to
  3174. MySQL, you should consult the online MySQL TODO list
  3175. (http://www.mysql.com/documentation/manual.php?section=TODO). That is
  3176. the latest version of the TODO list in this manual. *Note TODO::.
  3177.  
  3178. * Menu:
  3179.  
  3180. * Missing Sub-selects::         Sub-selects
  3181. * Missing SELECT INTO TABLE::   `SELECT INTO TABLE'
  3182. * Missing Transactions::        Transactions
  3183. * Missing Triggers::            Triggers
  3184. * Missing Foreign Keys::        Foreign Keys
  3185. * Broken Foreign KEY::          Reasons NOT to Use Foreign Keys constraints
  3186. * Missing Views::               Views
  3187. * Missing comments::            `--' as the start of a comment
  3188.  
  3189. 
  3190. File: mysql.info,  Node: Missing Sub-selects,  Next: Missing SELECT INTO TABLE,  Prev: Missing functions,  Up: Missing functions
  3191.  
  3192. Sub-selects
  3193. ...........
  3194.  
  3195. MySQL currently only supports sub selects of the form `INSERT ...
  3196. SELECT ...' and `REPLACE ... SELECT ...'. You can however use the
  3197. function `IN()' in other contexts.
  3198.  
  3199. In many cases you can rewrite the query without a sub-select:
  3200.  
  3201.      SELECT * FROM table1 WHERE id IN (SELECT id FROM table2);
  3202.  
  3203. This can be re-written as:
  3204.  
  3205.      SELECT table1.* FROM table1,table2 WHERE table1.id=table2.id;
  3206.  
  3207. The queries:
  3208.      SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM table2);
  3209.      SELECT * FROM table1 WHERE NOT EXISTS (SELECT id FROM table2 where table1.id=table2.id);
  3210.  
  3211. Can be rewritten as:
  3212.  
  3213.      SELECT table1.* FROM table1 LEFT JOIN table2 ON table1.id=table2.id where table2.id IS NULL
  3214.  
  3215. For more complicated subqueries you can often create temporary tables
  3216. to hold the subquery.  In some cases, however this option will not
  3217. work. The most frequently encountered of these cases arises with
  3218. `DELETE' statements, for which standard SQL does not support joins
  3219. (except in sub-selects).  For this situation there are two options
  3220. available until subqueries are supported by MySQL.
  3221.  
  3222. The first option is to use a procedural programming language (such as
  3223. Perl or PHP) to submit a `SELECT' query to obtain the primary keys for
  3224. the records to be deleted, and then use these values to construct the
  3225. `DELETE' statement (`DELETE FROM ... WHERE ... IN (key1, key2, ...)').
  3226.  
  3227. The second option is to use interactive SQL to contruct a set of
  3228. `DELETE' statements automatically, using the MySQL extension `CONCAT()'
  3229. (in lieu of the standard `||' operator).  For example:
  3230.  
  3231.      SELECT CONCAT('DELETE FROM tab1 WHERE pkid = ', tab1.pkid, ';')
  3232.        FROM tab1, tab2
  3233.       WHERE tab1.col1 = tab2.col2;
  3234.  
  3235. You can place this query in a script file and redirect input from it to
  3236. the `mysql' command-line interpreter, piping its output back to a
  3237. second instance of the interpreter:
  3238.  
  3239.      prompt> mysql --skip-column-names mydb < myscript.sql | mysql mydb
  3240.  
  3241. MySQL 4.0 supports multi-table deletes that can be used to efficiently
  3242. delete rows based on information from one table or even from many tables
  3243. at the same time.
  3244.  
  3245. 
  3246. File: mysql.info,  Node: Missing SELECT INTO TABLE,  Next: Missing Transactions,  Prev: Missing Sub-selects,  Up: Missing functions
  3247.  
  3248. `SELECT INTO TABLE'
  3249. ...................
  3250.  
  3251. MySQL doesn't yet support the Oracle SQL extension: `SELECT ... INTO
  3252. TABLE ...'.  MySQL supports instead the ANSI SQL syntax `INSERT INTO
  3253. ... SELECT ...', which is basically the same thing. *Note INSERT
  3254. SELECT::.
  3255.  
  3256.      INSERT INTO tblTemp2 (fldID) SELECT tblTemp1.fldOrder_ID FROM tblTemp1 WHERE
  3257.      tblTemp1.fldOrder_ID > 100;
  3258.  
  3259. Alternatively, you can use `SELECT INTO OUTFILE...' or `CREATE TABLE
  3260. ... SELECT' to solve your problem.
  3261.  
  3262. 
  3263. File: mysql.info,  Node: Missing Transactions,  Next: Missing Triggers,  Prev: Missing SELECT INTO TABLE,  Up: Missing functions
  3264.  
  3265. Transactions
  3266. ............
  3267.  
  3268. As MySQL does nowadays support transactions, the following discussion
  3269. is only valid if you are only using the non-transaction-safe table
  3270. types. *Note COMMIT::.
  3271.  
  3272. The question is often asked, by the curious and the critical, "Why is
  3273. MySQL not a transactional database?" or "Why does MySQL not support
  3274. transactions?"
  3275.  
  3276. MySQL has made a conscious decision to support another paradigm for
  3277. data integrity, "atomic operations." It is our thinking and experience
  3278. that atomic operations offer equal or even better integrity with much
  3279. better performance. We, nonetheless, appreciate and understand the
  3280. transactional database paradigm and plan, within the next few releases,
  3281. to introduce transaction-safe tables on a per table basis. We will be
  3282. giving our users the possibility to decide if they need the speed of
  3283. atomic operations or if they need to use transactional features in their
  3284. applications.
  3285.  
  3286. How does one use the features of MySQL to maintain rigorous integrity
  3287. and how do these features compare with the transactional paradigm?
  3288.  
  3289. First, in the transactional paradigm, if your applications are written
  3290. in a way that is dependent on the calling of "rollback" instead of
  3291. "commit" in critical situations, then transactions are more convenient.
  3292. Moreover, transactions ensure that unfinished updates or corrupting
  3293. activities are not committed to the database; the server is given the
  3294. opportunity to do an automatic rollback and your database is saved.
  3295.  
  3296. MySQL, in almost all cases, allows you to solve for potential problems
  3297. by including simple checks before updates and by running simple scripts
  3298. that check the databases for inconsistencies and automatically repair
  3299. or warn if such occurs. Note that just by using the MySQL log or even
  3300. adding one extra log, one can normally fix tables perfectly with no
  3301. data integrity loss.
  3302.  
  3303. Moreover, fatal transactional updates can be rewritten to be atomic. In
  3304. fact,we will go so far as to say that all integrity problems that
  3305. transactions solve can be done with `LOCK TABLES' or atomic updates,
  3306. ensuring that you never will get an automatic abort from the database,
  3307. which is a common problem with transactional databases.
  3308.  
  3309. Not even transactions can prevent all loss if the server goes down.  In
  3310. such cases even a transactional system can lose data.  The difference
  3311. between different systems lies in just how small the time-lap is where
  3312. they could lose data. No system is 100% secure, only "secure enough."
  3313. Even Oracle, reputed to be the safest of transactional databases, is
  3314. reported to sometimes lose data in such situations.
  3315.  
  3316. To be safe with MySQL, you only need to have backups and have the
  3317. update logging turned on.  With this you can recover from any situation
  3318. that you could with any transactional database.  It is, of course,
  3319. always good to have backups, independent of which database you use.
  3320.  
  3321. The transactional paradigm has its benefits and its drawbacks. Many
  3322. users and application developers depend on the ease with which they can
  3323. code around problems where an abort appears to be, or is necessary, and
  3324. they may have to do a little more work with MySQL to either think
  3325. differently or write more. If you are new to the atomic operations
  3326. paradigm, or more familiar or more comfortable with transactions, do not
  3327. jump to the conclusion that MySQL has not addressed these issues.
  3328. Reliability and integrity are foremost in our minds.  Recent estimates
  3329. indicate that there are more than 1,000,000 `mysqld' servers currently
  3330. running, many of which are in production environments.  We hear very,
  3331. very seldom from our users that they have lost any data, and in almost
  3332. all of those cases user error is involved. This is, in our opinion, the
  3333. best proof of MySQL's stability and reliability.
  3334.  
  3335. Lastly, in situations where integrity is of highest importance, MySQL's
  3336. current features allow for transaction-level or better reliability and
  3337. integrity. If you lock tables with `LOCK TABLES', all updates will
  3338. stall until any integrity checks are made.  If you only obtain a read
  3339. lock (as opposed to a write lock), then reads and inserts are still
  3340. allowed to happen.  The new inserted records will not be seen by any of
  3341. the clients that have a `READ' lock until they release their read
  3342. locks.  With `INSERT DELAYED' you can queue inserts into a local queue,
  3343. until the locks are released, without having the client wait for the
  3344. insert to complete. *Note INSERT DELAYED::.
  3345.  
  3346. "Atomic," in the sense that we mean it, is nothing magical. It only
  3347. means that you can be sure that while each specific update is running,
  3348. no other user can interfere with it, and there will never be an
  3349. automatic rollback (which can happen on transaction based systems if
  3350. you are not very careful).  MySQL also guarantees that there will not be
  3351. any dirty reads.  You can find some example of how to write atomic
  3352. updates in the commit-rollback section. *Note Commit-rollback::.
  3353.  
  3354. We have thought quite a bit about integrity and performance, and we
  3355. believe that our atomic operations paradigm allows for both high
  3356. reliability and extremely high performance, on the order of three to
  3357. five times the speed of the fastest and most optimally tuned of
  3358. transactional databases. We didn't leave out transactions because they
  3359. are hard to do. The main reason we went with atomic operations as
  3360. opposed to transactions is that by doing this we could apply many speed
  3361. optimizations that would not otherwise have been possible.
  3362.  
  3363. Many of our users who have speed foremost in their minds are not at all
  3364. concerned about transactions. For them transactions are not an issue.
  3365. For those of our users who are concerned with or have wondered about
  3366. transactions vis-a-vis MySQL, there is a "MySQL way" as we have
  3367. outlined above.  For those where safety is more important than speed,
  3368. we recommend them to use the `BDB', or `InnoDB' tables for all their
  3369. critical data. *Note Table types::.
  3370.  
  3371. One final note: We are currently working on a safe replication schema
  3372. that we believe to be better than any commercial replication system we
  3373. know of. This system will work most reliably under the atomic
  3374. operations, non-transactional, paradigm. Stay tuned.
  3375.  
  3376. 
  3377. File: mysql.info,  Node: Missing Triggers,  Next: Missing Foreign Keys,  Prev: Missing Transactions,  Up: Missing functions
  3378.  
  3379. Stored Procedures and Triggers
  3380. ..............................
  3381.  
  3382. A stored procedure is a set of SQL commands that can be compiled and
  3383. stored in the server. Once this has been done, clients don't need to
  3384. keep reissuing the entire query but can refer to the stored procedure.
  3385. This provides better performance because the query has to be parsed
  3386. only once, and less information needs to be sent between the server and
  3387. the client. You can also raise the conceptual level by having libraries
  3388. of functions in the server.
  3389.  
  3390. A trigger is a stored procedure that is invoked when a particular event
  3391. occurs.  For example, you can install a stored procedure that is
  3392. triggered each time a record is deleted from a transaction table and
  3393. that automatically deletes the corresponding customer from a customer
  3394. table when all his transactions are deleted.
  3395.  
  3396. The planned update language will be able to handle stored procedures,
  3397. but without triggers. Triggers usually slow down everything, even
  3398. queries for which they are not needed.
  3399.  
  3400. To see when MySQL might get stored procedures, see *Note TODO::.
  3401.  
  3402. 
  3403. File: mysql.info,  Node: Missing Foreign Keys,  Next: Broken Foreign KEY,  Prev: Missing Triggers,  Up: Missing functions
  3404.  
  3405. Foreign Keys
  3406. ............
  3407.  
  3408. Note that foreign keys in SQL are not used to join tables, but are used
  3409. mostly for checking referential integrity (foreign key constraints).  If
  3410. you want to get results from multiple tables from a `SELECT' statement,
  3411. you do this by joining tables:
  3412.  
  3413.      SELECT * from table1,table2 where table1.id = table2.id;
  3414.  
  3415. *Note `JOIN': JOIN. *Note example-Foreign keys::.
  3416.  
  3417. The `FOREIGN KEY' syntax in MySQL exists only for compatibility with
  3418. other SQL vendors' `CREATE TABLE' commands; it doesn't do anything.
  3419. The `FOREIGN KEY' syntax without `ON DELETE ...' is mostly used for
  3420. documentation purposes. Some ODBC applications may use this to produce
  3421. automatic `WHERE' clauses, but this is usually easy to override.
  3422. `FOREIGN KEY' is sometimes used as a constraint check, but this check
  3423. is unnecessary in practice if rows are inserted into the tables in the
  3424. right order. MySQL only supports these clauses because some
  3425. applications require them to exist (regardless of whether or not they
  3426. work).
  3427.  
  3428. In MySQL, you can work around the problem of `ON DELETE ...' not being
  3429. implemented by adding the appropriate `DELETE' statement to an
  3430. application when you delete records from a table that has a foreign key.
  3431. In practice this is as quick (in some cases quicker) and much more
  3432. portable than using foreign keys.
  3433.  
  3434. In the near future we will extend the `FOREIGN KEY' implementation so
  3435. that at least the information will be saved in the table specification
  3436. file and may be retrieved by `mysqldump' and ODBC. At a later stage we
  3437. will implement the foreign key constraints for application that can't
  3438. easily be coded to avoid them.
  3439.  
  3440. * Menu:
  3441.  
  3442. * Broken Foreign KEY::          Reasons NOT to use foreign keys constraints
  3443.  
  3444. 
  3445. File: mysql.info,  Node: Broken Foreign KEY,  Next: Missing Views,  Prev: Missing Foreign Keys,  Up: Missing functions
  3446.  
  3447. Reasons NOT to Use Foreign Keys constraints
  3448. ...........................................
  3449.  
  3450. There are so many problems with foreign key constraints that we don't
  3451. know where to start:
  3452.  
  3453.    * Foreign key constraints make life very complicated, because the
  3454.      foreign key definitions must be stored in a database and
  3455.      implementing them would destroy the whole "nice approach" of using
  3456.      files that can be moved, copied, and removed.
  3457.  
  3458.    * The speed impact is terrible for `INSERT' and `UPDATE' statements,
  3459.      and in this case almost all `FOREIGN KEY' constraint checks are
  3460.      useless because you usually insert records in the right tables in
  3461.      the right order, anyway.
  3462.  
  3463.    * There is also a need to hold locks on many more tables when
  3464.      updating one table, because the side effects can cascade through
  3465.      the entire database. It's MUCH faster to delete records from one
  3466.      table first and subsequently delete them from the other tables.
  3467.  
  3468.    * You can no longer restore a table by doing a full delete from the
  3469.      table and then restoring all records (from a new source or from a
  3470.      backup).
  3471.  
  3472.    * If you use foreign key constraints you can't dump and restore
  3473.      tables unless you do so in a very specific order.
  3474.  
  3475.    * It's very easy to do "allowed" circular definitions that make the
  3476.      tables impossible to re-create each table with a single create
  3477.      statement, even if the definition works and is usable.
  3478.  
  3479.    * It's very easy to overlook `FOREIGN KEY ... ON DELETE' rules when
  3480.      one codes an application. It's not unusual that one loses a lot of
  3481.      important information just because a wrong or misused `ON DELETE'
  3482.      rule.
  3483.  
  3484. The only nice aspect of `FOREIGN KEY' is that it gives ODBC and some
  3485. other client programs the ability to see how a table is connected and
  3486. to use this to show connection diagrams and to help in building
  3487. applications.
  3488.  
  3489. MySQL will soon store `FOREIGN KEY' definitions so that a client can
  3490. ask for and receive an answer about how the original connection was
  3491. made. The current `.frm' file format does not have any place for it.
  3492. At a later stage we will implement the foreign key constraints for
  3493. application that can't easily be coded to avoid them.
  3494.  
  3495. 
  3496. File: mysql.info,  Node: Missing Views,  Next: Missing comments,  Prev: Broken Foreign KEY,  Up: Missing functions
  3497.  
  3498. Views
  3499. .....
  3500.  
  3501. MySQL doesn't yet support views, but we plan to implement these to
  3502. about 4.1.
  3503.  
  3504. Views are mostly useful for letting users access a set of relations as
  3505. one table (in read-only mode).  Many SQL databases don't allow one to
  3506. update any rows in a view, but you have to do the updates in the
  3507. separate tables.
  3508.  
  3509. As MySQL is mostly used in applications and on web system where the
  3510. application writer has full control on the database usage, most of our
  3511. users haven't regarded views to be very important. (At least no one has
  3512. been interested enough in this to be prepared to finance the
  3513. implementation of views).
  3514.  
  3515. One doesn't need views in MySQL to restrict access to columns as MySQL
  3516. has a very sophisticated privilege system. *Note Privilege system::.
  3517.  
  3518. 
  3519. File: mysql.info,  Node: Missing comments,  Prev: Missing Views,  Up: Missing functions
  3520.  
  3521. `--' as the Start of a Comment
  3522. ..............................
  3523.  
  3524. Some other SQL databases use `--' to start comments. MySQL has `#' as
  3525. the start comment character, even if the `mysql' command-line tool
  3526. removes all lines that start with `--'.  You can also use the C comment
  3527. style `/* this is a comment */' with MySQL.  *Note Comments::.
  3528.  
  3529. MySQL Version 3.23.3 and above supports the `--' comment style only if
  3530. the comment is followed by a space.  This is because this degenerate
  3531. comment style has caused many problems with automatically generated SQL
  3532. queries that have used something like the following code, where we
  3533. automatically insert the value of the payment for `!payment!':
  3534.  
  3535.      UPDATE tbl_name SET credit=credit-!payment!
  3536.  
  3537. What do you think will happen when the value of `payment' is negative?
  3538.  
  3539. Because `1--1' is legal in SQL, we think it is terrible that `--' means
  3540. start comment.
  3541.  
  3542. In MySQL Version 3.23 you can, however, use: `1-- This is a comment'
  3543.  
  3544. The following discussion only concerns you if you are running a MySQL
  3545. version earlier than Version 3.23:
  3546.  
  3547. If you have a SQL program in a text file that contains `--' comments
  3548. you should use:
  3549.  
  3550.      shell> replace " --" " #" < text-file-with-funny-comments.sql \
  3551.               | mysql database
  3552.  
  3553. instead of the usual:
  3554.  
  3555.      shell> mysql database < text-file-with-funny-comments.sql
  3556.  
  3557. You can also edit the command file "in place" to change the `--'
  3558. comments to `#' comments:
  3559.  
  3560.      shell> replace " --" " #" -- text-file-with-funny-comments.sql
  3561.  
  3562. Change them back with this command:
  3563.  
  3564.      shell> replace " #" " --" -- text-file-with-funny-comments.sql
  3565.  
  3566. 
  3567. File: mysql.info,  Node: Standards,  Next: Commit-rollback,  Prev: Missing functions,  Up: Compatibility
  3568.  
  3569. What Standards Does MySQL Follow?
  3570. ---------------------------------
  3571.  
  3572. Entry level SQL92. ODBC levels 0-2.
  3573.  
  3574. 
  3575. File: mysql.info,  Node: Commit-rollback,  Next: Bugs,  Prev: Standards,  Up: Compatibility
  3576.  
  3577. How to Cope Without `COMMIT'/`ROLLBACK'
  3578. ---------------------------------------
  3579.  
  3580. The following mostly applies only for `ISAM', `MyISAM', and `HEAP'
  3581. tables. If you only use transaction-safe tables (`BDB', or `InnoDB'
  3582. tables) in an an update, you can do `COMMIT' and `ROLLBACK' also with
  3583. MySQL.  *Note COMMIT::.
  3584.  
  3585. The problem with handling `COMMIT'-`ROLLBACK' efficiently with the
  3586. above table types would require a completely different table layout
  3587. than MySQL uses today.  The table type would also need extra threads
  3588. that do automatic cleanups on the tables, and the disk usage would be
  3589. much higher. This would make these table types about 2-4 times slower
  3590. than they are today.
  3591.  
  3592. For the moment, we prefer implementing the SQL server language
  3593. (something like stored procedures). With this you would very seldom
  3594. really need `COMMIT'-`ROLLBACK.' This would also give much better
  3595. performance.
  3596.  
  3597. Loops that need transactions normally can be coded with the help of
  3598. `LOCK TABLES', and you don't need cursors when you can update records
  3599. on the fly.
  3600.  
  3601. We at TcX had a greater need for a real fast database than a 100%
  3602. general database. Whenever we find a way to implement these features
  3603. without any speed loss, we will probably do it. For the moment, there
  3604. are many more important things to do. Check the TODO for how we
  3605. prioritize things at the moment. (Customers with higher levels of
  3606. support can alter this, so things may be reprioritized.)
  3607.  
  3608. The current problem is actually `ROLLBACK'. Without `ROLLBACK', you can
  3609. do any kind of `COMMIT' action with `LOCK TABLES'. To support
  3610. `ROLLBACK' with the above table types, MySQL would have to be changed
  3611. to store all old records that were updated and revert everything back
  3612. to the starting point if `ROLLBACK' was issued. For simple cases, this
  3613. isn't that hard to do (the current `isamlog' could be used for this
  3614. purpose), but it would be much more difficult to implement `ROLLBACK'
  3615. for `ALTER/DROP/CREATE TABLE'.
  3616.  
  3617. To avoid using `ROLLBACK', you can use the following strategy:
  3618.  
  3619.   1. Use `LOCK TABLES ...' to lock all the tables you want to access.
  3620.  
  3621.   2. Test conditions.
  3622.  
  3623.   3. Update if everything is okay.
  3624.  
  3625.   4. Use `UNLOCK TABLES' to release your locks.
  3626.  
  3627. This is usually a much faster method than using transactions with
  3628. possible `ROLLBACK's, although not always. The only situation this
  3629. solution doesn't handle is when someone kills the threads in the middle
  3630. of an update. In this case, all locks will be released but some of the
  3631. updates may not have been executed.
  3632.  
  3633. You can also use functions to update records in a single operation.
  3634. You can get a very efficient application by using the following
  3635. techniques:
  3636.  
  3637.    * Modify fields relative to their current value.
  3638.  
  3639.    * Update only those fields that actually have changed.
  3640.  
  3641. For example, when we are doing updates to some customer information, we
  3642. update only the customer data that has changed and test only that none
  3643. of the changed data, or data that depend on the changed data, has
  3644. changed compared to the original row. The test for changed data is done
  3645. with the `WHERE' clause in the `UPDATE' statement. If the record wasn't
  3646. updated, we give the client a message: "Some of the data you have
  3647. changed have been changed by another user". Then we show the old row
  3648. versus the new row in a window, so the user can decide which version of
  3649. the customer record he should use.
  3650.  
  3651. This gives us something that is similar to column locking but is
  3652. actually even better, because we only update some of the columns, using
  3653. values that are relative to their current values.  This means that
  3654. typical `UPDATE' statements look something like these:
  3655.  
  3656.      UPDATE tablename SET pay_back=pay_back+'relative change';
  3657.      
  3658.      UPDATE customer
  3659.        SET
  3660.          customer_date='current_date',
  3661.          address='new address',
  3662.          phone='new phone',
  3663.          money_he_owes_us=money_he_owes_us+'new_money'
  3664.        WHERE
  3665.          customer_id=id AND address='old address' AND phone='old phone';
  3666.  
  3667. As you can see, this is very efficient and works even if another client
  3668. has changed the values in the `pay_back' or `money_he_owes_us' columns.
  3669.  
  3670. In many cases, users have wanted `ROLLBACK' and/or `LOCK TABLES' for
  3671. the purpose of managing unique identifiers for some tables. This can be
  3672. handled much more efficiently by using an `AUTO_INCREMENT' column and
  3673. either the SQL function `LAST_INSERT_ID()' or the C API function
  3674. `mysql_insert_id()'. *Note `mysql_insert_id()': mysql_insert_id.
  3675.  
  3676. At MySQL AB, we have never had any need for row-level locking because
  3677. we have always been able to code around it. Some cases really need row
  3678. locking, but they are very few. If you want row-level locking, you can
  3679. use a flag column in the table and do something like this:
  3680.  
  3681.      UPDATE tbl_name SET row_flag=1 WHERE id=ID;
  3682.  
  3683. MySQL returns 1 for the number of affected rows if the row was found
  3684. and `row_flag' wasn't already 1 in the original row.
  3685.  
  3686. You can think of it as MySQL changed the above query to:
  3687.  
  3688.      UPDATE tbl_name SET row_flag=1 WHERE id=ID and row_flag <> 1;
  3689.  
  3690. 
  3691. File: mysql.info,  Node: Bugs,  Prev: Commit-rollback,  Up: Compatibility
  3692.  
  3693. Known errors and design deficiencies in MySQL
  3694. ---------------------------------------------
  3695.  
  3696. The following problems are known and have a very high priority to get
  3697. fixed:
  3698.  
  3699.    * `ANALYZE TABLE' on a BDB table may in some case make the table
  3700.      unusable until one has restarted `mysqld'.  When this happens you
  3701.      will see errors like the following in the MySQL error file:
  3702.  
  3703.           001207 22:07:56  bdb:  log_flush: LSN past current end-of-log
  3704.  
  3705.    * Don't execute `ALTER TABLE' on a `BDB' table on which you are
  3706.      running not completed multi-statement transactions. (The
  3707.      transaction will probably be ignored).
  3708.  
  3709.    * `ANALYZE TABLE', `OPTIMIZE TABLE' and `REPAIR TABLE' may cause
  3710.      problems on tables for which you are using `INSERT DELAYED'.
  3711.  
  3712.    * Doing a `LOCK TABLE ..' and `FLUSH TABLES ..' doesn't guarantee
  3713.      that there isn't a half-finished transaction in progress on the
  3714.      table.
  3715.  
  3716.    * BDB tables are a bit slow to open. If you have many BDB tables in a
  3717.      database, it will take a long time to use the `mysql' client on the
  3718.      database if you are not using the `-A' option or if you are using
  3719.      `rehash'. This is especially notable when you have a big table
  3720.      cache.
  3721.  
  3722.    * Th current replication protocol cannot deal with `LOAD DATA INFILE'
  3723.      and line terminator characters of more than 1 character.
  3724.  
  3725. The following problems are known and will be fixed in due time:
  3726.  
  3727.    * For the moment `MATCH' only works with `SELECT' statements.
  3728.  
  3729.    * When using `SET CHARACTER SET', one can't use translated
  3730.      characters in database, table and column names.
  3731.  
  3732.    * `DELETE FROM merge_table' used without a `WHERE' will only clear
  3733.      the mapping for the table, not delete everything in the mapped
  3734.      tables
  3735.  
  3736.    * You cannot build in another directory when using MIT-pthreads.
  3737.      Because this requires changes to MIT-pthreads, we are not likely
  3738.      to fix this.
  3739.  
  3740.    * `BLOB' values can't "reliably" be used in `GROUP BY' or `ORDER BY'
  3741.      or `DISTINCT'. Only the first `max_sort_length' bytes (default
  3742.      1024) are used when comparing `BLOB'bs in these cases.  This can
  3743.      be changed with the `-O max_sort_length' option to `mysqld'. A
  3744.      workaround for most cases is to use a substring: `SELECT DISTINCT
  3745.      LEFT(blob,2048) FROM tbl_name'.
  3746.  
  3747.    * Calculation is done with `BIGINT' or `DOUBLE' (both are normally
  3748.      64 bits long). It depends on the function which precision one
  3749.      gets. The general rule is that bit functions are done with `BIGINT'
  3750.      precision, `IF', and `ELT()' with `BIGINT' or `DOUBLE' precision
  3751.      and the rest with `DOUBLE' precision.  One should try to avoid
  3752.      using bigger unsigned long long values than 63 bits
  3753.      (9223372036854775807) for anything else than bit fields!
  3754.  
  3755.    * All string columns, except `BLOB' and `TEXT' columns, automatically
  3756.      have all trailing spaces removed when retrieved. For `CHAR' types
  3757.      this is okay, and may be regarded as a feature according to ANSI
  3758.      SQL92. The bug is that in MySQL, `VARCHAR' columns are treated the
  3759.      same way.
  3760.  
  3761.    * You can only have up to 255 `ENUM' and `SET' columns in one table.
  3762.  
  3763.    * `safe_mysqld' re-directs all messages from `mysqld' to the
  3764.      `mysqld' log.  One problem with this is that if you execute
  3765.      `mysqladmin refresh' to close and reopen the log, `stdout' and
  3766.      `stderr' are still redirected to the old log.  If you use `--log'
  3767.      extensively, you should edit `safe_mysqld' to log to
  3768.      `'hostname'.err' instead of `'hostname'.log' so you can easily
  3769.      reclaim the space for the old log by deleting the old one and
  3770.      executing `mysqladmin refresh'.
  3771.  
  3772.    * In the `UPDATE' statement, columns are updated from left to right.
  3773.      If you refer to an updated column, you will get the updated value
  3774.      instead of the original value. For example:
  3775.  
  3776.           mysql> UPDATE tbl_name SET KEY=KEY+1,KEY=KEY+1;
  3777.  
  3778.      This will update `KEY' with `2' instead of with `1'.
  3779.  
  3780.    * You can't use temporary tables more than once in the same query.
  3781.      For example, the following doesn't work.
  3782.  
  3783.           select * from temporary_table, temporary_table as t2;
  3784.  
  3785.    * `RENAME' doesn't work with `TEMPORARY' tables.
  3786.  
  3787.    * The optimizer may handle `DISTINCT' differently if you are using
  3788.      'hidden' columns in a join or not.  In a join, hidden columns are
  3789.      counted as part of the result (even if they are not shown) while in
  3790.      normal queries hidden columns doesn't participate in the `DISTINCT'
  3791.      comparison.  We will probably change this in the future to never
  3792.      compare the hidden columns when executing `DISTINCT'
  3793.  
  3794.      An example of this is:
  3795.  
  3796.           SELECT DISTINCT mp3id FROM band_downloads WHERE userid = 9 ORDER BY id
  3797.           DESC;
  3798.  
  3799.      and
  3800.  
  3801.           SELECT DISTINCT band_downloads.mp3id, FROM band_downloads,band_mp3
  3802.           WHERE band_downloads.userid = 9 AND band_mp3.id = band_downloads.mp3id
  3803.           ORDER BY band_downloads.id DESC;
  3804.  
  3805.      In the second case you may in MySQL 3.23.x get two identical rows
  3806.      in the result set (because the hidden 'id' column may differ).
  3807.  
  3808.      Note that the this only happens for queries where you don't have
  3809.      the ORDER BY columns in the result, something that is you are not
  3810.      allowed to do in ANSI SQL.
  3811.  
  3812.    * Because MySQL allows you to work with table types that doesn't
  3813.      support transactions (and thus can't `rollback' data) some things
  3814.      behaves a little different in MySQL than in other SQL servers:
  3815.      (This is just to ensure that MySQL never need to do a rollback for
  3816.      a SQL command).  This may be a little awkward at times as column
  3817.      Because MySQL allows you to work with table types that don't
  3818.      support transactions, and thus can't `rollback' data, some things
  3819.      behave a little differently in MySQL than in other SQL servers.
  3820.      This is just to ensure that MySQL never need to do a rollback for
  3821.      a SQL command.  This may be a little awkward at times as column
  3822.      values must be checked in the application, but this will actually
  3823.      give you a nice speed increase as it allows MySQL to do some
  3824.      optimizations that otherwise would be very hard to do.
  3825.  
  3826.      If you set a column to an incorrect value, MySQL will, instead of
  3827.      doing a rollback, store the `best possible value' in the column:
  3828.  
  3829.         - If you try to store a value outside the range in a numerical
  3830.           column, MySQL will instead store the smallest or biggest
  3831.           possible value in the column.
  3832.  
  3833.         - If you try to store a string that doesn't start with a number
  3834.           into a numerical column, MySQL will store 0 into it.
  3835.  
  3836.         - If you try to store `NULL' into a column that doesn't take
  3837.           `NULL' values, MySQL will store 0 or `''' (empty string) in
  3838.           it instead. (This behavior can, however, be changed with the
  3839.           -DDONT_USE_DEFAULT_FIELDS compile option).
  3840.  
  3841.         - MySQL allows you to store some wrong date values into `DATE'
  3842.           and `DATETIME' columns. (Like 2000-02-31 or 2000-02-00).  If
  3843.           the date is totally wrong, MySQL will store the special
  3844.           0000-00-00 date value in the column.
  3845.  
  3846.         - If you set an `enum' to an unsupported value, it will be set
  3847.           to the error value 'empty string', with numeric value 0.
  3848.  
  3849.    * If you execute a `PROCEDURE' on a query that returns an empty set,
  3850.      in some cases the `PROCEDURE' will not transform the columns.
  3851.  
  3852.    * Creation of a table of type `MERGE' doesn't check if the underlying
  3853.      tables are of compatible types.
  3854.  
  3855.    * MySQL can't yet handle `NaN', `-Inf' and `Inf' values in double.
  3856.      Using these will cause problems when trying to export and import
  3857.      data. We should as an intermediate solution change `NaN' to `NULL'
  3858.      (if possible) and `-Inf' and `Inf' to the Minimum respective
  3859.      maximum possible `double' value.
  3860.  
  3861.    * `LIMIT' on negative numbers are treated as big positive numbers.
  3862.  
  3863.    * If you use `ALTER TABLE' to first add an `UNIQUE' index to a table
  3864.      used in a `MERGE' table and then use `ALTER TABLE' to add a normal
  3865.      index on the `MERGE' table, the key order will be different for
  3866.      the tables if there was an old not-unique key in the table. This
  3867.      is because `ALTER TABLE' puts `UNIQUE' keys before normal keys to
  3868.      be able to detect duplicate keys as early as possible.
  3869.  
  3870. The following are known bugs in earlier versions of MySQL:
  3871.  
  3872.    * You can get a hung thread if you do a `DROP TABLE' on a table that
  3873.      is one among many tables that is locked with `LOCK TABLES'.
  3874.  
  3875.    * In the following case you can get a core dump:
  3876.  
  3877.         - Delayed insert handler has pending inserts to a table.
  3878.  
  3879.         - `LOCK table' with `WRITE'
  3880.  
  3881.         - `FLUSH TABLES'
  3882.  
  3883.    * Before MySQL Version 3.23.2 an `UPDATE' that updated a key with a
  3884.      `WHERE' on the same key may have failed because the key was used to
  3885.      search for records and the same row may have been found multiple
  3886.      times:
  3887.  
  3888.           UPDATE tbl_name SET KEY=KEY+1 WHERE KEY > 100;
  3889.  
  3890.      A workaround is to use:
  3891.  
  3892.           mysql> UPDATE tbl_name SET KEY=KEY+1 WHERE KEY+0 > 100;
  3893.  
  3894.      This will work because MySQL will not use index on expressions in
  3895.      the `WHERE' clause.
  3896.  
  3897.    * Before MySQL Version 3.23, all numeric types where treated as
  3898.      fixed-point fields. That means you had to specify how many
  3899.      decimals a floating-point field shall have. All results were
  3900.      returned with the correct number of decimals.
  3901.  
  3902. For platform-specific bugs, see the sections about compiling and
  3903. porting.
  3904.  
  3905. 
  3906. File: mysql.info,  Node: Comparisons,  Next: TODO,  Prev: Compatibility,  Up: Introduction
  3907.  
  3908. How MySQL Compares to Other Databases
  3909. =====================================
  3910.  
  3911. * Menu:
  3912.  
  3913. * Compare mSQL::                How MySQL compares to `mSQL'
  3914. * Compare PostgreSQL::          How MySQL compares with PostgreSQL
  3915.  
  3916. This section compares MySQL to other popular databases.
  3917.  
  3918. This section has been written by the MySQL developers, so it should be
  3919. read with that in mind.  There are no factual errors contained in this
  3920. section that we know of.  If you find something which you believe to be
  3921. an error, please contact us about it at <docs@mysql.com>.
  3922.  
  3923. For a list of all supported limits, functions, and types, see the
  3924. `crash-me' Web page at `http://www.mysql.com/information/crash-me.php'.
  3925.  
  3926. 
  3927. File: mysql.info,  Node: Compare mSQL,  Next: Compare PostgreSQL,  Prev: Comparisons,  Up: Comparisons
  3928.  
  3929. How MySQL Compares to `mSQL'
  3930. ----------------------------
  3931.  
  3932. *Performance*
  3933.      For a true comparison of speed, consult the growing MySQL benchmark
  3934.      suite. *Note MySQL Benchmarks::.
  3935.  
  3936.      Because there is no thread creation overhead, a small parser, few
  3937.      features, and simple security, `mSQL' should be quicker at:
  3938.  
  3939.         * Tests that perform repeated connects and disconnects, running
  3940.           a very simple query during each connection.
  3941.  
  3942.         * `INSERT' operations into very simple tables with few columns
  3943.           and keys.
  3944.  
  3945.         * `CREATE TABLE' and `DROP TABLE'.
  3946.  
  3947.         * `SELECT' on something that isn't an index. (A table scan is
  3948.           very easy.)
  3949.  
  3950.      Because these operations are so simple, it is hard to be better at
  3951.      them when you have a higher startup overhead. After the connection
  3952.      is established, MySQL should perform much better.
  3953.  
  3954.      On the other hand, MySQL is much faster than `mSQL' (and most
  3955.      other SQL implementations) on the following:
  3956.  
  3957.         * Complex `SELECT' operations.
  3958.  
  3959.         * Retrieving large results (MySQL has a better, faster, and
  3960.           safer protocol).
  3961.  
  3962.         * Tables with variable-length strings, because MySQL has more
  3963.           efficient handling and can have indexes on `VARCHAR' columns.
  3964.  
  3965.         * Handling tables with many columns.
  3966.  
  3967.         * Handling tables with large record lengths.
  3968.  
  3969.         * `SELECT' with many expressions.
  3970.  
  3971.         * `SELECT' on large tables.
  3972.  
  3973.         * Handling many connections at the same time. MySQL is fully
  3974.           multi-threaded. Each connection has its own thread, which
  3975.           means that no thread has to wait for another (unless a thread
  3976.           is modifying a table another thread wants to access). In
  3977.           `mSQL', once one connection is established, all others must
  3978.           wait until the first has finished, regardless of whether the
  3979.           connection is running a query that is short or long. When the
  3980.           first connection terminates, the next can be served, while
  3981.           all the others wait again, etc.
  3982.  
  3983.         * Joins.  `mSQL' can become pathologically slow if you change
  3984.           the order of tables in a `SELECT'. In the benchmark suite, a
  3985.           time more than 15000 times slower than MySQL was seen.  This
  3986.           is due to `mSQL''s lack of a join optimizer to order tables
  3987.           in the optimal order. However, if you put the tables in
  3988.           exactly the right order in `mSQL'2 and the `WHERE' is simple
  3989.           and uses index columns, the join will be relatively fast!
  3990.           *Note MySQL Benchmarks::.
  3991.  
  3992.         * `ORDER BY' and `GROUP BY'.
  3993.  
  3994.         * `DISTINCT'.
  3995.  
  3996.         * Using `TEXT' or `BLOB' columns.
  3997.  
  3998. *SQL Features*
  3999.         * `GROUP BY' and `HAVING'.  `mSQL' does not support `GROUP BY'
  4000.           at all.  MySQL supports a full `GROUP BY' with both `HAVING'
  4001.           and the following functions: `COUNT()', `AVG()', `MIN()',
  4002.           `MAX()', `SUM()', and `STD()'.  `COUNT(*)' is optimized to
  4003.           return very quickly if the `SELECT' retrieves from one table,
  4004.           no other columns are retrieved, and there is no `WHERE'
  4005.           clause.  `MIN()' and `MAX()' may take string arguments.
  4006.  
  4007.         * `INSERT' and `UPDATE' with calculations.  MySQL can do
  4008.           calculations in an `INSERT' or `UPDATE'.  For example:
  4009.  
  4010.                mysql> UPDATE SET x=x*10+y WHERE x<20;
  4011.  
  4012.         * Aliasing.  MySQL has column aliasing.
  4013.  
  4014.         * Qualifying column names.  In MySQL, if a column name is
  4015.           unique among the tables used in a query, you do not have to
  4016.           use the full qualifier.
  4017.  
  4018.         * `SELECT' with functions.  MySQL has many functions (too many
  4019.           to list here; see *Note Functions::).
  4020.  
  4021.  
  4022. *Disk Space Efficiency*
  4023.      That is, how small can you make your tables?
  4024.  
  4025.      MySQL has very precise types, so you can create tables that take
  4026.      very little space. An example of a useful MySQL datatype is the
  4027.      `MEDIUMINT' that is 3 bytes long. If you have 100,000,000 records,
  4028.      saving even one byte per record is very important.
  4029.  
  4030.      `mSQL2' has a more limited set of column types, so it is more
  4031.      difficult to get small tables.
  4032.  
  4033. *Stability*
  4034.      This is harder to judge objectively. For a discussion of MySQL
  4035.      stability, see *Note Stability::.
  4036.  
  4037.      We have no experience with `mSQL' stability, so we cannot say
  4038.      anything about that.
  4039.  
  4040. *Price*
  4041.      Another important issue is the license. MySQL has a more flexible
  4042.      license than `mSQL', and is also less expensive than `mSQL'.
  4043.      Whichever product you choose to use, remember to at least consider
  4044.      paying for a license or e-mail support.  (You are required to get
  4045.      a license if you include MySQL with a product that you sell, of
  4046.      course.)
  4047.  
  4048. *Perl Interfaces*
  4049.      MySQL has basically the same interfaces to Perl as `mSQL' with
  4050.      some added features.
  4051.  
  4052. *JDBC (Java)*
  4053.      MySQL currently has a lot of different JDBC drivers:
  4054.  
  4055.         * The mm driver: A type 4 JDBC driver by Mark Matthews
  4056.           <mmatthew@ecn.purdue.edu>.  This is released under the LGPL.
  4057.  
  4058.         * The Resin driver. This is a commercial JDBC driver released
  4059.           under open source.
  4060.           `http://www.caucho.com/projects/jdbc-mysql/index.xtp'
  4061.  
  4062.         * The gwe driver: A Java interface by GWE technologies (not
  4063.           supported anymore).
  4064.  
  4065.         * The jms driver: An improved gwe driver by Xiaokun Kelvin ZHU
  4066.           <X.Zhu@brad.ac.uk> (not supported anymore).
  4067.  
  4068.         * The twz driver: A type 4 JDBC driver by Terrence W. Zellers
  4069.           <zellert@voicenet.com>.  This is commercial but is free for
  4070.           private and educational use (not supported anymore).
  4071.  
  4072.      The recommended driver is the mm driver. The Resin driver may also
  4073.      be good (at least the benchmarks looks good), but we haven't
  4074.      received that much information about this yet.
  4075.  
  4076.      We know that `mSQL' has a JDBC driver, but we have too little
  4077.      experience with it to compare.
  4078.  
  4079. *Rate of Development*
  4080.      MySQL has a very small team of developers, but we are quite used
  4081.      to coding C and C++ very rapidly. Because threads, functions,
  4082.      `GROUP BY', and so on are still not implemented in `mSQL', it has
  4083.      a lot of catching up to do. To get some perspective on this, you
  4084.      can view the `mSQL' `HISTORY' file for the last year and compare
  4085.      it with the News section of the MySQL Reference Manual (*note
  4086.      News::). It should be pretty obvious which one has developed most
  4087.      rapidly.
  4088.  
  4089. *Utility Programs*
  4090.      Both `mSQL' and MySQL have many interesting third-party tools.
  4091.      Because it is very easy to port upward (from `mSQL' to MySQL),
  4092.      almost all the interesting applications that are available for
  4093.      `mSQL' are also available for MySQL.
  4094.  
  4095.      MySQL comes with a simple `msql2mysql' program that fixes
  4096.      differences in spelling between `mSQL' and MySQL for the most-used
  4097.      C API functions.  For example, it changes instances of
  4098.      `msqlConnect()' to `mysql_connect()'. Converting a client program
  4099.      from `mSQL' to MySQL usually takes a couple of minutes.
  4100.  
  4101. * Menu:
  4102.  
  4103. * Using mSQL tools::            How to convert `mSQL' tools for MySQL
  4104. * Protocol differences::        How `mSQL' and MySQL Client/Server Communications Protocols Differ
  4105. * Syntax differences::          How `mSQL' 2.0 SQL Syntax Differs from MySQL
  4106.  
  4107. 
  4108. File: mysql.info,  Node: Using mSQL tools,  Next: Protocol differences,  Prev: Compare mSQL,  Up: Compare mSQL
  4109.  
  4110. How to Convert `mSQL' Tools for MySQL
  4111. .....................................
  4112.  
  4113. According to our experience, it would just take a few hours to convert
  4114. tools such as `msql-tcl' and `msqljava' that use the `mSQL' C API so
  4115. that they work with the MySQL C API.
  4116.  
  4117. The conversion procedure is:
  4118.  
  4119.   1. Run the shell script `msql2mysql' on the source. This requires the
  4120.      `replace' program, which is distributed with MySQL.
  4121.  
  4122.   2. Compile.
  4123.  
  4124.   3. Fix all compiler errors.
  4125.  
  4126. Differences between the `mSQL' C API and the MySQL C API are:
  4127.  
  4128.    * MySQL uses a `MYSQL' structure as a connection type (`mSQL' uses
  4129.      an `int').
  4130.  
  4131.    * `mysql_connect()' takes a pointer to a `MYSQL' structure as a
  4132.      parameter.  It is easy to define one globally or to use `malloc()'
  4133.      to get one.  `mysql_connect()' also takes two parameters for
  4134.      specifying the user and password.  You may set these to `NULL,
  4135.      NULL' for default use.
  4136.  
  4137.    * `mysql_error()' takes the `MYSQL' structure as a parameter. Just
  4138.      add the parameter to your old `msql_error()' code if you are
  4139.      porting old code.
  4140.  
  4141.    * MySQL returns an error number and a text error message for all
  4142.      errors. `mSQL' returns only a text error message.
  4143.  
  4144.    * Some incompatibilities exist as a result of MySQL supporting
  4145.      multiple connections to the server from the same process.
  4146.  
  4147. 
  4148. File: mysql.info,  Node: Protocol differences,  Next: Syntax differences,  Prev: Using mSQL tools,  Up: Compare mSQL
  4149.  
  4150. How `mSQL' and MySQL Client/Server Communications Protocols Differ
  4151. ..................................................................
  4152.  
  4153. There are enough differences that it is impossible (or at least not
  4154. easy) to support both.
  4155.  
  4156. The most significant ways in which the MySQL protocol differs from the
  4157. `mSQL' protocol are listed below:
  4158.  
  4159.    * A message buffer may contain many result rows.
  4160.  
  4161.    * The message buffers are dynamically enlarged if the query or the
  4162.      result is bigger than the current buffer, up to a configurable
  4163.      server and client limit.
  4164.  
  4165.    * All packets are numbered to catch duplicated or missing packets.
  4166.  
  4167.    * All column values are sent in ASCII. The lengths of columns and
  4168.      rows are sent in packed binary coding (1, 2, or 3 bytes).
  4169.  
  4170.    * MySQL can read in the result unbuffered (without having to store
  4171.      the full set in the client).
  4172.  
  4173.    * If a single read/write takes more than 30 seconds, the server
  4174.      closes the connection.
  4175.  
  4176.    * If a connection is idle for 8 hours, the server closes the
  4177.      connection.
  4178.  
  4179. * Menu:
  4180.  
  4181. * Syntax differences::          How `mSQL' 2.0 SQL Syntax Differs from MySQL
  4182.  
  4183. 
  4184. File: mysql.info,  Node: Syntax differences,  Prev: Protocol differences,  Up: Compare mSQL
  4185.  
  4186. How `mSQL' 2.0 SQL Syntax Differs from MySQL
  4187. ............................................
  4188.  
  4189. *Column types*
  4190.  
  4191. `MySQL'
  4192.      Has the following additional types (among others; *note `CREATE
  4193.      TABLE': CREATE TABLE.):
  4194.         * `ENUM' type for one of a set of strings.
  4195.  
  4196.         * `SET' type for many of a set of strings.
  4197.  
  4198.         * `BIGINT' type for 64-bit integers.
  4199.  
  4200. `'
  4201.      MySQL also supports the following additional type attributes:
  4202.         * `UNSIGNED' option for integer columns.
  4203.  
  4204.         * `ZEROFILL' option for integer columns.
  4205.  
  4206.         * `AUTO_INCREMENT' option for integer columns that are a
  4207.           `PRIMARY KEY'.  *Note `mysql_insert_id()': mysql_insert_id.
  4208.  
  4209.         * `DEFAULT' value for all columns.
  4210.  
  4211. `mSQL2'
  4212.      `mSQL' column types correspond to the MySQL types shown below:
  4213.      `mSQL'     *Corresponding MySQL type*
  4214.      *type*     
  4215.      `CHAR(len)'`CHAR(len)'
  4216.      `TEXT(len)'`TEXT(len)'. `len' is the maximal length.  And `LIKE'
  4217.                 works.
  4218.      `INT'      `INT'. With many more options!
  4219.      `REAL'     `REAL'. Or `FLOAT'. Both 4- and 8-byte versions are
  4220.                 available.
  4221.      `UINT'     `INT UNSIGNED'
  4222.      `DATE'     `DATE'. Uses ANSI SQL format rather than `mSQL''s own
  4223.                 format.
  4224.      `TIME'     `TIME'
  4225.      `MONEY'    `DECIMAL(12,2)'. A fixed-point value with two decimals.
  4226.  
  4227. *Index Creation*
  4228.  
  4229. `MySQL'
  4230.      Indexes may be specified at table creation time with the `CREATE
  4231.      TABLE' statement.
  4232.  
  4233. `mSQL'
  4234.      Indexes must be created after the table has been created, with
  4235.      separate `CREATE INDEX' statements.
  4236.  
  4237. *To Insert a Unique Identifier into a Table*
  4238.  
  4239. `MySQL'
  4240.      Use `AUTO_INCREMENT' as a column type specifier.  *Note
  4241.      `mysql_insert_id()': mysql_insert_id.
  4242.  
  4243. `mSQL'
  4244.      Create a `SEQUENCE' on a table and select the `_seq' column.
  4245.  
  4246. *To Obtain a Unique Identifier for a Row*
  4247.  
  4248. `MySQL'
  4249.      Add a `PRIMARY KEY' or `UNIQUE' key to the table and use this.
  4250.      New in Version 3.23.11: If the `PRIMARY' or `UNIQUE' key consists
  4251.      of only one column and this is of type integer, one can also refer
  4252.      to it as `_rowid'.
  4253.  
  4254. `mSQL'
  4255.      Use the `_rowid' column. Observe that `_rowid' may change over time
  4256.      depending on many factors.
  4257.  
  4258. *To Get the Time a Column Was Last Modified*
  4259.  
  4260. `MySQL'
  4261.      Add a `TIMESTAMP' column to the table. This column is
  4262.      automatically set to the current date and time for `INSERT' or
  4263.      `UPDATE' statements if you don't give the column a value or if you
  4264.      give it a `NULL' value.
  4265.  
  4266. `mSQL'
  4267.      Use the `_timestamp' column.
  4268.  
  4269. *`NULL' Value Comparisons*
  4270.  
  4271. `MySQL'
  4272.      MySQL follows ANSI SQL, and a comparison with `NULL' is always
  4273.      `NULL'.
  4274.  
  4275. `mSQL'
  4276.      In `mSQL', `NULL = NULL' is TRUE.  You must change `=NULL' to `IS
  4277.      NULL' and `<>NULL' to `IS NOT NULL' when porting old code from
  4278.      `mSQL' to MySQL.
  4279.  
  4280. *String Comparisons*
  4281.  
  4282. `MySQL'
  4283.      Normally, string comparisons are performed in case-independent
  4284.      fashion with the sort order determined by the current character
  4285.      set (ISO-8859-1 Latin1 by default).  If you don't like this,
  4286.      declare your columns with the `BINARY' attribute, which causes
  4287.      comparisons to be done according to the ASCII order used on the
  4288.      MySQL server host.
  4289.  
  4290. `mSQL'
  4291.      All string comparisons are performed in case-sensitive fashion with
  4292.      sorting in ASCII order.
  4293.  
  4294. *Case-insensitive Searching*
  4295.  
  4296. `MySQL'
  4297.      `LIKE' is a case-insensitive or case-sensitive operator, depending
  4298.      on the columns involved. If possible, MySQL uses indexes if the
  4299.      `LIKE' argument doesn't start with a wild-card character.
  4300.  
  4301. `mSQL'
  4302.      Use `CLIKE'.
  4303.  
  4304. *Handling of Trailing Spaces*
  4305.  
  4306. `MySQL'
  4307.      Strips all spaces at the end of `CHAR' and `VARCHAR' columns. Use
  4308.      a `TEXT' column if this behavior is not desired.
  4309.  
  4310. `mSQL'
  4311.      Retains trailing space.
  4312.  
  4313. *`WHERE' Clauses*
  4314.  
  4315. `MySQL'
  4316.      MySQL correctly prioritizes everything (`AND' is evaluated before
  4317.      `OR'). To get `mSQL' behavior in MySQL, use parentheses (as shown
  4318.      in an example below).
  4319.  
  4320. `mSQL'
  4321.      Evaluates everything from left to right. This means that some
  4322.      logical calculations with more than three arguments cannot be
  4323.      expressed in any way. It also means you must change some queries
  4324.      when you upgrade to MySQL. You do this easily by adding
  4325.      parentheses.  Suppose you have the following `mSQL' query:
  4326.           mysql> SELECT * FROM table WHERE a=1 AND b=2 OR a=3 AND b=4;
  4327.      To make MySQL evaluate this the way that `mSQL' would, you must
  4328.      add parentheses:
  4329.           mysql> SELECT * FROM table WHERE (a=1 AND (b=2 OR (a=3 AND (b=4))));
  4330.  
  4331. *Access Control*
  4332.  
  4333. `MySQL'
  4334.      Has tables to store grant (permission) options per user, host, and
  4335.      database. *Note Privileges::.
  4336.  
  4337. `mSQL'
  4338.      Has a file `mSQL.acl' in which you can grant read/write privileges
  4339.      for users.
  4340.  
  4341. `'
  4342. 
  4343. File: mysql.info,  Node: Compare PostgreSQL,  Prev: Compare mSQL,  Up: Comparisons
  4344.  
  4345. How MySQL Compares to PostgreSQL
  4346. --------------------------------
  4347.  
  4348. When reading the following, please note that both products are
  4349. continually evolving.  We at MySQL AB and the PostgreSQL developers are
  4350. both working on making our respective database as good as possible, so
  4351. we are both a serious choice to any commercial database.
  4352.  
  4353. The following comparison is made by us at MySQL AB.  We have tried to be
  4354. as accurate and fair as possible, but because we don't have a full
  4355. knowledge of all PostgreSQL features while we know MySQL througly, we
  4356. may have got some things wrong.  We will however correct these when they
  4357. come to our attention.
  4358.  
  4359. We would first like to note that PostgreSQL and MySQL are both widely
  4360. used products, but with different design goals, even if we are both
  4361. striving to be ANSI SQL compatible.  This means that for some
  4362. applications MySQL is more suited, while for others PostgreSQL is more
  4363. suited.  When choosing which database to use, you should first check if
  4364. the database's feature set satisfies your application.  If you need raw
  4365. speed, MySQL is probably your best choice.  If you need some of the
  4366. extra features that only PostgreSQL can offer, you should use
  4367. `PostgreSQL'.
  4368.  
  4369. * Menu:
  4370.  
  4371. * MySQL-PostgreSQL goals::      MySQL and PostgreSQL development strategies
  4372. * MySQL-PostgreSQL features::   Featurewise Comparison of MySQL and PostgreSQL
  4373. * MySQL-PostgreSQL benchmarks::  Benchmarking MySQL and PostgreSQL
  4374.  
  4375. 
  4376. File: mysql.info,  Node: MySQL-PostgreSQL goals,  Next: MySQL-PostgreSQL features,  Prev: Compare PostgreSQL,  Up: Compare PostgreSQL
  4377.  
  4378. MySQL and PostgreSQL development strategies
  4379. ...........................................
  4380.  
  4381. When adding things to MySQL we take pride to do an optimal, definite
  4382. solution.  The code should be so good that we shouldn't have any need to
  4383. change it in the foreseeable future.  We also do not like to sacrifice
  4384. speed for features but instead will do our utmost to find a solution
  4385. that will give maximal throughput.  This means that development will
  4386. take a little longer, but the end result will be well worth this.  This
  4387. kind of development is only possible because all server code are
  4388. checked by one of a few (currently two) persons before it's included in
  4389. the MySQL server.
  4390.  
  4391. We at MySQL AB believe in frequent releases to be able to push out new
  4392. features quickly to our users.  Because of this we do a new small
  4393. release about every three weeks, and a major branch every year.  All
  4394. releases are throughly tested with our testing tools on a lot of
  4395. different platforms.
  4396.  
  4397. PostgreSQL is based on a kernel with lots of contributors. In this setup
  4398. it makes sense to prioritize adding a lot of new features, instead of
  4399. implementing them optimally, because one can always optimize things
  4400. later if there arises a need for this.
  4401.  
  4402. Another big difference between MySQL and PostgreSQL is that nearly all
  4403. of the code in the MySQL server are coded by developers that are
  4404. employed by MySQL AB and are still working on the server code. The
  4405. exceptions are the transaction engines, and the regexp library.
  4406.  
  4407. This is in sharp contrast to the PostgreSQL code where the majority of
  4408. the code is coded by a big group of people with different backgrounds.
  4409. It was only recently that the PostgreSQL developers announced that their
  4410. current developer group had finally had time to take a look at all the
  4411. code in the current PostgreSQL release.
  4412.  
  4413. Both of the above development methods has it's own merits and drawbacks.
  4414. We here at MySQL AB think of course that our model is better because our
  4415. model gives better code consistency, more optimal and reusable code, and
  4416. in our opinion, fewer bugs.  Because we are the authors of the MySQL
  4417. server code, we are better able to coordinate new features and releases.
  4418.  
  4419. 
  4420. File: mysql.info,  Node: MySQL-PostgreSQL features,  Next: MySQL-PostgreSQL benchmarks,  Prev: MySQL-PostgreSQL goals,  Up: Compare PostgreSQL
  4421.  
  4422. Featurewise Comparison of MySQL and PostgreSQL
  4423. ..............................................
  4424.  
  4425. On the crash-me (http://www.mysql.com/information/crash-me.php) page
  4426. you can find a list of those database constructs and limits that one
  4427. can detect automatically with a program.  Note however that a lot of
  4428. the numerical limits may be changed with startup options for respective
  4429. database.  The above web page is however extremely useful when you want
  4430. to ensure that your applications works with many different databases or
  4431. when you want to convert your application from one datbase to another.
  4432.  
  4433. MySQL offers the following advantages over PostgreSQL:
  4434.  
  4435.    * `MySQL' is generally much faster than PostgreSQL.  *Note
  4436.      MySQL-PostgreSQL benchmarks::.
  4437.  
  4438.    * MySQL has a much larger user base than PostgreSQL, therefor the
  4439.      code is more tested and has historically been more stable than
  4440.      PostgreSQL.  MySQL is the much more used in production
  4441.      environments than PostgreSQL, mostly thanks to that MySQL AB,
  4442.      formerly TCX DataKonsult AB, has provided top quality commercial
  4443.      support for MySQL from the day it was released, whereas until
  4444.      recently PostgreSQL was unsupported.
  4445.  
  4446.    * MySQL works better on Windows than PostgreSQL does.  MySQL runs as
  4447.      a native Windows application (a service on NT/Win2000/WinXP), while
  4448.      PostgreSQL is run under the cygwin emulation.  We have heard that
  4449.      PostgreSQL is not yet that stable on Windows but we haven't been
  4450.      able to verify this ourselves.
  4451.  
  4452.    * MySQL has more APIs to other languages and is supported by more
  4453.      existing programs than PostgreSQL.  *Note Contrib::.
  4454.  
  4455.    * MySQL works on 24/7 heavy duty systems.  In most circumstances you
  4456.      never have to run any cleanups on MySQL.  PostgreSQL doesn't yet
  4457.      support 24/7 systems because you have to run `VACUUM()' once in a
  4458.      while to reclaim space from `UPDATE' and `DELETE' commands and to
  4459.      perform statistics analyzes that are critical to get good
  4460.      performance with PostgreSQL.  `VACUUM()' is also needed after
  4461.      adding a lot of new rows to a table.  On a busy system with lots
  4462.      of changes, `VACUUM()' must be run very frequently, in the worst
  4463.      cases even many times a day.  During the `VACUUM()' run, which may
  4464.      take hours if the database is big, the database is from a
  4465.      production standpoint, practically dead.  The PostgreSQL team has
  4466.      fixing this on their TODO, but we assume that this is not an easy
  4467.      thing to fix permanently.
  4468.  
  4469.    * A working, tested replication feature used by sites like:
  4470.         - Yahoo Finance (`http://finance.yahoo.com')
  4471.  
  4472.         - Mobile.de (`http://www.mobile.de/')
  4473.  
  4474.         - Slashdot (`http://www.slashdot.org')
  4475.  
  4476.    * Included in the MySQL distribution are two different testing
  4477.      suites, `mysql-test-run' and crash-me
  4478.      (http://www.mysql.com/information/crash-me.php), as well as a
  4479.      benchmark suite.  The test system is actively updated with code to
  4480.      test each new feature and almost all repeatable bugs that have
  4481.      come to our attention.  We test MySQL with these on a lot of
  4482.      platforms before every release.  These tests are more
  4483.      sophisticated than anything we have seen from PostgreSQL, and they
  4484.      ensures that the MySQL is kept to a high standard.
  4485.  
  4486.    * There are far more books in print about MySQL than about
  4487.      PostgreSQL.  O'Reilly, Sams, Que, and New Riders are all major
  4488.      publishers with books about MySQL.  All MySQL features are also
  4489.      documented in the MySQL on-line manual, because when a new feature
  4490.      is implemented, the MySQL developers are required to document it
  4491.      before it's included in the source.
  4492.  
  4493.    * MySQL supports more of the standard ODBC functions than
  4494.      `PostgreSQL'.
  4495.  
  4496.    * MySQL has a much more sophisticated `ALTER TABLE'.
  4497.  
  4498.    * MySQL has support for tables without transactions for applications
  4499.      that need all speed they can get. The tables may be memory based,
  4500.      `HEAP' tables or disk based `MyISAM'.  *Note Table types::.
  4501.  
  4502.    * MySQL has support for two different table handlers that support
  4503.      transactions, `BerkeleyDB' and `InnoDB'.  Because every
  4504.      transaction engine performs differently under different
  4505.      conditions, this gives the application writer more options to find
  4506.      an optimal solution for his or her setup.  *Note Table types::.
  4507.  
  4508.    * `MERGE' tables gives you a unique way to instantly make a view over
  4509.      a set of identical tables and use these as one.  This is perfect
  4510.      for systems where you have log files that you order for example by
  4511.      month.  *Note MERGE::.
  4512.  
  4513.    * The option to compress read-only tables, but still have direct
  4514.      access to the rows in the table, gives you better performance by
  4515.      minimizing disk reads.  This is very useful when you are archiving
  4516.      things.  *Note myisampack::.
  4517.  
  4518.    * MySQL has internal support for fulltext search. *Note Fulltext
  4519.      Search::.
  4520.  
  4521.    * You can access many databases from the same connection (depending
  4522.      of course on your privileges).
  4523.  
  4524.    * MySQL is coded from the start to be multi-threaded while
  4525.      PostgreSQL uses processes.  Context switching and access to common
  4526.      storage areas is much faster between threads than between separate
  4527.      processes, this gives MySQL a big speed advantage in multi-user
  4528.      applications and also makes it easier for MySQL to take full
  4529.      advantage of symmetric multiprocessor (SMP) systems.
  4530.  
  4531.    * MySQL has a much more sophisticated privilege system than
  4532.      PostgreSQL.  While PostgreSQL only supports `INSERT', `SELECT', and
  4533.      `UPDATE/DELETE' grants per user on a database or a table, MySQL
  4534.      allows you to define a full set of different privileges on
  4535.      database, table and column level.  MySQL also allows you to
  4536.      specify the privilege on host and user combinations.  *Note
  4537.      GRANT::.
  4538.  
  4539.    * MySQL supports a compressed client/server protocol which improves
  4540.      performance over slow links.
  4541.  
  4542.    * MySQL employs a "table handler" concept, and is the only relational
  4543.      database we know of built around this concept.  This allows
  4544.      different low-level table types to be swapped into the SQL engine,
  4545.      and each table type can be optimized for different performance
  4546.      characteristics.
  4547.  
  4548.    * All MySQL table types (except *InnoDB*) are implemented as files
  4549.      (one table per file), which makes it really easy to backup, move,
  4550.      delete and even symlink databases and tables, even when the server
  4551.      is down.
  4552.  
  4553.    * Tools to repair and optimize *MyISAM* tables (the most common
  4554.      MySQL table type).  A repair tool is only needed when a physical
  4555.      corruption of a data file happens, usually from a hardware
  4556.      failure.  It allows a majority of the data to be recovered.
  4557.  
  4558.    * Upgrading MySQL is painless.  When you are upgrading MySQL, you
  4559.      don't need to dump/restore your data, as you have to do with most
  4560.      PostgreSQL upgrades.
  4561.  
  4562. Drawbacks with MySQL compared to PostgreSQL:
  4563.  
  4564.    * The transaction support in MySQL is not yet as well tested as
  4565.      PostgreSQL's system.
  4566.  
  4567.    * Because MySQL uses threads, which are not yet flawless on many
  4568.      OSes, one must either use binaries from
  4569.      `http://www.mysql.com/downloads', or carefully follow our
  4570.      instructions on
  4571.      `http://www.mysql.com/doc/I/n/Installing_source.html' to get an
  4572.      optimal binary that works in all cases.
  4573.  
  4574.    * Table locking, as used by the non-transactional `MyISAM' tables, is
  4575.      in many cases faster than page locks, row locks or versioning.  The
  4576.      drawback however is that if one doesn't take into account how table
  4577.      locks work, a single long-running query can block a table for
  4578.      updates for a long time. This can usable be avoided when designing
  4579.      the application.  If not, one can always switch the trouble table
  4580.      to use one of the transactional table types. *Note Table locking::.
  4581.  
  4582.    * With UDF (user defined functions) one can extend MySQL with both
  4583.      normal SQL functions and aggregates, but this is not yet as easy
  4584.      or as flexible as in PostgreSQL.  *Note Adding functions::.
  4585.  
  4586.    * Updates and deletes that run over multiple tables is harder to do
  4587.      in MySQL. This will, hoever, be fixed in MySQL 4.0 with multi-table
  4588.      `DELETE' and multi-table `UPDATE' and in MySQL 4.1 with subselects.
  4589.  
  4590. PostgreSQL currently offers the following advantages over MySQL:
  4591.  
  4592. Note that because we know the MySQL road map, we have included in the
  4593. following table the version when MySQL should support this feature.
  4594. Unfortunately we couldn't do this for previous comparison, because we
  4595. don't know the PostgreSQL roadmap.
  4596.  
  4597. *Feature*                                          *MySQL version*
  4598. Subselects                                         4.1
  4599. Foreign keys                                       4.0 and 4.1
  4600. Views                                              4.2
  4601. Stored procedures                                  4.1
  4602. Extensible type system                             Not planned
  4603. Unions                                             4.0
  4604. Full join                                          4.0 or 4.1
  4605. Triggers                                           4.1
  4606. Constrainst                                        4.1
  4607. Cursors                                            4.1 or 4.2
  4608. Extensible index types like R-trees                R-trees are planned
  4609.                                                    for 4.2
  4610. Inherited tables                                   Not planned
  4611.  
  4612. Other reasons to use PostgreSQL:
  4613.  
  4614.    * Standard usage in PostgreSQL is closer to ANSI SQL in some cases.
  4615.  
  4616.    * One can speed up PostgreSQL by coding things as stored procedures.
  4617.  
  4618.    * PostgreSQL has a bigger team of developers that contribute to the
  4619.      server.
  4620.  
  4621. Drawbacks with PostgreSQL compared to MySQL:
  4622.  
  4623.    * `VACUUM()' makes PostgreSQL hard to use in a 24/7 environment.
  4624.  
  4625.    * Only transactional tables.
  4626.  
  4627.    * Much slower `INSERT', `DELETE', and `UPDATE'.
  4628.  
  4629. For a complete list of drawbacks, you should also examine the first
  4630. table in this section.
  4631.  
  4632. * Menu:
  4633.  
  4634. * MySQL-PostgreSQL benchmarks::  Benchmarking MySQL and PostgreSQL
  4635.  
  4636. 
  4637. File: mysql.info,  Node: MySQL-PostgreSQL benchmarks,  Prev: MySQL-PostgreSQL features,  Up: Compare PostgreSQL
  4638.  
  4639. Benchmarking MySQL and PostgreSQL
  4640. .................................
  4641.  
  4642. The only open source benchmark that we know of that can be used to
  4643. benchmark MySQL and PostgreSQL (and other databases) is our own. It can
  4644. be found at `http://www.mysql.com/information/benchmarks.html'.
  4645.  
  4646. We have many times asked the PostgreSQL developers and some PostgreSQL
  4647. users to help us extend this benchmark to make it the definitive
  4648. benchmark for databases, but unfortunately we haven't gotten any
  4649. feedback for this.
  4650.  
  4651. We the MySQL developers have, because of this, spent a lot of hours to
  4652. get maximum performance from PostgreSQL for the benchmarks, but because
  4653. we don't know PostgreSQL intimately, we are sure that there are things
  4654. that we have missed.  We have on the benchmark page documented exactly
  4655. how we did run the benchmark so that it should be easy for anyone to
  4656. repeat and verify our results.
  4657.  
  4658. The benchmarks are usually run with and without the `--fast' option.
  4659. When run with `--fast' we are trying to use every trick the server can
  4660. do to get the code to execute as fast as possible.  The idea is that the
  4661. normal run should show how the server would work in a default setup and
  4662. the `--fast' run shows how the server would do if the application
  4663. developer would use extensions in the server to make his application run
  4664. faster.
  4665.  
  4666. When running with PostgreSQL and `--fast' we do a `VACUUM()' after
  4667. every major table `UPDATE' and `DROP TABLE' to make the database in
  4668. perfect shape for the following `SELECT's.  The time for `VACUUM()' is
  4669. measured separately.
  4670.  
  4671. When running with PostgreSQL 7.1.1 we could, however, not run with
  4672. `--fast' because during the `INSERT' test, the postmaster (the
  4673. PostgreSQL deamon) died and the database was so corrupted that it was
  4674. impossible to restart postmaster.   After this happened twice, we
  4675. decided to postpone the `--fast' test until next PostgreSQL release.
  4676. The details about the machine we run the benchmark can be found on the
  4677. benchmark page.
  4678.  
  4679. Before going to the other benchmarks we know of, we would like to give
  4680. some background on benchmarks:
  4681.  
  4682. It's very easy to write a test that shows ANY database to be best
  4683. database in the world, by just restricting the test to something the
  4684. database is very good at and not test anything that the database is not
  4685. good at.  If one after this publishes the result with a single figure,
  4686. things are even easier.
  4687.  
  4688. This would be like us measuring the speed of MySQL compared to
  4689. PostgreSQL by looking at the summary time of the MySQL benchmarks on
  4690. our web page.  Based on this MySQL would be more than 40 times faster
  4691. than PostgreSQL, something that is of course not true.  We could make
  4692. things even worse by just taking the test where PostgreSQL performs
  4693. worst and claim that MySQL is more than 2000 times faster than
  4694. PostgreSQL.
  4695.  
  4696. The case is that MySQL does a lot of optimizations that PostgreSQL
  4697. doesn't do. This is of course also true the other way around.  An SQL
  4698. optimizer is a very complex thing, and a company could spend years on
  4699. just making the optimizer faster and faster.
  4700.  
  4701. When looking at the benchmark results you should look for things that
  4702. you do in your application and just use these results to decide which
  4703. database would be best suited for your application.  The benchmark
  4704. results also shows things a particular database is not good at and
  4705. should give you a notion about things to avoid and what you may have to
  4706. do in other ways.
  4707.  
  4708. We know of two benchmark tests that claims that PostgreSQL performs
  4709. better than MySQL.  These both where multi-user tests, a test that we
  4710. here at MySQL AB haven't had time to write and include in the benchmark
  4711. suite, mainly because it's a big task to do this in a manner that is
  4712. fair against all databases.
  4713.  
  4714. One is the benchmark paid for by Great Bridge, which you can read about
  4715. at: `http://www.greatbridge.com/about/press.php?content_id=4'.
  4716.  
  4717. This is the probably worst benchmark we have ever seen anyone conduct.
  4718. This was not only tuned to only test what PostgreSQL is absolutely best
  4719. at, it was also totally unfair against every other database involved in
  4720. the test.
  4721.  
  4722. *NOTE*:  We know that not even some of the main PostgreSQL developers
  4723. did like the way Great Bridge conducted the benchmark, so we don't
  4724. blame them for the way the benchmark was made.
  4725.  
  4726. This benchmark has been condemned in a lot of postings and newsgroups so
  4727. we will here just shortly repeat some things that where wrong with it.
  4728.  
  4729.    * The tests were run with an expensive commercial tool, that makes it
  4730.      impossible for an open source company like us to verify the
  4731.      benchmarks, or even check how the benchmarks were really done.
  4732.      The tool is not even a true benchmark tool, but an
  4733.      application/setup testing tool.  To refer this as a "standard"
  4734.      benchmark tool is to stretch the truth a long way.
  4735.  
  4736.    * Great Bridge admitted that they had optimized the PostgreSQL
  4737.      database (with `VACUUM()' before the test) and tuned the startup
  4738.      for the tests, something they hadn't done for any of the other
  4739.      databases involved.  To say "This process optimizes indexes and
  4740.      frees up disk space a bit.  The optimized indexes boost
  4741.      performance by some margin."  Our benchmarks clearly indicate that
  4742.      the difference in running a lot of selects on a database with and
  4743.      without `VACUUM()' can easily differ by a factor of ten.
  4744.  
  4745.    * The test results were also strange.  The AS3AP test documentation
  4746.      mentions that the test does "selections, simple joins, projections,
  4747.      aggregates, one-tuple updates, and bulk updates".
  4748.  
  4749.      PostgreSQL is good at doing `SELECT's and `JOIN's (especially
  4750.      after a `VACUUM()'), but doesn't perform as well on `INSERT's or
  4751.      `UPDATE's.  The benchmarks seem to indicate that only `SELECT's
  4752.      were done (or very few updates).  This could easily explain they
  4753.      good results for PostgreSQL in this test.  The bad results for
  4754.      MySQL will be obvious a bit down in this document.
  4755.  
  4756.    * They did run the so-called benchmark from a Windows machine
  4757.      against a Linux machine over ODBC, a setup that no normal database
  4758.      user would ever do when running a heavy multi-user application.
  4759.      This tested more the ODBC driver and the Windows protocol used
  4760.      between the clients than the database itself.
  4761.  
  4762.    * When running the database against Oracle and MS-SQL (Great Bridge
  4763.      has indirectly indicated that the databases they used in the
  4764.      test), they didn't use the native protocol but instead ODBC.
  4765.      Anyone that has ever used Oracle knows that all real application
  4766.      uses the native interface instead of ODBC.  Doing a test through
  4767.      ODBC and claiming that the results had anything to do with using
  4768.      the database in a real-world situation can't be regarded as fair.
  4769.      They should have done two tests with and without ODBC to provide
  4770.      the right facts (after having got experts to tune all involved
  4771.      databases of course).
  4772.  
  4773.    * They refer to the TPC-C tests, but they don't mention anywhere
  4774.      that the test they did was not a true TPC-C test and they were not
  4775.      even allowed to call it a TPC-C test.  A TPC-C test can only be
  4776.      conducted by the rules approved by the TPC Council
  4777.      (`http://www.tpc.org'). Great Bridge didn't do that.  By doing
  4778.      this they have both violated the TPC trademark and miscredited
  4779.      their own benchmarks.  The rules set by the TPC Council are very
  4780.      strict to ensure that no one can produce false results or make
  4781.      unprovable statements.  Apparently Great Bridge wasn't interested
  4782.      in doing this.
  4783.  
  4784.    * After the first test, we contacted Great Bridge and mentioned to
  4785.      them some of the obvious mistakes they had done with MySQL:
  4786.  
  4787.         - Running with a debug version of our ODBC driver
  4788.  
  4789.         - Running on a Linux system that wasn't optimized for threads
  4790.  
  4791.         - Using an old MySQL version when there was a recommended newer
  4792.           one available
  4793.  
  4794.         - Not starting MySQL with the right options for heavy
  4795.           multi-user use (the default installation of MySQL is tuned
  4796.           for minimal resource use).
  4797.  
  4798.      Great Bridge did run a new test, with our optimized ODBC driver
  4799.      and with better startup options for MySQL, but refused to either
  4800.      use our updated glibc library or our standard binary (used by 80%
  4801.      of our users), which was statically linked with a fixed glibc
  4802.      library.
  4803.  
  4804.      According to what we know, Great Bridge did nothing to ensure that
  4805.      the other databases were set up correctly to run well in their test
  4806.      environment.  We are sure however that they didn't contact Oracle
  4807.      or Microsoft to ask for their advice in this matter ;)
  4808.  
  4809.    * The benchmark was paid for by Great Bridge, and they decided to
  4810.      publish only partial, chosen results (instead of publishing it
  4811.      all).
  4812.  
  4813. Tim Perdue, a long time PostgreSQL fan and a reluctant MySQL user
  4814. published a comparison on phpbuider
  4815. (http://www.phpbuilder.com/columns/tim20001112.php3).
  4816.  
  4817. When we became aware of the comparison, we phoned Tim Perdue about this
  4818. because there were a lot of strange things in his results.  For example,
  4819. he claimed that MySQL had a problem with five users in his tests, when
  4820. we know that there are users with similar machines as his that are using
  4821. MySQL with 2000 simultaneous connections doing 400 queries per second.
  4822. (In this case the limit was the web bandwidth, not the database.)
  4823.  
  4824. It sounded like he was using a Linux kernel that either had some
  4825. problems with many threads, such as kernels before 2.4, which had a
  4826. problem with many threads on multi-CPU machines. We have documented in
  4827. this manual how to fix this and Tim should be aware of this problem.
  4828.  
  4829. The other possible problem could have been an old glibc library and
  4830. that Tim didn't use a MySQL binary from our site, which is linked with
  4831. a corrected glibc library, but had compiled a version of his own with.
  4832. In any of the above cases, the symptom would have been exactly what Tim
  4833. had measured.
  4834.  
  4835. We asked Tim if we could get access to his data so that we could repeat
  4836. the benchmark and if he could check the MySQL version on the machine to
  4837. find out what was wrong and he promised to come back to us about this.
  4838. He has not done that yet.
  4839.  
  4840. Because of this we can't put any trust in this benchmark either :(
  4841.  
  4842. Over time things also changes and the above benchmarks are not that
  4843. relevant anymore.  MySQL now have a couple of different table handlers
  4844. with different speed/concurrency tradeoffs.  *Note Table types::. It
  4845. would be interesting to see how the above tests would run with the
  4846. different transactional table types in MySQL.  PostgreSQL has of course
  4847. also got new features since the test was made.  As the above test are
  4848. not publicly available there is no way for us to know how the database
  4849. would preform in the same tests today.
  4850.  
  4851. Conclusion:
  4852.  
  4853. The only benchmarks that exist today that anyone can download and run
  4854. against MySQL and PostgreSQL is the MySQL benchmarks.  We here at MySQL
  4855. believe that open source databases should be tested with open source
  4856. tools!  This is the only way to ensure that no one does tests that
  4857. nobody can reproduce and use this to claim that a database is better
  4858. than another.  Without knowing all the facts it's impossible to answer
  4859. the claims of the tester.
  4860.  
  4861. The thing we find strange is that every test we have seen about
  4862. PostgreSQL, that is impossible to reproduce, claims that PostgreSQL is
  4863. better in most cases while our tests, which anyone can reproduce,
  4864. clearly shows otherwise.  With this we don't want to say that PostgreSQL
  4865. isn't good at many things (it is!) or that it isn't faster than MySQL
  4866. under certain conditions.  We would just like to see a fair test where
  4867. they are very good so that we could get some friendly competition going!
  4868.  
  4869. For more information about our benchmarks suite *Note MySQL
  4870. Benchmarks::.
  4871.  
  4872. We are working on an even better benchmark suite, including multi user
  4873. tests, and a better documentation of what the individual tests really
  4874. do and how to add more tests to the suite.
  4875.  
  4876. 
  4877. File: mysql.info,  Node: TODO,  Prev: Comparisons,  Up: Introduction
  4878.  
  4879. MySQL and the future (The TODO)
  4880. ===============================
  4881.  
  4882. * Menu:
  4883.  
  4884. * TODO MySQL 4.0::              Things that should be in Version 4.0
  4885. * TODO future::                 Things that must be done in the near future
  4886. * TODO sometime::               Things that have to be done sometime
  4887. * TODO unplanned::              Some things we don't have any plans to do
  4888.  
  4889. This appendix lists the features that we plan to implement in MySQL.
  4890.  
  4891. Everything in this list is approximately in the order it will be done.
  4892. If you want to affect the priority order, please register a license or
  4893. support us and tell us what you want to have done more quickly. *Note
  4894. Licensing and Support::.
  4895.  
  4896. The plan is that we in the future will support the full ANSI SQL99
  4897. standard, but with a lot of useful extensions. The challenge is to do
  4898. this without sacrifying the speed or compromise the code.
  4899.  
  4900. 
  4901. File: mysql.info,  Node: TODO MySQL 4.0,  Next: TODO future,  Prev: TODO,  Up: TODO
  4902.  
  4903. Things that should be in 4.0
  4904. ----------------------------
  4905.  
  4906. We plan to make MySQL Version 4.0 a "quick" release where we only add
  4907. some new stuff to enable others to help us with developing new features
  4908. into Version 4.1.  The MySQL 4.0 version should only take us about a
  4909. month to make after which we want to stabilize it and start working on
  4910. Version 4.1.  Version 4.0 should have the following new features:
  4911.  
  4912. The news section for 4.0 includes a list of the features we have already
  4913. implemented in the 4.0 tree. *Note News-4.0.x::.
  4914.  
  4915.    * New table definition file format (`.frm' files) This will enable us
  4916.      to not run out of bits when adding more table options.  One will
  4917.      still be able to use the old `.frm' file format with 4.0.  All
  4918.      newly created tables will, however, use the new format.
  4919.  
  4920.      The new file format will enable us to add new column types, more
  4921.      options for keys and `FOREIGN KEY' support.
  4922.  
  4923.    * `mysqld' as a library.  This will have the same interface as the
  4924.      standard MySQL client (with an extra function to just set up
  4925.      startup parameters) but will be faster (no TCP/IP or socket
  4926.      overhead), smaller and much easier to use for embedded products.
  4927.  
  4928.      One will be able to define at link time if one wants to use the
  4929.      client/server model or a stand-alone application just by defining
  4930.      which library to link with.
  4931.  
  4932.      The `mysqld' will support all standard MySQL features and one can
  4933.      use it in a threaded client to run different queries in each
  4934.      thread.
  4935.  
  4936.    * Replication should work with `RAND()' and user variables `@var'.
  4937.  
  4938.    * Online backup with very low performance penalty.  The online
  4939.      backup will make it easy to add a new replication slave without
  4940.      taking down the master.
  4941.  
  4942.    * `DELETE FROM table_name' will return the number of deleted rows.
  4943.      For fast execution one should use `TRUNCATE table_name'.
  4944.  
  4945.    * Allow `DELETE' on `MyISAM' tables to use the record cache.  To do
  4946.      this, we need to update the threads record cache when we update
  4947.      the `.MYD' file.
  4948.  
  4949.    * Better replication.
  4950.  
  4951.    * More functions for full-text search.  *Note Fulltext Features to
  4952.      Appear in MySQL 4.0::.
  4953.  
  4954.    * Character set casts and syntax for handling multiple character
  4955.      sets.
  4956.  
  4957.    * Allow users to change startup options without taking down the
  4958.      server.
  4959.  
  4960.    * Help for all commands from the client.
  4961.  
  4962.    * Secure connections (with SSL).
  4963.  
  4964.    * Extend the optimizer to be able to optimize some `ORDER BY
  4965.      key_name DESC' queries.
  4966.  
  4967.    * `SHOW COLUMNS FROM table_name' (used by `mysql' client to allow
  4968.      expansions of column names) should not open the table, but only the
  4969.      definition file. This will require less memory and be much faster.
  4970.  
  4971.    * New key cache
  4972.  
  4973.    * When using `SET CHARACTER SET' we should translate the whole query
  4974.      at once and not only strings. This will enable users to use the
  4975.      translated characters in database, table and column names.
  4976.  
  4977.    * Add a portable interface over `gethostbyaddr_r()' so that we can
  4978.      change `ip_to_hostname()' to not block other threads while doing
  4979.      DNS lookups.
  4980.  
  4981.    * Add `record_in_range()' method to `MERGE' tables to be able to
  4982.      choose the right index when there is many to choose from. We should
  4983.      also extend the info interface to get the key distribution for
  4984.      each index, of `analyze' is run on all sub tables.
  4985.  
  4986.    * `SET SQL_DEFAULT_TABLE_TYPE=[MyISAM | INNODB | BDB | HEAP]'.
  4987.  
  4988. 
  4989. File: mysql.info,  Node: TODO future,  Next: TODO sometime,  Prev: TODO MySQL 4.0,  Up: TODO
  4990.  
  4991. Things that must be done in the real near future
  4992. ------------------------------------------------
  4993.  
  4994.    * Fail safe replication.
  4995.  
  4996.    * Subqueries.  `select id from t where grp in (select grp from g
  4997.      where u > 100)'
  4998.  
  4999.    * Derived tables.
  5000.           select a.col1, b.col2 from (select max(col1) as col1 from root_table ) a,
  5001.           other_table b where a.col1=b.col1
  5002.  
  5003.      This could be done by automatically creating temporary tables for
  5004.      the derived tables for the duration of the query.
  5005.  
  5006.    * Add `PREPARE' of statements and sending of parameters to `mysqld'.
  5007.  
  5008.    * Extend the server/client protocol to support warnings.
  5009.  
  5010.    * Add options to the server/protocol protocol to get progress notes
  5011.      for long running commands.
  5012.  
  5013.    * Add database and real table name (in case of alias) to the
  5014.      MYSQL_FIELD structure.
  5015.  
  5016.    * Don't allow more than a defined number of threads to run MyISAM
  5017.      recover at the same time.
  5018.  
  5019.    * Change `INSERT ... SELECT' to optionally use concurrent inserts.
  5020.  
  5021.    * Implement `RENAME DATABASE'. To make this safe for all table
  5022.      handlers, it should work as follows:
  5023.         * Create the new database.
  5024.  
  5025.         * For every table do a rename of the table to another database,
  5026.           as we do with the `RENAME' command.
  5027.  
  5028.         * Drop the old database.
  5029.  
  5030.    * Return the original field types() when doing `SELECT MIN(column)
  5031.      ... GROUP BY'.
  5032.  
  5033.    * Multiple result sets.
  5034.  
  5035.    * Change the protocol to allow binary transfer of values. To do this
  5036.      efficiently, we need to add an API to allow binding of variables.
  5037.  
  5038.    * Make it possible to specify `long_query_time' with a granularity
  5039.      in microseconds.
  5040.  
  5041.    * Add a configurable prompt to the `mysql' command line client, with
  5042.      options like database in use, time and date...
  5043.  
  5044.    * Add range checking to `MERGE' tables.
  5045.  
  5046.    * Link the `myisampack' code into the server.
  5047.  
  5048.    * Port of MySQL to BeOS.
  5049.  
  5050.    * Port of the MySQL clients to LynxOS.
  5051.  
  5052.    * Add a temporary key buffer cache during `INSERT/DELETE/UPDATE' so
  5053.      that we can gracefully recover if the index file gets full.
  5054.  
  5055.    * If you perform an `ALTER TABLE' on a table that is symlinked to
  5056.      another disk, create temporary tables on this disk.
  5057.  
  5058.    * Implement a `DATE/DATETIME' type that handles time zone information
  5059.      properly, so that dealing with dates in different time zones is
  5060.      easier.
  5061.  
  5062.    * FreeBSD and MIT-pthreads;  Do sleeping threads take CPU?
  5063.  
  5064.    * Check if locked threads take any CPU.
  5065.  
  5066.    * Fix configure so that one can compile all libraries (like `MyISAM')
  5067.      without threads.
  5068.  
  5069.    * Add an option to periodically flush key pages for tables with
  5070.      delayed keys if they haven't been used in a while.
  5071.  
  5072.    * Allow join on key parts (optimization issue).
  5073.  
  5074.    * `INSERT SQL_CONCURRENT' and `mysqld --concurrent-insert' to do a
  5075.      concurrent insert at the end of the file if the file is
  5076.      read-locked.
  5077.  
  5078.    * Remember `FOREIGN' key definitions in the `.frm' file.
  5079.  
  5080.    * Cascading `DELETE'
  5081.  
  5082.    * Server side cursors.
  5083.  
  5084.    * Check if `lockd' works with modern Linux kernels; If not, we have
  5085.      to fix `lockd'!  To test this, start `mysqld' with
  5086.      `--enable-locking' and run the different fork* test suits. They
  5087.      shouldn't give any errors if `lockd' works.
  5088.  
  5089.    * Allow SQL variables in `LIMIT', like in `LIMIT @a,@b'.
  5090.  
  5091.    * Allow update of variables in `UPDATE' statements. For example:
  5092.      `UPDATE TABLE foo SET @a=a+b,a=@a, b=@a+c'
  5093.  
  5094.    * Change when user variables are updated so that one can use them
  5095.      with `GROUP BY', as in the following example: `SELECT id,
  5096.      @a:=count(*), sum(sum_col)/@a FROM table_name GROUP BY id'.
  5097.  
  5098.    * Don't add automatic `DEFAULT' values to columns.  Give an error
  5099.      when using an `INSERT' that doesn't contain a column that doesn't
  5100.      have a `DEFAULT'.
  5101.  
  5102.    * Caching of queries and results. This should be done as a separated
  5103.      module that examines each query and if this is query is in the
  5104.      cache the cached result should be returned.  When one updates a
  5105.      table one should remove as few queries as possible from the cache.
  5106.      This should give a big speed bost on machines with much RAM where
  5107.      queries are often repeated (like WWW applications).  One idea
  5108.      would be to only cache queries of type: `SELECT CACHED ...'
  5109.  
  5110.    * Fix `libmysql.c' to allow two `mysql_query()' commands in a row
  5111.      without reading results or give a nice error message when one does
  5112.      this.
  5113.  
  5114.    * Optimize `BIT' type to take 1 bit (now `BIT' takes 1 char).
  5115.  
  5116.    * Check why MIT-pthreads `ctime()' doesn't work on some FreeBSD
  5117.      systems.
  5118.  
  5119.    * Add an `IMAGE' option to `LOAD DATA INFILE' to not update
  5120.      `TIMESTAMP' and `AUTO_INCREMENT' fields.
  5121.  
  5122.    * Added `LOAD DATE INFILE.. UPDATE' syntax.
  5123.         * For tables with primary keys, if the data contains the
  5124.           primary key, entries matching that primary key are updated
  5125.           from the remainder of the columns. However, columns MISSING
  5126.           from the incoming data feed are not touched.
  5127.  
  5128.         * For tables tables with primary keys that are missing some
  5129.           part of the key in the incoming data stream, or that have no
  5130.           primary key, the feed is treated as a `LOAD DATA INFILE ...
  5131.           REPLACE INTO' is now.
  5132.  
  5133.    * Make `LOAD DATA INFILE' understand syntax like:
  5134.           LOAD DATA INFILE 'file_name.txt' INTO TABLE tbl_name
  5135.           TEXT_FIELDS (text_field1, text_field2, text_field3)
  5136.           SET table_field1=concatenate(text_field1, text_field2), table_field3=23
  5137.           IGNORE text_field3
  5138.           
  5139.           This can be used to skip over extra columns in the text file, or update columns
  5140.           based on expressions of the read data...
  5141.  
  5142.    * `LOAD DATA INFILE 'file_name' INTO TABLE 'table_name' ERRORS TO
  5143.      err_table_name' This would cause any errors and warnings to be
  5144.      logged into the err_table_name table. That table would have a
  5145.      structure like:
  5146.  
  5147.           line_number    - line number in data file
  5148.           error_message  - the error/warning message
  5149.           and maybe
  5150.           data_line      - the line from the data file
  5151.  
  5152.    * Add true `VARCHAR' support (There is already support for this in
  5153.      MyISAM).
  5154.  
  5155.    * Automatic output from `mysql' to netscape.
  5156.  
  5157.    * `LOCK DATABASES'. (with various options)
  5158.  
  5159.    * Change sort to allocate memory in "hunks" to get better memory
  5160.      utilization.
  5161.  
  5162.    * `DECIMAL' and `NUMERIC' types can't read exponential numbers;
  5163.      `Field_decimal::store(const char *from,uint len)' must be recoded
  5164.      to fix this.
  5165.  
  5166.    * Functions: ADD_TO_SET(value,set) and REMOVE_FROM_SET(value,set)
  5167.  
  5168.    * Add use of `t1 JOIN t2 ON ...' and `t1 JOIN t2 USING ...'
  5169.      Currently, you can only use this syntax with `LEFT JOIN'.
  5170.  
  5171.    * Add full support for `unsigned long long' type.
  5172.  
  5173.    * Many more variables for `show status'.  Counts for:
  5174.      `INSERT'/`DELETE'/`UPDATE' statements. Records reads and updated.
  5175.      Selects on 1 table and selects with joins.  Mean number of tables
  5176.      in select. Number of `ORDER BY' and `GROUP BY' queries.
  5177.  
  5178.    * If you abort `mysql' in the middle of a query, you should open
  5179.      another connection and kill the old running query.  Alternatively,
  5180.      an attempt should be made to detect this in the server.
  5181.  
  5182.    * Add a handler interface for table information so you can use it as
  5183.      a system table. This would be a bit slow if you requested
  5184.      information about all tables, but very flexible.  `SHOW INFO FROM
  5185.      tbl_name' for basic table information should be implemented.
  5186.  
  5187.    * Add support for UNICODE.
  5188.  
  5189.    * `NATURAL JOIN' and `UNION JOIN'
  5190.  
  5191.    * Allow `select a from crash_me left join crash_me2 using (a)'; In
  5192.      this case a is assumed to come from the crash_me table.
  5193.  
  5194.    * Fix that `ON' and `USING' works with the `JOIN' join type.
  5195.  
  5196.    * Oracle like `CONNECT BY PRIOR ...' to search hierarchy structures.
  5197.  
  5198.    * `mysqladmin copy database new-database'. - Requires COPY command
  5199.      to be added to `mysqld'
  5200.  
  5201.    * Processlist should show number of queries/thread.
  5202.  
  5203.    * `SHOW HOSTS' for printing information about the hostname cache.
  5204.  
  5205.    * `DELETE' and `REPLACE' options to the `UPDATE' statement (this
  5206.      will delete rows when one gets a duplicate key error while
  5207.      updating).
  5208.  
  5209.    * Change the format of `DATETIME' to store fractions of seconds.
  5210.  
  5211.    * Add all missing ANSI92 and ODBC 3.0 types.
  5212.  
  5213.    * Change table names from empty strings to `NULL' for calculated
  5214.      columns.
  5215.  
  5216.    * Don't use 'Item_copy_string' on numerical values to avoid
  5217.      number->string->number conversion in case of: `SELECT
  5218.      COUNT(*)*(id+0) FROM table_name GROUP BY id'
  5219.  
  5220.    * Make it possible to use the new GNU regexp library instead of the
  5221.      current one (The GNU library should be much faster than the old
  5222.      one).
  5223.  
  5224.    * Change that `ALTER TABLE' doesn't abort clients that executes
  5225.      `INSERT DELAYED'.
  5226.  
  5227.    * Fix that when columns referenced in an `UPDATE' clause contains
  5228.      the old values before the update started.
  5229.  
  5230.    * `myisamchk', `REPAIR' and `OPTIMIZE TABLE' should be able to
  5231.      handle cases where the data and/or index files are symbolic links.
  5232.  
  5233.    * Add simulation of `pread()'/`pwrite()' on Windows to enable
  5234.      concurrent inserts.
  5235.  
  5236.    * A logfile analyzer that could parsed out information about which
  5237.      tables are hit most often, how often multi-table joins are
  5238.      executed, etc.  It should help users identify areas or table
  5239.      design that could be optimized to execute much more efficient
  5240.      queries.
  5241.  
  5242.    * Add `SUM(DISTINCT)'
  5243.  
  5244.    * Add `ANY()',`EVERY()' and `SOME()' group functions. In ANSI SQL
  5245.      these only works on boolean columns, but we can extend these to
  5246.      work on any columns/expressions by applying: value == 0 -> FALSE
  5247.      and value <> 0 -> TRUE.
  5248.  
  5249.    * Fix that the type for `MAX(column)' is the same as the column type.
  5250.           create table t1 (a DATE);
  5251.           insert into t1 values (now());
  5252.           create table t2 select max(a) from t1;
  5253.           show columns from t2;
  5254.  
  5255.    * Come up with a nice syntax for a statement that will `UPDATE' the
  5256.      row if it exists and `INSERT' a new row if the row didn't exist.
  5257.      (Like `REPLACE' works with `INSERT' / `DELETE')
  5258.  
  5259. 
  5260. File: mysql.info,  Node: TODO sometime,  Next: TODO unplanned,  Prev: TODO future,  Up: TODO
  5261.  
  5262. Things that have to be done sometime
  5263. ------------------------------------
  5264.  
  5265.    * Implement function: `get_changed_tables(timeout,table1,table2,...)'
  5266.  
  5267.    * Atomic multi-table updates, eg `update items,month set
  5268.      items.price=month.price where items.id=month.id;';
  5269.  
  5270.    * Change reading through tables to use memmap when possible. Now only
  5271.      compressed tables use memmap.
  5272.  
  5273.    * Add a new privilege *'Show_priv'* for `SHOW' commands.
  5274.  
  5275.    * Make the automatic timestamp code nicer.  Add timestamps to the
  5276.      update log with `SET TIMESTAMP=#;'
  5277.  
  5278.    * Use read/write mutex in some places to get more speed.
  5279.  
  5280.    * Full foreign key support. One probably wants to implement a
  5281.      procedural language first.
  5282.  
  5283.    * Simple views (first on one table, later on any expression).
  5284.  
  5285.    * Automatically close some tables if a table, temporary table or
  5286.      temporary files gets error 23 (not enough open files).
  5287.  
  5288.    * When one finds a field=#, change all occurrences of field to #.
  5289.      Now this is only done for some simple cases.
  5290.  
  5291.    * Change all const expressions with calculated expressions if
  5292.      possible.
  5293.  
  5294.    * Optimize key = expression. At the moment only key = field or key =
  5295.      constant are optimized.
  5296.  
  5297.    * Join some of the copy functions for nicer code.
  5298.  
  5299.    * Change `sql_yacc.yy' to an inline parser to reduce its size and get
  5300.      better error messages (5 days).
  5301.  
  5302.    * Change the parser to use only one rule per different number of
  5303.      arguments in function.
  5304.  
  5305.    * Use of full calculation names in the order part. (For ACCESS97)
  5306.  
  5307.    * `UNION', `MINUS', `INTERSECT' and `FULL OUTER JOIN'.  (Currently
  5308.      only `LEFT OUTER JOIN' is supported)
  5309.  
  5310.    * Allow `UNIQUE' on fields that can be `NULL'.
  5311.  
  5312.    * `SQL_OPTION MAX_SELECT_TIME=#' to put a time limit on a query.
  5313.  
  5314.    * Make the update log to a database.
  5315.  
  5316.    * Negative `LIMIT' to retrieve data from the end.
  5317.  
  5318.    * Alarm around client connect/read/write functions.
  5319.  
  5320.    * Please note the changes to `safe_mysqld': according to FSSTND
  5321.      (which Debian tries to follow) PID files should go into
  5322.      `/var/run/<progname>.pid' and log files into `/var/log'. It would
  5323.      be nice if you could put the "DATADIR" in the first declaration of
  5324.      "pidfile" and "log", so the placement of these files can be
  5325.      changed with a single statement.
  5326.  
  5327.    * Allow a client to request logging.
  5328.  
  5329.    * Add use of `zlib()' for `gzip'-ed files to `LOAD DATA INFILE'.
  5330.  
  5331.    * Fix sorting and grouping of `BLOB' columns (partly solved now).
  5332.  
  5333.    * Stored procedures.  This is currently not regarded to be very
  5334.      important as stored procedures are not very standardized yet.
  5335.      Another problem is that true stored procedures make it much harder
  5336.      for the optimizer and in many cases the result is slower than
  5337.      before We will, on the other hand, add a simple (atomic) update
  5338.      language that can be used to write loops and such in the MySQL
  5339.      server.
  5340.  
  5341.    * Change to use semaphores when counting threads.  One should first
  5342.      implement a semaphore library to MIT-pthreads.
  5343.  
  5344.    * Don't assign a new `AUTO_INCREMENT' value when one sets a column
  5345.      to 0.  Use `NULL' instead.
  5346.  
  5347.    * Add full support for `JOIN' with parentheses.
  5348.  
  5349.    * As an alternative for one thread / connection manage a pool of
  5350.      threads to handle the queries.
  5351.  
  5352.    * Allow one to get more than one lock with `GET_LOCK'.  When doing
  5353.      this, one must also handle the possible deadlocks this change will
  5354.      introduce.
  5355.  
  5356. Time is given according to amount of work, not real time.
  5357.  
  5358. 
  5359. File: mysql.info,  Node: TODO unplanned,  Prev: TODO sometime,  Up: TODO
  5360.  
  5361. Some things we don't have any plans to do
  5362. -----------------------------------------
  5363.  
  5364.    * Nothing;  In the long run we plan to be fully ANSI 92 / ANSI 99
  5365.      compliant.
  5366.  
  5367. 
  5368. File: mysql.info,  Node: Installing,  Next: Tutorial,  Prev: Introduction,  Up: Top
  5369.  
  5370. MySQL Installation
  5371. ******************
  5372.  
  5373. * Menu:
  5374.  
  5375. * Quick Standard Installation::  Quick Standard Installation of MySQL
  5376. * General Installation Issues::  General Installation Issues
  5377. * Installing source::           Installing a MySQL source distribution
  5378. * Post-installation::           Post-installation setup and testing
  5379. * Upgrade::                     Upgrading/Downgrading MySQL
  5380. * Operating System Specific Notes::  Operating System Specific Notes
  5381.  
  5382. This chapter describes how to obtain and install MySQL:
  5383.  
  5384.    * For a list of sites from which you can obtain MySQL, see *Note
  5385.      Getting MySQL: Getting MySQL.
  5386.  
  5387.    * To see which platforms are supported, see *Note Which OS::. Please
  5388.      note that not all supported system are equally good for running
  5389.      MySQL on them.  On some it is much more robust and efficient than
  5390.      others - see  *Note Which OS:: for details.
  5391.  
  5392.    * Several versions of MySQL are available in both binary and source
  5393.      distributions.  We also provide public access to our current
  5394.      source tree for those who want to see our most recent developments
  5395.      and help us test new code.  To determine which version and type of
  5396.      distribution you should use, see *Note Which version::. When in
  5397.      doubt, use the binary distribution.
  5398.  
  5399.    * Installation instructions for binary and source distributions are
  5400.      described in *Note Installing binary:: and *Note Installing
  5401.      source::.  Each set of instructions includes a section on
  5402.      system-specific problems you may run into.
  5403.  
  5404.    * For post-installation procedures, see *Note Post-installation::.
  5405.      These procedures apply whether you install MySQL using a binary or
  5406.      source distribution.
  5407.  
  5408. 
  5409. File: mysql.info,  Node: Quick Standard Installation,  Next: General Installation Issues,  Prev: Installing,  Up: Installing
  5410.  
  5411. Quick Standard Installation of MySQL
  5412. ====================================
  5413.  
  5414. * Menu:
  5415.  
  5416. * Linux-RPM::                   Installing MySQL on Linux
  5417. * Windows installation::        Installing MySQL on Windows
  5418.  
  5419. 
  5420. File: mysql.info,  Node: Linux-RPM,  Next: Windows installation,  Prev: Quick Standard Installation,  Up: Quick Standard Installation
  5421.  
  5422. Installing MySQL on Linux
  5423. -------------------------
  5424.  
  5425. The recommended way to install MySQL on Linux is by using an RPM file.
  5426. The MySQL RPMs are currently being built on a RedHat Version 6.2 system
  5427. but should work on other versions of Linux that support `rpm' and use
  5428. `glibc'.
  5429.  
  5430. If you have problems with an RPM file, for example, if you receive the
  5431. error "`Sorry, the host 'xxxx' could not be looked up'", see *Note
  5432. Binary notes-Linux::.
  5433.  
  5434. The RPM files you may want to use are:
  5435.  
  5436.    * `MySQL-VERSION.i386.rpm'
  5437.  
  5438.      The MySQL server.  You will need this unless you only want to
  5439.      connect to a MySQL server running on another machine.
  5440.  
  5441.    * `MySQL-client-VERSION.i386.rpm'
  5442.  
  5443.      The standard MySQL client programs. You probably always want to
  5444.      install this package.
  5445.  
  5446.    * `MySQL-bench-VERSION.i386.rpm'
  5447.  
  5448.      Tests and benchmarks. Requires Perl and msql-mysql-modules RPMs.
  5449.  
  5450.    * `MySQL-devel-VERSION.i386.rpm'
  5451.  
  5452.      Libraries and include files needed if you want to compile other
  5453.      MySQL clients, such as the Perl modules.
  5454.  
  5455.    * `MySQL-VERSION.src.rpm'
  5456.  
  5457.      This contains the source code for all of the above packages. It
  5458.      can also be used to try to build RPMs for other architectures (for
  5459.      example, Alpha or SPARC).
  5460.  
  5461. To see all files in an RPM package, run:
  5462.      shell> rpm -qpl MySQL-VERSION.i386.rpm
  5463.  
  5464. To perform a standard minimal installation, run:
  5465.  
  5466.      shell> rpm -i MySQL-VERSION.i386.rpm MySQL-client-VERSION.i386.rpm
  5467.  
  5468. To install just the client package, run:
  5469.  
  5470.      shell> rpm -i MySQL-client-VERSION.i386.rpm
  5471.  
  5472. The RPM places data in `/var/lib/mysql'. The RPM also creates the
  5473. appropriate entries in `/etc/rc.d/' to start the server automatically
  5474. at boot time.  (This means that if you have performed a previous
  5475. installation, you may want to make a copy of your previously installed
  5476. MySQL startup file if you made any changes to it, so you don't lose
  5477. your changes.)
  5478.  
  5479. After installing the RPM file(s), the `mysqld' daemon should be running
  5480. and you should now be able to start using MySQL.  *Note
  5481. Post-installation::.
  5482.  
  5483. If something goes wrong, you can find more information in the binary
  5484. installation chapter. *Note Installing binary::.
  5485.  
  5486. 
  5487. File: mysql.info,  Node: Windows installation,  Prev: Linux-RPM,  Up: Quick Standard Installation
  5488.  
  5489. Installing MySQL on Windows
  5490. ---------------------------
  5491.  
  5492. The following instructions apply to precompiled binary distributions.
  5493. If you download a source distribution, you will have to compile and
  5494. install it yourself.
  5495.  
  5496. If you don't have a copy of the MySQL distribution, you should first
  5497. download one from `http://www.mysql.com/downloads/mysql-3.23.html'.
  5498.  
  5499. If you plan to connect to MySQL from some other program, you will
  5500. probably also need the *MyODBC* driver. You can find this at the
  5501. *MyODBC* download page
  5502. (`http://www.mysql.com/downloads/api-myodbc.html').
  5503.  
  5504. To install either distribution, unzip it in some empty directory and
  5505. run the `Setup.exe' program.
  5506.  
  5507. By default, MySQL-Windows is configured to be installed in `C:\mysql'.
  5508. If you want to install MySQL elsewhere, install it in `C:\mysql' first,
  5509. then move the installation to where you want it.  If you do move MySQL,
  5510. you must indicate where everything is located by supplying a
  5511. `--basedir' option when you start the server.  For example, if you have
  5512. moved the MySQL distribution to `D:\programs\mysql', you must start
  5513. `mysqld' like this:
  5514.  
  5515.      C:\> D:\programs\mysql\bin\mysqld --basedir D:\programs\mysql
  5516.  
  5517. Use `mysqld --help' to display all the options that `mysqld'
  5518. understands!
  5519.  
  5520. With all newer MySQL versions, you can also create a `C:\my.cnf' file
  5521. that holds any default options for the MySQL server.  Copy the file
  5522. `\mysql\my-xxxxx.cnf' to `C:\my.cnf' and edit it to suit your setup.
  5523. Note that you should specify all paths with `/' instead of `\'. If you
  5524. use `\', you need to specify it twice, because `\' is the escape
  5525. character in MySQL.  *Note Option files::.
  5526.  
  5527. Starting with MySQL 3.23.38, the Windows distribution includes both the
  5528. normal and the *MySQL-Max* binaries.  The main benefit of using the
  5529. normal `mysqld.exe' binary is that it's a little faster and uses less
  5530. resources.
  5531.  
  5532. Here is a list of the different MySQL servers you can use:
  5533.  
  5534. `mysqld'            Compiled with full debugging and automatic memory
  5535.                    allocation checking, symbolic links, BDB and InnoDB
  5536.                    tables.
  5537. `mysqld-opt'        Optimized binary with no support for transactional
  5538.                    tables.
  5539. `mysqld-nt'         Optimized binary for NT with support for named
  5540.                    pipes. You can run this version on Win98, but in this
  5541.                    case no named pipes are created and you must have
  5542.                    TCP/IP installed.
  5543. `mysqld-max'        Optimized binary with support for symbolic links,
  5544.                    BDB and InnoDB tables.
  5545. `mysqld-max-nt'     Like `mysqld-max', but compiled with support for
  5546.                    named pipes.
  5547.  
  5548. Starting from 3.23.50, named pipes are only enabled if mysqld is
  5549. started with `--enable-named-pipe'.
  5550.  
  5551. All of the above binaries are optimized for the Pentium Pro processor
  5552. but should work on any Intel processor >= i386.
  5553.  
  5554. NOTE: If you want to use InnoDB tables, there are certain startup
  5555. options that must be specified in your `my.ini' file! *Note InnoDB
  5556. start::.
  5557.  
  5558. 
  5559. File: mysql.info,  Node: General Installation Issues,  Next: Installing source,  Prev: Quick Standard Installation,  Up: Installing
  5560.  
  5561. General Installation Issues
  5562. ===========================
  5563.  
  5564. * Menu:
  5565.  
  5566. * Getting MySQL::               How to Get MySQL
  5567. * Which OS::                    Operating Systems Supported by MySQL
  5568. * Which version::               Which MySQL Version to Use
  5569. * Installation layouts::        Installation Layouts
  5570. * Many versions::               How and When Updates Are Released
  5571. * MySQL binaries::              MySQL Binaries Compiled by MySQL AB
  5572.  
  5573. 
  5574. File: mysql.info,  Node: Getting MySQL,  Next: Which OS,  Prev: General Installation Issues,  Up: General Installation Issues
  5575.  
  5576. How to Get MySQL
  5577. ----------------
  5578.  
  5579. Check the MySQL home page (http://www.mysql.com/) for information about
  5580. the current version and for downloading instructions.
  5581.  
  5582. Our main download mirror is located at:
  5583.  
  5584. `http://download.sourceforge.net/mirrors/mysql/'
  5585.  
  5586. If you are interested in becoming a MySQL mirror site, you may
  5587. anonymously rsync with: `rsync://download.sourceforge.net/mysql/'.
  5588. Please send e-mail to <webmaster@mysql.com> notifying us of your mirror
  5589. to be added to the list below.
  5590.  
  5591. If you have problems downloading from our main site, try using one of
  5592. the mirrors listed below.
  5593.  
  5594. Please report bad or out-of-date mirrors to <webmaster@mysql.com>.
  5595.  
  5596. *Europe:*
  5597.  
  5598.    *  Austria [Univ. of Technology/Vienna]  WWW
  5599.      (http://gd.tuwien.ac.at/db/mysql/) FTP
  5600.      (ftp://gd.tuwien.ac.at/db/mysql/)
  5601.  
  5602.    *  Bulgaria [online.bg/Sofia]  WWW (http://mysql.online.bg/) FTP
  5603.      (ftp://mysql.online.bg/)
  5604.  
  5605.    *  Czech Republic [Masaryk University in Brno]  WWW
  5606.      (http://mysql.linux.cz/index.html) FTP
  5607.      (ftp://ftp.fi.muni.cz/pub/mysql/)
  5608.  
  5609.    *  Czech Republic [www.sopik.cz]  WWW (http://www.mysql.cz/)
  5610.  
  5611.    *  Czech Republic [www.gin.cz]  WWW (http://mysql.gin.cz/) FTP
  5612.      (ftp://ftp.gin.cz/pub/MIRRORS/www.mysql.com/)
  5613.  
  5614.    *  Denmark [Borsen]  WWW (http://mysql.borsen.dk/)
  5615.  
  5616.    *  Denmark [SunSITE]  WWW (http://mirrors.sunsite.dk/mysql/) FTP
  5617.      (ftp://sunsite.dk/mirrors/mysql/)
  5618.  
  5619.    *  Estonia [OKinteractive]  WWW (http://mysql.mirror.ok.ee)
  5620.  
  5621.    *  France [mtesa.net]  WWW (http://mysql.mtesa.net/)
  5622.  
  5623.    *  France [fastorama.com, Chatenois]  WWW
  5624.      (http://mysql.fastorama.com/) FTP
  5625.      (ftp://ftp.fastorama.com/unix/mysql/)
  5626.  
  5627.    *  Finland [tonnikala.net]  WWW (http://mysql.tonnikala.org/)
  5628.  
  5629.    *  Germany [Kernelnotes.de, Bonn]  WWW
  5630.      (http://www.kernelnotes.de/mysql/) FTP
  5631.      (ftp://ftp.kernelnotes.de/pub/mirror/mysql.org/)
  5632.  
  5633.    *  Germany [Wolfenbuettel]  WWW
  5634.      (http://www.fh-wolfenbuettel.de/ftp/pub/database/mysql/) FTP
  5635.      (ftp://ftp.fh-wolfenbuettel.de/pub/database/mysql/)
  5636.  
  5637.    *  Greece [NTUA, Athens]  WWW (http://www.ntua.gr/mysql/) FTP
  5638.      (ftp://ftp.ntua.gr/pub/databases/mysql/)
  5639.  
  5640.    *  Hungary [Xenia]  WWW (http://mysql.sote.hu/) FTP
  5641.      (ftp://xenia.sote.hu/pub/mirrors/www.mysql.com/)
  5642.  
  5643.    *  Hungary [TiszaneT]  WWW (http://mysql.tiszanet.hu/) FTP
  5644.      (ftp://mysql.tiszanet.hu/pub/mirrors/mysql/)
  5645.  
  5646.    *  Hungary [stop.hu]  WWW (http://mysql.mirror.stop.hu/)
  5647.  
  5648.    *  Iceland [GM]  WWW (http://mysql.gm.is/) FTP
  5649.      (ftp://ftp.gm.is/pub/mysql/)
  5650.  
  5651.    *  Italy [feelinglinux.com]  WWW (http://mysql.feelinglinux.com/)
  5652.  
  5653.    *  Italy [Teta Srl]  WWW (http://www.teta.it/mysql/)
  5654.  
  5655.    *  Italy [tzone.it]  WWW (http://mysql.tzone.it/)
  5656.  
  5657.    *  Ireland [Esat Net]  WWW
  5658.      (http://ftp.esat.net/mirrors/download.sourceforge.net/pub/mirrors/mysql/)
  5659.      FTP
  5660.      (ftp://ftp.esat.net/mirrors/download.sourceforge.net/pub/mirrors/mysql/)
  5661.  
  5662.    *  Latvia [linux.lv]  FTP (ftp://ftp.linux.lv/pub/software/mysql/)
  5663.  
  5664.    *  Netherlands [Silverpoint]  WWW (http://mysql.silverpoint.nl/)
  5665.  
  5666.    *  Netherlands [Widexs BV]  WWW (http://mysql.widexs.nl/) FTP
  5667.      (ftp://mysql.widexs.nl/pub/mysql/)
  5668.  
  5669.    *  Netherlands [ProServe]  WWW (http://mysql.proserve.nl/)
  5670.  
  5671.    *  Poland [Sunsite]  WWW (http://sunsite.icm.edu.pl/mysql/) FTP
  5672.      (ftp://sunsite.icm.edu.pl/pub/unix/mysql/)
  5673.  
  5674.    *  Poland [ncservice.com/Gdansk]  WWW (http://mysql.service.net.pl/)
  5675.  
  5676.    *  Portugal [Netc]  WWW (http://ftp.netc.pt/pub/mysql/) FTP
  5677.      (ftp://ftp.netc.pt/pub/mysql/)
  5678.  
  5679.    *  Romania [roedu.net/Bucharest]  FTP
  5680.      (ftp://ftp.roedu.net/pub/mirrors/ftp.mysql.com/)
  5681.  
  5682.    *  Russia [DirectNet]  WWW (http://mysql.directnet.ru/) FTP
  5683.      (ftp://ftp.dn.ru/pub/MySQL/)
  5684.  
  5685.    *  Russia [Scientific Center/Chernogolovka]  FTP
  5686.      (ftp://ftp.chg.ru/pub/databases/mysql/)
  5687.  
  5688.    *  Sweden [Sunet]  WWW
  5689.      (http://ftp.sunet.se/pub/unix/databases/relational/mysql/) FTP
  5690.      (ftp://ftp.sunet.se/pub/unix/databases/relational/mysql/)
  5691.  
  5692.    *  Switzerland [Sunsite]  WWW
  5693.      (http://sunsite.cnlab-switch.ch/ftp/mirror/mysql/) FTP
  5694.      (ftp://sunsite.cnlab-switch.ch/mirror/mysql/)
  5695.  
  5696.    *  UK [PLiG/UK]  WWW (http://ftp.plig.org/pub/mysql/) FTP
  5697.      (ftp://ftp.plig.org/pub/mysql/)
  5698.  
  5699.    *  Ukraine [PACO]  WWW (http://mysql.paco.net.ua) FTP
  5700.      (ftp://mysql.paco.net.ua/)
  5701.  
  5702.    *  Ukraine [ISP Alkar Teleport/Dnepropetrovsk]  WWW
  5703.      (http://mysql.dp.ua/)
  5704.  
  5705.    *  Yugoslavia [bolex.co.yu]  WWW (http://mysql.boa.org.yu/) FTP
  5706.      (ftp://ftp.linux.org.yu/pub/MySQL/)
  5707.  
  5708.  
  5709. *North America:*
  5710.  
  5711.    *  Canada [Tryc]  WWW (http://web.tryc.on.ca/mysql/)
  5712.  
  5713.    *  USA [Hurricane Electric/San Jose]  WWW (http://mysql.he.net/)
  5714.  
  5715.    *  USA [ValueClick, Los Angeles CA]  WWW
  5716.      (http://mysql.valueclick.com/) FTP
  5717.      (ftp://mysql.valueclick.com/pub/mysql/Downloads/)
  5718.  
  5719.    *  USA [Wisconsin University/Wisconsin]  WWW
  5720.      (http://mirror.sit.wisc.edu/mysql/) FTP
  5721.      (ftp://mirror.sit.wisc.edu/mirrors/mysql/)
  5722.  
  5723.    *  USA [LinuxWired/Scottsdale, AZ]  WWW
  5724.      (http://mysql.linuxwired.net/) FTP
  5725.      (ftp://ftp.linuxwired.net/pub/mirrors/mysql/)
  5726.  
  5727.    *  USA [adgrafix.com/Boston, MA]  WWW (http://mysql.adgrafix.com/)
  5728.  
  5729.    *  USA [netNumina/Cambridge, MA]  WWW
  5730.      (http://mysql.mirrors.netnumina.com/)
  5731.  
  5732.    *  USA [Ahaza Systems/Seattle, WA]  WWW
  5733.      (http://mysql.mirrortree.com/) FTP
  5734.      (ftp://mysql.mirrortree.com/pub/mysql/)
  5735.  
  5736.  
  5737. *South America:*
  5738.  
  5739.    *  Argentina [bannerlandia.com]  WWW
  5740.      (http://mysql.bannerlandia.com.ar/) FTP
  5741.      (ftp://mysql.bannerlandia.com.ar/mirrors/mysql/)
  5742.  
  5743.    *  Chile [Vision]  WWW (http://mysql.vision.cl/)
  5744.  
  5745.    *  Chile [PSINet]  WWW (http://mysql.psinet.cl/) FTP
  5746.      (ftp://ftp.psinet.cl/pub/database/mysql/)
  5747.  
  5748.    *  Chile [Tecnoera]  WWW (http://mysql.tecnoera.com/)
  5749.  
  5750.  
  5751. *Asia:*
  5752.  
  5753.    *  China [linuxforum.net]  WWW
  5754.      (http://www2.linuxforum.net/mirror/mysql/)
  5755.  
  5756.    *  China [HKLPG/Hong Kong]  WWW (http://mysql.hklpg.org)
  5757.  
  5758.    *  China [Gremlins/Hong Kong]  WWW (http://mysql.gremlins.com.hk/)
  5759.      FTP (ftp://ftp.mirrors.gremlins.com.hk/mysql/)
  5760.  
  5761.    *  China [shellhung.org/Hong Kong]  WWW (http://mysql.shellhung.org/)
  5762.      FTP (ftp://ftp.shellhung.org/pub/Mirror/mysql/)
  5763.  
  5764.    *  Indonesia [incaf.net]  WWW (http://mysql.incaf.net/)
  5765.  
  5766.    *  Indonesia [web.id]  WWW (http://mysql.itb.web.id/) FTP
  5767.      (ftp://mysql.itb.web.id/pub/MySQL/)
  5768.  
  5769.    *  Japan [Soft Agency]  WWW (http://www.softagency.co.jp/MySQL)
  5770.  
  5771.    *  Japan [u-aizu.ac.jp/Aizu]  FTP
  5772.      (ftp://ftp.u-aizu.ac.jp/ftp/pub/dbms/mysql/mysql.com)
  5773.  
  5774.    *  South Korea [Webiiz]  WWW (http://mysql.webiiz.com/)
  5775.  
  5776.    *  South Korea [PanworldNet]  WWW (http://mysql.holywar.net/)
  5777.  
  5778.    *  Singapore [HJC]  WWW (http://mysql.hjc.edu.sg) FTP
  5779.      (ftp://ftp.hjc.edu.sg/mysql)
  5780.  
  5781.    *  Taiwan [TTN]  WWW (http://mysql.ttn.net)
  5782.  
  5783.    *  Taiwan [nctu.edu/HsinChu]  WWW (http://mysql.nctu.edu.tw/)
  5784.  
  5785.  
  5786. *Africa:*
  5787.  
  5788.    *  South-Africa [Mweb]  WWW (http://www.mysql.mweb.co.za/)
  5789.  
  5790.    *  South Africa [The Internet Solution/Johannesburg]  FTP
  5791.      (ftp://ftp.is.co.za/linux/mysql/)
  5792.  
  5793.  
  5794. 
  5795. File: mysql.info,  Node: Which OS,  Next: Which version,  Prev: Getting MySQL,  Up: General Installation Issues
  5796.  
  5797. Operating Systems Supported by MySQL
  5798. ------------------------------------
  5799.  
  5800. We use GNU Autoconf, so it is possible to port MySQL to all modern
  5801. systems with working Posix threads and a C++ compiler.  (To compile
  5802. only the client code, a C++ compiler is required but not threads.)  We
  5803. use and develop the software ourselves primarily on Sun Solaris
  5804. (Versions 2.5 - 2.7) and SuSE Linux Version 7.x.
  5805.  
  5806. Note that for many operating systems, the native thread support works
  5807. only in the latest versions. MySQL has been reported to compile
  5808. successfully on the following operating system/thread package
  5809. combinations:
  5810.  
  5811.    * AIX 4.x with native threads.  *Note IBM-AIX::.
  5812.  
  5813.    * Amiga.
  5814.  
  5815.    * BSDI 2.x with the included MIT-pthreads package.  *Note BSDI::.
  5816.  
  5817.    * BSDI 3.0, 3.1 and 4.x with native threads.  *Note BSDI::.
  5818.  
  5819.    * DEC Unix 4.x with native threads.  *Note Alpha-DEC-UNIX::.
  5820.  
  5821.    * FreeBSD 2.x with the included MIT-pthreads package.  *Note
  5822.      FreeBSD::.
  5823.  
  5824.    * FreeBSD 3.x and 4.x with native threads.  *Note FreeBSD::.
  5825.  
  5826.    * HP-UX 10.20 with the included MIT-pthreads package.  *Note HP-UX
  5827.      10.20::.
  5828.  
  5829.    * HP-UX 11.x with the native threads.  *Note HP-UX 11.x::.
  5830.  
  5831.    * Linux 2.0+ with LinuxThreads 0.7.1+ or `glibc' 2.0.7+.  *Note
  5832.      Linux::.
  5833.  
  5834.    * Mac OS X Server.  *Note Mac OS X::.
  5835.  
  5836.    * NetBSD 1.3/1.4 Intel and NetBSD 1.3 Alpha (Requires GNU make).
  5837.      *Note NetBSD::.
  5838.  
  5839.    * OpenBSD > 2.5 with native therads. OpenBSD < 2.5 with the included
  5840.      MIT-pthreads package.  *Note OpenBSD::.
  5841.  
  5842.    * OS/2 Warp 3, FixPack 29 and OS/2 Warp 4, FixPack 4.  *Note OS/2::.
  5843.  
  5844.    * SGI Irix 6.x with native threads.  *Note SGI-Irix::.
  5845.  
  5846.    * Solaris 2.5 and above with native threads on SPARC and x86.  *Note
  5847.      Solaris::.
  5848.  
  5849.    * SunOS 4.x with the included MIT-pthreads package.  *Note Solaris::.
  5850.  
  5851.    * SCO OpenServer with a recent port of the FSU Pthreads package.
  5852.      *Note SCO::.
  5853.  
  5854.    * SCO UnixWare 7.0.1.  *Note SCO Unixware::.
  5855.  
  5856.    * Tru64 Unix
  5857.  
  5858.    * Win95, Win98, NT, and Win2000.  *Note Windows::.
  5859.  
  5860. Note that not all platforms are suited equally well for running MySQL.
  5861. How well a certain platform is suited for a high-load mission critical
  5862. MySQL server is determined by the following factors:
  5863.  
  5864.    * General stability of the thread library. A platform may have
  5865.      excellent reputation otherwise, but if the thread library is
  5866.      unstable in the code that is called by MySQL, even if everything
  5867.      else is perfect, MySQL will be only as stable as the thread
  5868.      library.
  5869.  
  5870.    * The ability of the kernel and/or thread library to take advantage
  5871.      of *SMP* on multi-processor systems. In other words, when a process
  5872.      creates a thread, it should be possible for that thread to run on
  5873.      a different CPU than the original process.
  5874.  
  5875.    * The ability of the kernel and/or the thread library to run many
  5876.      threads which acquire/release a mutex over a short critical region
  5877.      frequently without excessive context switches. In other words, if
  5878.      the implementation of `pthread_mutex_lock()' is too anxious to
  5879.      yield CPU, this will hurt MySQL tremendously. If this issue is not
  5880.      taken care of, adding extra CPUs will actually make MySQL slower.
  5881.  
  5882.    * General file system stability/performance.
  5883.  
  5884.    * Ability of the file system to deal with large files at all and
  5885.      deal with them efficiently, if your tables are big.
  5886.  
  5887.    * Our level of expertise here at MySQL AB with the platform. If we
  5888.      know a platform well, we introduce platform-specific
  5889.      optimizations/fixes enabled at compile time. We can also provide
  5890.      advice on configuring your system optimally for MySQL.
  5891.  
  5892.    * The amount of testing of similar configurations we have done
  5893.      internally.
  5894.  
  5895.    * The number of users that have successfully run MySQL on that
  5896.      platform in similar configurations. If this number is high, the
  5897.      chances of hitting some platform-specific surprise are much
  5898.      smaller.
  5899.  
  5900. Based on the above criteria, the best platforms for running MySQL at
  5901. this point are x86 with SuSE Linux 7.1, 2.4 kernel and ReiserFS (or any
  5902. similar Linux distribution) and Sparc with Solaris 2.7 or 2.8. FreeBSD
  5903. comes third, but we really hope it will join the top club once the
  5904. thread library is improved. We also hope that at some point we will be
  5905. able to include all other platforms on which MySQL compiles, runs ok,
  5906. but not quite with the same level of stability and performance, into
  5907. the top category. This will require some effort on our part in
  5908. cooperation with the developers of the OS/library components MySQL
  5909. depends upon. If you are interested in making one of those components
  5910. better, are in a position to influence their development, and need more
  5911. detailed instructions on what MySQL needs to run better, send an e-mail
  5912. to <internals@lists.mysql.com>.
  5913.  
  5914. Please note that the comparison above is not to say that one OS is
  5915. better or worse than the other in general. We are talking about
  5916. choosing a particular OS for a dedicated purpose - running MySQL, and
  5917. compare platforms in that regard only. With this in mind, the result of
  5918. this comparison would be different if we included more issues into it.
  5919. And in some cases, the reason one OS is better than the other could
  5920. simply be that we have put forth more effort into testing on and
  5921. optimizing for that particular platform.  We are just stating our
  5922. observations to help you make a decision on which platform to use MySQL
  5923. on in your setup.
  5924.  
  5925. 
  5926. File: mysql.info,  Node: Which version,  Next: Installation layouts,  Prev: Which OS,  Up: General Installation Issues
  5927.  
  5928. Which MySQL Version to Use
  5929. --------------------------
  5930.  
  5931. The first decision to make is whether you want to use the latest
  5932. development release or the last stable release:
  5933.  
  5934.    * Normally, if you are beginning to use MySQL for the first time or
  5935.      trying to port it to some system for which there is no binary
  5936.      distribution, we recommend going with the stable release (currently
  5937.      Version 3.23.52.  Note that all MySQL releases are checked with
  5938.      the MySQL benchmarks and an extensive test suite before each
  5939.      release.
  5940.  
  5941.    * Otherwise, if you are running an old system and want to upgrade,
  5942.      but don't want to take chances with a non-seamless upgrade, you
  5943.      should upgrade to the latest in the same branch you are using
  5944.      (where only the last version number is newer than yours).  We have
  5945.      tried to fix only fatal bugs and make small, relatively safe
  5946.      changes to that version.
  5947.  
  5948. The second decision to make is whether you want to use a source
  5949. distribution or a binary distribution.  In most cases you should
  5950. probably use a binary distribution, if one exists for your platform, as
  5951. this generally will be easier to install than a source distribution.
  5952.  
  5953. In the following cases you probably will be better off with a source
  5954. installation:
  5955.  
  5956.    * If you want to install MySQL at some explicit location.  (The
  5957.      standard binary distributions are "ready to run" at any place, but
  5958.      you may want to get even more flexibility).
  5959.  
  5960.    * To be able to satisfy different user requirements, we are
  5961.      providing two different binary versions; One compiled with the
  5962.      non-transactional table handlers, (a small, fast binary), and one
  5963.      configured with the most important extended options like
  5964.      transaction-safe tables.  Both versions are compiled from the same
  5965.      source distribution.  All native `MySQL' clients can connect to
  5966.      both MySQL versions.
  5967.  
  5968.      The extended MySQL binary distribution is marked with the `-max'
  5969.      suffix and is configured with the same options as `mysqld-max'.
  5970.      *Note `mysqld-max': mysqld-max.
  5971.  
  5972.      If you want to use the `MySQL-Max' RPM, you must first install the
  5973.      standard `MySQL' RPM.
  5974.  
  5975.    * If you want to configure `mysqld' with some extra features that are
  5976.      NOT in the standard binary distributions.  Here is a list of the
  5977.      most common extra options that you may want to use:
  5978.  
  5979.         * `--with-berkeley-db'
  5980.  
  5981.         * `--with-innodb'
  5982.  
  5983.         * `--with-raid'
  5984.  
  5985.         * `--with-libwrap'
  5986.  
  5987.         * `--with-named-z-lib  (This is done for some of the binaries)'
  5988.  
  5989.         * `--with-debug[=full]'
  5990.  
  5991.    * The default binary distribution is normally compiled with support
  5992.      for all characters sets and should work on a variety of processors
  5993.      from the same processor family.
  5994.  
  5995.      If you want a faster MySQL server you may want to recompile it
  5996.      with support for only the character sets you need, use a better
  5997.      compiler (like `pgcc') or use compiler options that are better
  5998.      optimized for your processor.
  5999.  
  6000.    * If you have found a bug and reported it to the MySQL development
  6001.      team you will probably receive a patch that you need to apply to
  6002.      the source distribution to get the bug fixed.
  6003.  
  6004.    * If you want to read (and/or modify) the C and C++ code that makes
  6005.      up MySQL, you should get a source distribution.  The source code is
  6006.      always the ultimate manual.  Source distributions also contain more
  6007.      tests and examples than binary distributions.
  6008.  
  6009. The MySQL naming scheme uses release numbers that consist of three
  6010. numbers and a suffix.  For example, a release name like
  6011. `mysql-3.21.17-beta' is interpreted like this:
  6012.  
  6013.    * The first number (`3') describes the file format.  All Version 3
  6014.      releases have the same file format.
  6015.  
  6016.    * The second number (`21') is the release level.  Normally there are
  6017.      two to choose from. One is the release/stable branch (currently
  6018.      `23') and the other is the development branch (currently `4.0').
  6019.      Normally both are stable, but the development version may have
  6020.      quirks, missing documentation on new features, or may fail to
  6021.      compile on some systems.
  6022.  
  6023.    * The third number (`17') is the version number within the release
  6024.      level.  This is incremented for each new distribution.  Usually you
  6025.      want the latest version for the release level you have chosen.
  6026.  
  6027.    * The suffix (`beta') indicates the stability level of the release.
  6028.      The possible suffixes are:
  6029.  
  6030.         - `alpha' indicates that the release contains some large
  6031.           section of new code that hasn't been 100% tested.  Known bugs
  6032.           (usually there are none) should be documented in the News
  6033.           section.  *Note News::.  There are also new commands and
  6034.           extensions in most alpha releases.  Active development that
  6035.           may involve major code changes can occur on an alpha release,
  6036.           but everything will be tested before doing a release.  There
  6037.           should be no known bugs in any MySQL release.
  6038.  
  6039.         - `beta' means that all new code has been tested.  No major new
  6040.           features that could cause corruption on old code are added.
  6041.           There should be no known bugs.  A version changes from alpha
  6042.           to beta when there haven't been any reported fatal bugs
  6043.           within an alpha version for at least a month and we don't
  6044.           plan to add any features that could make any old command more
  6045.           unreliable.
  6046.  
  6047.         - `gamma' is a beta that has been around a while and seems to
  6048.           work fine.  Only minor fixes are added.  This is what many
  6049.           other companies call a release.
  6050.  
  6051.         - If there is no suffix, it means that the version has been run
  6052.           for a while at many different sites with no reports of bugs
  6053.           other than platform-specific bugs.  Only critical bug fixes
  6054.           are applied to the release. This is what we call a stable
  6055.           release.
  6056.  
  6057. All versions of MySQL are run through our standard tests and benchmarks
  6058. to ensure that they are relatively safe to use.  Because the standard
  6059. tests are extended over time to check for all previously found bugs,
  6060. the test suite keeps getting better.
  6061.  
  6062. Note that all releases have been tested at least with:
  6063.  
  6064. An internal test suite
  6065.      This is part of a production system for a customer.  It has many
  6066.      tables with hundreds of megabytes of data.
  6067.  
  6068. The MySQL benchmark suite
  6069.      This runs a range of common queries.  It is also a test to see
  6070.      whether the latest batch of optimizations actually made the code
  6071.      faster.  *Note MySQL Benchmarks::.
  6072.  
  6073. The `crash-me' test
  6074.      This tries to determine what features the database supports and
  6075.      what its capabilities and limitations are.  *Note MySQL
  6076.      Benchmarks::.
  6077.  
  6078. Another test is that we use the newest MySQL version in our internal
  6079. production environment, on at least one machine.  We have more than 100
  6080. gigabytes of data to work with.
  6081.  
  6082. 
  6083. File: mysql.info,  Node: Installation layouts,  Next: Many versions,  Prev: Which version,  Up: General Installation Issues
  6084.  
  6085. Installation Layouts
  6086. --------------------
  6087.  
  6088. This section describes the default layout of the directories created by
  6089. installing binary and source distributions.
  6090.  
  6091. A binary distribution is installed by unpacking it at the installation
  6092. location you choose (typically `/usr/local/mysql') and creates the
  6093. following directories in that location:
  6094.  
  6095. *Directory*            *Contents of directory*
  6096. `bin'                  Client programs and the `mysqld' server
  6097. `data'                 Log files, databases
  6098. `include'              Include (header) files
  6099. `lib'                  Libraries
  6100. `scripts'              `mysql_install_db'
  6101. `share/mysql'          Error message files
  6102. `sql-bench'            Benchmarks
  6103.  
  6104. A source distribution is installed after you configure and compile it.
  6105. By default, the installation step installs files under `/usr/local', in
  6106. the following subdirectories:
  6107.  
  6108. *Directory*            *Contents of directory*
  6109. `bin'                  Client programs and scripts
  6110. `include/mysql'        Include (header) files
  6111. `info'                 Documentation in Info format
  6112. `lib/mysql'            Libraries
  6113. `libexec'              The `mysqld' server
  6114. `share/mysql'          Error message files
  6115. `sql-bench'            Benchmarks and `crash-me' test
  6116. `var'                  Databases and log files
  6117.  
  6118. Within an installation directory, the layout of a source installation
  6119. differs from that of a binary installation in the following ways:
  6120.  
  6121.    * The `mysqld' server is installed in the `libexec' directory rather
  6122.      than in the `bin' directory.
  6123.  
  6124.    * The data directory is `var' rather than `data'.
  6125.  
  6126.    * `mysql_install_db' is installed in the `/usr/local/bin' directory
  6127.      rather than in `/usr/local/mysql/scripts'.
  6128.  
  6129.    * The header file and library directories are `include/mysql' and
  6130.      `lib/mysql' rather than `include' and `lib'.
  6131.  
  6132. You can create your own binary installation from a compiled source
  6133. distribution by executing the script `scripts/make_binary_distribution'.
  6134.  
  6135. 
  6136. File: mysql.info,  Node: Many versions,  Next: MySQL binaries,  Prev: Installation layouts,  Up: General Installation Issues
  6137.  
  6138. How and When Updates Are Released
  6139. ---------------------------------
  6140.  
  6141. MySQL is evolving quite rapidly here at MySQL AB and we want to share
  6142. this with other MySQL users.  We try to make a release when we have
  6143. very useful features that others seem to have a need for.
  6144.  
  6145. We also try to help out users who request features that are easy to
  6146. implement.  We take note of what our licensed users want to have, and
  6147. we especially take note of what our extended e-mail supported customers
  6148. want and try to help them out.
  6149.  
  6150. No one has to download a new release.  The News section will tell you if
  6151. the new release has something you really want.  *Note News::.
  6152.  
  6153. We use the following policy when updating MySQL:
  6154.  
  6155.    * For each minor update, the last number in the version string is
  6156.      incremented.  When there are major new features or minor
  6157.      incompatibilities with previous versions, the second number in the
  6158.      version string is incremented.  When the file format changes, the
  6159.      first number is increased.
  6160.  
  6161.    * Stable tested releases are meant to appear about 1-2 times a year,
  6162.      but if small bugs are found, a release with only bug fixes will be
  6163.      released.
  6164.  
  6165.    * Working releases are meant to appear about every 1-8 weeks.
  6166.  
  6167.    * Binary distributions for some platforms will be made by us for
  6168.      major releases.  Other people may make binary distributions for
  6169.      other systems but probably less frequently.
  6170.  
  6171.    * We usually make patches available as soon as we have located and
  6172.      fixed small bugs.
  6173.  
  6174.    * For non-critical but annoying bugs, we will make patches available
  6175.      if they are sent to us.  Otherwise we will combine many of them
  6176.      into a larger patch.
  6177.  
  6178.    * If there is, by any chance, a fatal bug in a release we will make
  6179.      a new release as soon as possible.  We would like other companies
  6180.      to do this, too.
  6181.  
  6182. The current stable release is Version 3.23; We have already moved active
  6183. development to Version 4.0.  Bugs will still be fixed in the stable
  6184. version.  We don't believe in a complete freeze, as this also leaves
  6185. out bug fixes and things that "must be done."  "Somewhat frozen" means
  6186. that we may add small things that "almost surely will not affect
  6187. anything that's already working."
  6188.  
  6189. 
  6190. File: mysql.info,  Node: MySQL binaries,  Prev: Many versions,  Up: General Installation Issues
  6191.  
  6192. MySQL Binaries Compiled by MySQL AB
  6193. -----------------------------------
  6194.  
  6195. As a service, we at MySQL AB provide a set of binary distributions of
  6196. MySQL that are compiled at our site or at sites where customers kindly
  6197. have given us access to their machines.
  6198.  
  6199. These distributions are generated with
  6200. `scripts/make_binary_distribution' and are configured with the
  6201. following compilers and options:
  6202.  
  6203. SunOS 4.1.4 2 sun4c with `gcc' 2.7.2.1
  6204.      `CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors" ./configure
  6205.      --prefix=/usr/local/mysql --disable-shared
  6206.      --with-extra-charsets=complex --enable-assembler'
  6207.  
  6208. SunOS 5.5.1 (and above) sun4u with `egcs' 1.0.3a or 2.90.27 or gcc 2.95.2 and newer
  6209.      `CC=gcc CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors
  6210.      -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql
  6211.      --with-low-memory --with-extra-charsets=complex --enable-assembler'
  6212.  
  6213. SunOS 5.6 i86pc with `gcc' 2.8.1
  6214.      `CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  6215.      --with-low-memory --with-extra-charsets=complex'
  6216.  
  6217. Linux 2.0.33 i386 with `pgcc' 2.90.29 (`egcs' 1.0.3a)
  6218.      `CFLAGS="-O3 -mpentium -mstack-align-double" CXX=gcc CXXFLAGS="-O3
  6219.      -mpentium -mstack-align-double -felide-constructors
  6220.      -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql
  6221.      --enable-assembler --with-mysqld-ldflags=-all-static
  6222.      --with-extra-charsets=complex'
  6223.  
  6224. Linux 2.2.x with x686 with `gcc' 2.95.2
  6225.      `CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro
  6226.      -felide-constructors -fno-exceptions -fno-rtti" ./configure
  6227.      --prefix=/usr/local/mysql --enable-assembler
  6228.      --with-mysqld-ldflags=-all-static --disable-shared
  6229.      --with-extra-charset=complex'
  6230.  
  6231. SCO 3.2v5.0.4 i386 with `gcc' 2.7-95q4
  6232.      `CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  6233.      --with-extra-charsets=complex'
  6234.  
  6235. AIX 2 4 with `gcc' 2.7.2.2
  6236.      `CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  6237.      --with-extra-charsets=complex'
  6238.  
  6239. OSF1 V4.0 564 alpha with `gcc' 2.8.1
  6240.      `CC=gcc CFLAGS=-O CXX=gcc CXXFLAGS=-O3 ./configure
  6241.      --prefix=/usr/local/mysql --with-low-memory
  6242.      --with-extra-charsets=complex'
  6243.  
  6244. Irix 6.3 IP32 with `gcc' 2.8.0
  6245.      `CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  6246.      --with-extra-charsets=complex'
  6247.  
  6248. BSDI BSD/OS 3.1 i386 with `gcc' 2.7.2.1
  6249.      `CC=gcc CXX=gcc CXXFLAGS=-O ./configure --prefix=/usr/local/mysql
  6250.      --with-extra-charsets=complex'
  6251.  
  6252. BSDI BSD/OS 2.1 i386 with `gcc' 2.7.2
  6253.      `CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  6254.      --with-extra-charsets=complex'
  6255.  
  6256. Anyone who has more optimal options for any of the configurations listed
  6257. above can always mail them to the developer's mailing list at
  6258. <internals@lists.mysql.com>.
  6259.  
  6260. RPM distributions prior to MySQL Version 3.22 are user-contributed.
  6261. Beginning with Version 3.22, the RPMs are generated by us at MySQL AB.
  6262.  
  6263. If you want to compile a debug version of MySQL, you should add
  6264. `--with-debug' or `--with-debug=full' to the above configure lines and
  6265. remove any `-fomit-frame-pointer' options.
  6266.  
  6267. 
  6268. File: mysql.info,  Node: Installing source,  Next: Post-installation,  Prev: General Installation Issues,  Up: Installing
  6269.  
  6270. Installing a MySQL Source Distribution
  6271. ======================================
  6272.  
  6273. Before you proceed with the source installation, check first to see if
  6274. our binary is available for your platform and if it will work for you.
  6275. We put in a lot of effort into making sure that our binaries are built
  6276. with the best possible options.
  6277.  
  6278. You need the following tools to build and install MySQL from source:
  6279.  
  6280.    * GNU `gunzip' to uncompress the distribution.
  6281.  
  6282.    * A reasonable `tar' to unpack the distribution.  GNU `tar' is known
  6283.      to work.  Sun `tar' is known to have problems.
  6284.  
  6285.    * A working ANSI C++ compiler.  `gcc' >= 2.95.2, `egcs' >= 1.0.2 or
  6286.      `egcs 2.91.66', SGI C++, and SunPro C++ are some of the compilers
  6287.      that are known to work.  `libg++' is not needed when using `gcc'.
  6288.      `gcc' 2.7.x has a bug that makes it impossible to compile some
  6289.      perfectly legal C++ files, such as `sql/sql_base.cc'.  If you only
  6290.      have `gcc' 2.7.x, you must upgrade your `gcc' to be able to
  6291.      compile MySQL. `gcc' 2.8.1 is also known to have problems on some
  6292.      platforms so it should be avoided if there exists a new compiler
  6293.      for the platform..
  6294.  
  6295.      `gcc' >= 2.95.2 is recommended when compiling MySQL Version 3.23.x.
  6296.  
  6297.    * A good `make' program.  GNU `make' is always recommended and is
  6298.      sometimes required.  If you have problems, we recommend trying GNU
  6299.      `make' 3.75 or newer.
  6300.  
  6301. If you are using a recent version of *gcc*, recent enough to understand
  6302. `-fno-exceptions' option, it is *VERY IMPORTANT* that you use it.
  6303. Otherwise, you may compile a binary that crashes randomly. We also
  6304. recommend that you use `-felide-contructors' and `-fno-rtti' along with
  6305. `-fno-exceptions'. When in doubt, do the following:
  6306.  
  6307.  
  6308.      CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static
  6309.  
  6310. On most systems this will give you a fast and stable binary.
  6311.  
  6312. If you run into problems, *PLEASE ALWAYS USE `mysqlbug'* when posting
  6313. questions to <mysql@lists.mysql.com>.  Even if the problem isn't a bug,
  6314. `mysqlbug' gathers system information that will help others solve your
  6315. problem.  By not using `mysqlbug', you lessen the likelihood of getting
  6316. a solution to your problem!  You will find `mysqlbug' in the `scripts'
  6317. directory after you unpack the distribution.  *Note Bug reports::.
  6318.  
  6319. * Menu:
  6320.  
  6321. * Quick install::               Quick installation overview
  6322. * Applying patches::            Applying patches
  6323. * configure options::           Typical `configure' options
  6324. * Installing source tree::      Installing from the Development Source Tree
  6325. * Compilation problems::        Problems Compiling?
  6326. * MIT-pthreads::                MIT-pthreads Notes
  6327.  
  6328. 
  6329. File: mysql.info,  Node: Quick install,  Next: Applying patches,  Prev: Installing source,  Up: Installing source
  6330.  
  6331. Quick Installation Overview
  6332. ---------------------------
  6333.  
  6334. The basic commands you must execute to install a MySQL source
  6335. distribution are:
  6336.  
  6337.      shell> groupadd mysql
  6338.      shell> useradd -g mysql mysql
  6339.      shell> gunzip < mysql-VERSION.tar.gz | tar -xvf -
  6340.      shell> cd mysql-VERSION
  6341.      shell> ./configure --prefix=/usr/local/mysql
  6342.      shell> make
  6343.      shell> make install
  6344.      shell> scripts/mysql_install_db
  6345.      shell> chown -R root  /usr/local/mysql
  6346.      shell> chown -R mysql /usr/local/mysql/var
  6347.      shell> chgrp -R mysql /usr/local/mysql
  6348.      shell> cp support-files/my-medium.cnf /etc/my.cnf
  6349.      shell> /usr/local/mysql/bin/safe_mysqld --user=mysql &
  6350.  
  6351. If you want have support for InnoDB tables, you should edit the
  6352. `/etc/my.cnf' file and remove the `#' character before the parameters
  6353. that starts with `innodb_...'. *Note Option files::. *Note InnoDB
  6354. start::.
  6355.  
  6356. If you start from a source RPM, then do the following:
  6357.  
  6358.      shell> rpm --rebuild MySQL-VERSION.src.rpm
  6359.  
  6360. This will make a binary RPM that you can install.
  6361.  
  6362. You can add new users using the `bin/mysql_setpermission' script if you
  6363. install the `DBI' and `Msql-Mysql-modules' Perl modules.
  6364.  
  6365. A more detailed description follows.
  6366.  
  6367. To install a source distribution, follow the steps below, then proceed
  6368. to *Note Post-installation::, for post-installation initialization and
  6369. testing:
  6370.  
  6371.   1. Pick the directory under which you want to unpack the
  6372.      distribution, and move into it.
  6373.  
  6374.   2. Obtain a distribution file from one of the sites listed in *Note
  6375.      Getting MySQL: Getting MySQL.
  6376.  
  6377.   3. If you are interested in using Berkeley DB tables with MySQL, you
  6378.      will need to obtain a patched version of the Berkeley DB source
  6379.      code.  Please read the chapter on Berkeley DB tables before
  6380.      proceeding.  *Note BDB::.
  6381.  
  6382.      MySQL source distributions are provided as compressed `tar'
  6383.      archives and have names like `mysql-VERSION.tar.gz', where
  6384.      `VERSION' is a number like 3.23.52.
  6385.  
  6386.   4. Add a user and group for `mysqld' to run as:
  6387.  
  6388.           shell> groupadd mysql
  6389.           shell> useradd -g mysql mysql
  6390.  
  6391.      These commands add the `mysql' group, and the `mysql' user.  The
  6392.      syntax for `useradd' and `groupadd' may differ slightly on
  6393.      different versions of Unix.  They may also be called `adduser' and
  6394.      `addgroup'.  You may wish to call the user and group something
  6395.      else instead of `mysql'.
  6396.  
  6397.   5. Unpack the distribution into the current directory:
  6398.           shell> gunzip < /path/to/mysql-VERSION.tar.gz | tar xvf -
  6399.  
  6400.      This command creates a directory named `mysql-VERSION'.
  6401.  
  6402.   6. Change into the top-level directory of the unpacked distribution:
  6403.  
  6404.           shell> cd mysql-VERSION
  6405.  
  6406.      Note that currently you must configure and build MySQL from this
  6407.      top-level directory.  You can not build it in a different
  6408.      directory.
  6409.  
  6410.   7. Configure the release and compile everything:
  6411.  
  6412.           shell> ./configure --prefix=/usr/local/mysql
  6413.           shell> make
  6414.  
  6415.      When you run `configure', you might want to specify some options.
  6416.      Run `./configure --help' for a list of options.  *Note `configure'
  6417.      options: configure options, discusses some of the more useful
  6418.      options.
  6419.  
  6420.      If `configure' fails, and you are going to send mail to
  6421.      <mysql@lists.mysql.com> to ask for assistance, please include any
  6422.      lines from `config.log' that you think can help solve the problem.
  6423.      Also include the last couple of lines of output from `configure'
  6424.      if `configure' aborts.  Post the bug report using the `mysqlbug'
  6425.      script.  *Note Bug reports::.
  6426.  
  6427.      If the compile fails, see *Note Compilation problems::, for help
  6428.      with a number of common problems.
  6429.  
  6430.   8. Install everything:
  6431.  
  6432.           shell> make install
  6433.  
  6434.      You might need to run this command as `root'.
  6435.  
  6436.   9. Create the MySQL grant tables (necessary only if you haven't
  6437.      installed MySQL before):
  6438.  
  6439.           shell> scripts/mysql_install_db
  6440.  
  6441.      Note that MySQL versions older than Version 3.22.10 started the
  6442.      MySQL server when you run `mysql_install_db'.  This is no longer
  6443.      true!
  6444.  
  6445.  10. Change ownership of binaries to `root' and ownership of the data
  6446.      directory to the user that you will run `mysqld' as:
  6447.  
  6448.           shell> chown -R root  /usr/local/mysql
  6449.           shell> chown -R mysql /usr/local/mysql/var
  6450.           shell> chgrp -R mysql /usr/local/mysql
  6451.  
  6452.      The first command changes the `owner' attribute of the files to the
  6453.      `root' user, the second one changes the `owner' attribute of the
  6454.      data directory to the `mysql' user, and the third one changes the
  6455.      `group' attribute to the `mysql' group.
  6456.  
  6457.  11. If you want to install support for the Perl `DBI'/`DBD' interface,
  6458.      see *Note Perl support::.
  6459.  
  6460.  12. If you would like MySQL to start automatically when you boot your
  6461.      machine, you can copy `support-files/mysql.server' to the location
  6462.      where your system has its startup files.  More information can be
  6463.      found in the `support-files/mysql.server' script itself and in
  6464.      *Note Automatic start::.
  6465.  
  6466. After everything has been installed, you should initialize and test your
  6467. distribution:
  6468.  
  6469.      shell> /usr/local/mysql/bin/safe_mysqld --user=mysql &
  6470.  
  6471. If that command fails immediately with `mysqld daemon ended' then you
  6472. can find some information in the file
  6473. `mysql-data-directory/'hostname'.err'.  The likely reason is that you
  6474. already have another `mysqld' server running.  *Note Multiple servers::.
  6475.  
  6476. *Note Post-installation::.
  6477.  
  6478. 
  6479. File: mysql.info,  Node: Applying patches,  Next: configure options,  Prev: Quick install,  Up: Installing source
  6480.  
  6481. Applying Patches
  6482. ----------------
  6483.  
  6484. Sometimes patches appear on the mailing list or are placed in the
  6485. patches area (http://www.mysql.com/Downloads/Patches) of the MySQL Web
  6486. site.
  6487.  
  6488. To apply a patch from the mailing list, save the message in which the
  6489. patch appears in a file, change into the top-level directory of your
  6490. MySQL source tree, and run these commands:
  6491.  
  6492.      shell> patch -p1 < patch-file-name
  6493.      shell> rm config.cache
  6494.      shell> make clean
  6495.  
  6496. Patches from the FTP site are distributed as plain text files or as
  6497. files compressed with `gzip'.  Apply a plain patch as shown above for
  6498. mailing list patches.  To apply a compressed patch, change into the
  6499. top-level directory of your MySQL source tree and run these commands:
  6500.  
  6501.      shell> gunzip < patch-file-name.gz | patch -p1
  6502.      shell> rm config.cache
  6503.      shell> make clean
  6504.  
  6505. After applying a patch, follow the instructions for a normal source
  6506. install, beginning with the `./configure' step.  After running the `make
  6507. install' step, restart your MySQL server.
  6508.  
  6509. You may need to bring down any currently running server before you run
  6510. `make install'.  (Use `mysqladmin shutdown' to do this.)  Some systems
  6511. do not allow you to install a new version of a program if it replaces
  6512. the version that is currently executing.
  6513.  
  6514. 
  6515. File: mysql.info,  Node: configure options,  Next: Installing source tree,  Prev: Applying patches,  Up: Installing source
  6516.  
  6517. Typical `configure' Options
  6518. ---------------------------
  6519.  
  6520. The `configure' script gives you a great deal of control over how you
  6521. configure your MySQL distribution.  Typically you do this using options
  6522. on the `configure' command line.  You can also affect `configure' using
  6523. certain environment variables.  *Note Environment variables::.  For a
  6524. list of options supported by `configure', run this command:
  6525.  
  6526.      shell> ./configure --help
  6527.  
  6528. Some of the more commonly-used `configure' options are described below:
  6529.  
  6530.    * To compile just the MySQL client libraries and client programs and
  6531.      not the server, use the `--without-server' option:
  6532.  
  6533.           shell> ./configure --without-server
  6534.  
  6535.      If you don't have a C++ compiler, `mysql' will not compile (it is
  6536.      the one client program that requires C++).  In this case, you can
  6537.      remove the code in `configure' that tests for the C++ compiler and
  6538.      then run `./configure' with the `--without-server' option. The
  6539.      compile step will still try to build `mysql', but you can ignore
  6540.      any warnings about `mysql.cc'.  (If `make' stops, try `make -k' to
  6541.      tell it to continue with the rest of the build even if errors
  6542.      occur.)
  6543.  
  6544.    * If you don't want your log files and database directories located
  6545.      under `/usr/local/var', use a `configure' command, something like
  6546.      one of these:
  6547.  
  6548.           shell> ./configure --prefix=/usr/local/mysql
  6549.           shell> ./configure --prefix=/usr/local \
  6550.                      --localstatedir=/usr/local/mysql/data
  6551.  
  6552.      The first command changes the installation prefix so that
  6553.      everything is installed under `/usr/local/mysql' rather than the
  6554.      default of `/usr/local'.  The second command preserves the default
  6555.      installation prefix, but overrides the default location for
  6556.      database directories (normally `/usr/local/var') and changes it to
  6557.      `/usr/local/mysql/data'.
  6558.  
  6559.    * If you are using Unix and you want the MySQL socket located
  6560.      somewhere other than the default location (normally in the
  6561.      directory `/tmp' or `/var/run') use a `configure' command like
  6562.      this:
  6563.  
  6564.           shell> ./configure --with-unix-socket-path=/usr/local/mysql/tmp/mysql.sock
  6565.  
  6566.      Note that the given file must be an absolute pathname!  You can
  6567.      also later change the location `mysql.sock' by using the MySQL
  6568.      option files. *Note Problems with mysql.sock::.
  6569.  
  6570.    * If you want to compile statically linked programs (for example, to
  6571.      make a binary distribution, to get more speed, or to work around
  6572.      problems with some RedHat Linux distributions), run `configure'
  6573.      like this:
  6574.  
  6575.           shell> ./configure --with-client-ldflags=-all-static \
  6576.                      --with-mysqld-ldflags=-all-static
  6577.  
  6578.    * If you are using `gcc' and don't have `libg++' or `libstdc++'
  6579.      installed, you can tell `configure' to use `gcc' as your C++
  6580.      compiler:
  6581.  
  6582.           shell> CC=gcc CXX=gcc ./configure
  6583.  
  6584.      When you use `gcc' as your C++ compiler, it will not attempt to
  6585.      link in `libg++' or `libstdc++'.
  6586.  
  6587.      Here is some common environment variables to set depending on the
  6588.      compiler you are using:
  6589.  
  6590.      gcc 2.7.2.1    CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors"
  6591.      egcs 1.0.3a    CC=gcc CXX=gcc CXXFLAGS="-O3 -felide-constructors
  6592.                    -fno-exceptions -fno-rtti"
  6593.      gcc 2.95.2     CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3
  6594.                    -mpentiumpro -felide-constructors -fno-exceptions
  6595.                    -fno-rtti"
  6596.      pgcc 2.90.29   CFLAGS="-O3 -mpentiumpro -mstack-align-double"
  6597.      or newer      CXX=gcc CXXFLAGS="-O3 -mpentiumpro
  6598.                    -mstack-align-double -felide-constructors
  6599.                    -fno-exceptions -fno-rtti"
  6600.  
  6601.      In most cases you can get a reasonably optimal MySQL binary by
  6602.      using the options from the above and adding the following options
  6603.      to the configure line:
  6604.  
  6605.           --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static
  6606.  
  6607.      The full configure line would in other words be something like the
  6608.      following for all recent gcc versions:
  6609.  
  6610.           CFLAGS="-O3 -mpentiumpro" CXX=gcc CXXFLAGS="-O3 -mpentiumpro -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static
  6611.  
  6612.      The binaries we provide on the MySQL Web site at
  6613.      `http://www.mysql.com' are all compiled with full optimization and
  6614.      should be perfect for most users.  *Note MySQL binaries::.  There
  6615.      are some things you can tweak to make an even faster binary, but
  6616.      this is only for advanced users.  *Note Compile and link options::.
  6617.  
  6618.      If the build fails and produces errors about your compiler or
  6619.      linker not being able to create the shared library
  6620.      `libmysqlclient.so.#' (`#' is a version number), you can work
  6621.      around this problem by giving the `--disable-shared' option to
  6622.      `configure'.  In this case, `configure' will not build a shared
  6623.      `libmysqlclient.so.#' library.
  6624.  
  6625.    * You can configure MySQL not to use `DEFAULT' column values for
  6626.      non-`NULL' columns (that is, columns that are not allowed to be
  6627.      `NULL').  This causes `INSERT' statements to generate an error
  6628.      unless you explicitly specify values for all columns that require a
  6629.      non-`NULL' value.  To suppress use of default values, run
  6630.      `configure' like this:
  6631.  
  6632.           shell> CXXFLAGS=-DDONT_USE_DEFAULT_FIELDS ./configure
  6633.  
  6634.    * By default, MySQL uses the ISO-8859-1 (Latin1) character set. To
  6635.      change the default set, use the `--with-charset' option:
  6636.           shell> ./configure --with-charset=CHARSET
  6637.      `CHARSET' may be one of `big5', `cp1251', `cp1257', `czech',
  6638.      `danish', `dec8', `dos', `euc_kr', `gb2312', `gbk', `german1',
  6639.      `hebrew', `hp8', `hungarian', `koi8_ru', `koi8_ukr', `latin1',
  6640.      `latin2', `sjis', `swe7', `tis620', `ujis', `usa7', or
  6641.      `win1251ukr'.  *Note Character sets::.
  6642.  
  6643.      If you want to convert characters between the server and the
  6644.      client, you should take a look at the `SET OPTION CHARACTER SET'
  6645.      command.  *Note `SET OPTION': SET OPTION.
  6646.  
  6647.      *Warning:* If you change character sets after having created any
  6648.      tables, you will have to run `myisamchk -r -q' on every table. Your
  6649.      indexes may be sorted incorrectly otherwise.  (This can happen if
  6650.      you install MySQL, create some tables, then reconfigure MySQL to
  6651.      use a different character set and reinstall it.)
  6652.  
  6653.      With the option `--with-extra-charset=LIST' you can define which
  6654.      additional character sets should be incompiled in the server.
  6655.  
  6656.      Here `LIST' is either a list of character set separated with space,
  6657.      `complex' to include all characters that can't be dynamically
  6658.      loaded or `all' to include all character sets into the binaries.
  6659.  
  6660.    * To configure MySQL with debugging code, use the `--with-debug'
  6661.      option:
  6662.           shell> ./configure --with-debug
  6663.      This causes a safe memory allocator to be included that can find
  6664.      some errors and that provides output about what is happening.
  6665.      *Note Debugging server::.
  6666.  
  6667.    * If your client programs are using threads, you need to also
  6668.      compile a thread-safe version of the MySQL client library with the
  6669.      `--enable-thread-safe-client' configure options. This will create a
  6670.      `libmysqlclient_r' library with which you should link your threaded
  6671.      applications.  *Note Threaded clients::.
  6672.  
  6673.    * Options that pertain to particular systems can be found in the
  6674.      system-specific section of this manual.  *Note Operating System
  6675.      Specific Notes::.
  6676.  
  6677. 
  6678. File: mysql.info,  Node: Installing source tree,  Next: Compilation problems,  Prev: configure options,  Up: Installing source
  6679.  
  6680. Installing from the Development Source Tree
  6681. -------------------------------------------
  6682.  
  6683. *CAUTION:* You should read this section only if you are interested in
  6684. helping us test our new code. If you just want to get MySQL up and
  6685. running on your system, you should use a standard release distribution
  6686. (either a source or binary distribution will do).
  6687.  
  6688. To obtain our most recent development source tree, use these
  6689. instructions:
  6690.  
  6691.   1. Download *BitKeeper* from
  6692.      `http://www.bitmover.com/cgi-bin/download.cgi'.  You will need
  6693.      *Bitkeeper* 2.0 or newer to access our repository.
  6694.  
  6695.   2. Follow the instructions to install it.
  6696.  
  6697.   3. After *BitKeeper* is installed, use this command if you want to
  6698.      clone the MySQL 3.23 branch:
  6699.  
  6700.           shell> bk clone bk://work.mysql.com:7000 mysql
  6701.  
  6702.      To clone the 4.0 branch, use this command instead:
  6703.  
  6704.           shell> bk clone bk://work.mysql.com:7001 mysql-4.0
  6705.  
  6706.      The initial download of the source tree may take a while,
  6707.      depending on the speed of your connection; be patient.
  6708.  
  6709.   4. You will need GNU `autoconf', `automake', `libtool', and `m4' to
  6710.      run the next set of commands.  If you get some strange error
  6711.      during this stage, check that you really have `libtool' installed!
  6712.  
  6713.           shell> cd mysql
  6714.           shell> bk -r edit
  6715.           shell> aclocal; autoheader; autoconf;  automake;
  6716.           shell> ./configure  # Add your favorite options here
  6717.           shell> make
  6718.  
  6719.      A collection of our standard configure scripts is located in the
  6720.      `BUILD/' subdirectory.  If you are lazy, you can use
  6721.      `BUILD/compile-pentium-debug'. To compile on a different
  6722.      architecture, modify the script removing flags that are
  6723.      Pentium-specific.
  6724.  
  6725.   5. When the build is done, run `make install'.  Be careful with this
  6726.      on a production machine; the command may overwrite your live
  6727.      release installation.  If you have another installation of MySQL,
  6728.      we recommand that you run `./configure' with different values for
  6729.      the `prefix', `tcp-port', and `unix-socket-path' options than
  6730.      those used for your production server.
  6731.  
  6732.   6. Play hard with your new installation and try to make the new
  6733.      features crash.  Start by running `make test'.  *Note MySQL test
  6734.      suite::.
  6735.  
  6736.   7. If you have gotten to the `make' stage and the distribution does
  6737.      not compile, please report it to <bugs@lists.mysql.com>.  If you
  6738.      have installed the latest versions of the required GNU tools, and
  6739.      they crash trying to process our configuration files, please
  6740.      report that also.  However, if you execute `aclocal' and get a
  6741.      `command not found' error or a similar problem, do not report it.
  6742.      Instead, make sure all the necessary tools are installed and that
  6743.      your `PATH' variable is set correctly so your shell can find them.
  6744.  
  6745.   8. After the initial `bk clone' operation to get the source tree, you
  6746.      should run `bk pull' periodically to get the updates.
  6747.  
  6748.   9. You can examine the change history for the tree with all the diffs
  6749.      by using `bk sccstool'.  If you see some funny diffs or code that
  6750.      you have a question about, do not hesitate to send e-mail to
  6751.      <internals@lists.mysql.com>.  Also, if you think you have a better
  6752.      idea on how to do something, send an email to the same address
  6753.      with a patch.  `bk diffs' will produce a patch for you after you
  6754.      have made changes to the source. If you do not have the time to
  6755.      code your idea, just send a description.
  6756.  
  6757.  10. *BitKeeper* has a nice help utility that you can access via `bk
  6758.      helptool'.
  6759.  
  6760.  
  6761. 
  6762. File: mysql.info,  Node: Compilation problems,  Next: MIT-pthreads,  Prev: Installing source tree,  Up: Installing source
  6763.  
  6764. Problems Compiling?
  6765. -------------------
  6766.  
  6767. All MySQL programs compile cleanly for us with no warnings on Solaris
  6768. using `gcc'.  On other systems, warnings may occur due to differences
  6769. in system include files.  See *Note MIT-pthreads:: for warnings that
  6770. may occur when using MIT-pthreads.  For other problems, check the list
  6771. below.
  6772.  
  6773. The solution to many problems involves reconfiguring.  If you do need to
  6774. reconfigure, take note of the following:
  6775.  
  6776.    * If `configure' is run after it already has been run, it may use
  6777.      information that was gathered during its previous invocation.  This
  6778.      information is stored in `config.cache'.  When `configure' starts
  6779.      up, it looks for that file and reads its contents if it exists, on
  6780.      the assumption that the information is still correct.  That
  6781.      assumption is invalid when you reconfigure.
  6782.  
  6783.    * Each time you run `configure', you must run `make' again to
  6784.      recompile.  However, you may want to remove old object files from
  6785.      previous builds first, because they were compiled using different
  6786.      configuration options.
  6787.  
  6788. To prevent old configuration information or object files from being
  6789. used, run these commands before rerunning `configure':
  6790.  
  6791.      shell> rm config.cache
  6792.      shell> make clean
  6793.  
  6794. Alternatively, you can run `make distclean'.
  6795.  
  6796. The list below describes some of the problems compiling MySQL that have
  6797. been found to occur most often:
  6798.  
  6799.    * If you get errors when compiling `sql_yacc.cc', such as the ones
  6800.      shown below, you have probably run out of memory or swap space:
  6801.  
  6802.           Internal compiler error: program cc1plus got fatal signal 11
  6803.             or
  6804.           Out of virtual memory
  6805.             or
  6806.           Virtual memory exhausted
  6807.  
  6808.      The problem is that `gcc' requires huge amounts of memory to
  6809.      compile `sql_yacc.cc' with inline functions.  Try running
  6810.      `configure' with the `--with-low-memory' option:
  6811.  
  6812.           shell> ./configure --with-low-memory
  6813.  
  6814.      This option causes `-fno-inline' to be added to the compile line
  6815.      if you are using `gcc' and `-O0' if you are using something else.
  6816.      You should try the `--with-low-memory' option even if you have so
  6817.      much memory and swap space that you think you can't possibly have
  6818.      run out.  This problem has been observed to occur even on systems
  6819.      with generous hardware configurations, and the `--with-low-memory'
  6820.      option usually fixes it.
  6821.  
  6822.    * By default, `configure' picks `c++' as the compiler name and GNU
  6823.      `c++' links with `-lg++'.  If you are using `gcc', that behavior
  6824.      can cause problems during configuration such as this:
  6825.  
  6826.           configure: error: installation or configuration problem:
  6827.           C++ compiler cannot create executables.
  6828.  
  6829.      You might also observe problems during compilation related to
  6830.      `g++', `libg++', or `libstdc++'.
  6831.  
  6832.      One cause of these problems is that you may not have `g++', or you
  6833.      may have `g++' but not `libg++', or `libstdc++'.  Take a look at
  6834.      the `config.log' file.  It should contain the exact reason why
  6835.      your c++ compiler didn't work!  To work around these problems, you
  6836.      can use `gcc' as your C++ compiler.  Try setting the environment
  6837.      variable `CXX' to `"gcc -O3"'.  For example:
  6838.  
  6839.           shell> CXX="gcc -O3" ./configure
  6840.  
  6841.      This works because `gcc' compiles C++ sources as well as `g++'
  6842.      does, but does not link in `libg++' or `libstdc++' by default.
  6843.  
  6844.      Another way to fix these problems, of course, is to install `g++',
  6845.      `libg++' and `libstdc++'.
  6846.  
  6847.    * If your compile fails with errors, such as any of the following,
  6848.      you must upgrade your version of `make' to GNU `make':
  6849.  
  6850.           making all in mit-pthreads
  6851.           make: Fatal error in reader: Makefile, line 18:
  6852.           Badly formed macro assignment
  6853.             or
  6854.           make: file `Makefile' line 18: Must be a separator (:
  6855.             or
  6856.           pthread.h: No such file or directory
  6857.  
  6858.      Solaris and FreeBSD are known to have troublesome `make' programs.
  6859.  
  6860.      GNU `make' Version 3.75 is known to work.
  6861.  
  6862.    * If you want to define flags to be used by your C or C++ compilers,
  6863.      do so by adding the flags to the `CFLAGS' and `CXXFLAGS'
  6864.      environment variables.  You can also specify the compiler names
  6865.      this way using `CC' and `CXX'.  For example:
  6866.  
  6867.           shell> CC=gcc
  6868.           shell> CFLAGS=-O3
  6869.           shell> CXX=gcc
  6870.           shell> CXXFLAGS=-O3
  6871.           shell> export CC CFLAGS CXX CXXFLAGS
  6872.  
  6873.      See *Note MySQL binaries::, for a list of flag definitions that
  6874.      have been found to be useful on various systems.
  6875.  
  6876.    * If you get an error message like this, you need to upgrade your
  6877.      `gcc' compiler:
  6878.  
  6879.           client/libmysql.c:273: parse error before `__attribute__'
  6880.  
  6881.      `gcc' 2.8.1 is known to work, but we recommend using `gcc' 2.95.2
  6882.      or `egcs' 1.0.3a instead.
  6883.  
  6884.    * If you get errors such as those shown below when compiling
  6885.      `mysqld', `configure' didn't correctly detect the type of the last
  6886.      argument to `accept()', `getsockname()', or `getpeername()':
  6887.  
  6888.           cxx: Error: mysqld.cc, line 645: In this statement, the referenced
  6889.                type of the pointer value "&length" is "unsigned long", which
  6890.                is not compatible with "int".
  6891.           new_sock = accept(sock, (struct sockaddr *)&cAddr, &length);
  6892.  
  6893.      To fix this, edit the `config.h' file (which is generated by
  6894.      `configure').  Look for these lines:
  6895.  
  6896.           /* Define as the base type of the last arg to accept */
  6897.           #define SOCKET_SIZE_TYPE XXX
  6898.  
  6899.      Change `XXX' to `size_t' or `int', depending on your operating
  6900.      system.  (Note that you will have to do this each time you run
  6901.      `configure', because `configure' regenerates `config.h'.)
  6902.  
  6903.    * The `sql_yacc.cc' file is generated from `sql_yacc.yy'.  Normally
  6904.      the build process doesn't need to create `sql_yacc.cc', because
  6905.      MySQL comes with an already-generated copy.  However, if you do
  6906.      need to re-create it, you might encounter this error:
  6907.  
  6908.           "sql_yacc.yy", line xxx fatal: default action causes potential...
  6909.  
  6910.      This is a sign that your version of `yacc' is deficient.  You
  6911.      probably need to install `bison' (the GNU version of `yacc') and
  6912.      use that instead.
  6913.  
  6914.    * If you need to debug `mysqld' or a MySQL client, run `configure'
  6915.      with the `--with-debug' option, then recompile and link your
  6916.      clients with the new client library.  *Note Debugging client::.
  6917.  
  6918. 
  6919. File: mysql.info,  Node: MIT-pthreads,  Prev: Compilation problems,  Up: Installing source
  6920.  
  6921. MIT-pthreads Notes
  6922. ------------------
  6923.  
  6924. This section describes some of the issues involved in using
  6925. MIT-pthreads.
  6926.  
  6927. Note that on Linux you should NOT use MIT-pthreads but install
  6928. LinuxThreads!  *Note Linux::.
  6929.  
  6930. If your system does not provide native thread support, you will need to
  6931. build MySQL using the MIT-pthreads package.  This includes older
  6932. FreeBSD systems, SunOS 4.x, Solaris 2.4 and earlier, and some others.
  6933. *Note Which OS::.
  6934.  
  6935.    * On most systems, you can force MIT-pthreads to be used by running
  6936.      `configure' with the `--with-mit-threads' option:
  6937.  
  6938.           shell> ./configure --with-mit-threads
  6939.  
  6940.      Building in a non-source directory is not supported when using
  6941.      MIT-pthreads, because we want to minimize our changes to this code.
  6942.  
  6943.    * The checks that determine whether or not to use MIT-pthreads occur
  6944.      only during the part of the configuration process that deals with
  6945.      the server code.  If you have configured the distribution using
  6946.      `--without-server' to build only the client code, clients will not
  6947.      know whether or not MIT-pthreads is being used and will use Unix
  6948.      socket connections by default.  Because Unix sockets do not work
  6949.      under MIT-pthreads, this means you will need to use `-h' or
  6950.      `--host' when you run client programs.
  6951.  
  6952.    * When MySQL is compiled using MIT-pthreads, system locking is
  6953.      disabled by default for performance reasons.  You can tell the
  6954.      server to use system locking with the `--use-locking' option.
  6955.  
  6956.    * Sometimes the pthread `bind()' command fails to bind to a socket
  6957.      without any error message (at least on Solaris).  The result is
  6958.      that all connections to the server fail.  For example:
  6959.  
  6960.           shell> mysqladmin version
  6961.           mysqladmin: connect to server at '' failed;
  6962.           error: 'Can't connect to mysql server on localhost (146)'
  6963.  
  6964.      The solution to this is to kill the `mysqld' server and restart it.
  6965.      This has only happened to us when we have forced the server down
  6966.      and done a restart immediately.
  6967.  
  6968.    * With MIT-pthreads, the `sleep()' system call isn't interruptible
  6969.      with `SIGINT' (break).  This is only noticeable when you run
  6970.      `mysqladmin --sleep'.  You must wait for the `sleep()' call to
  6971.      terminate before the interrupt is served and the process stops.
  6972.  
  6973.    * When linking, you may receive warning messages like these (at
  6974.      least on Solaris); they can be ignored:
  6975.  
  6976.           ld: warning: symbol `_iob' has differing sizes:
  6977.               (file /my/local/pthreads/lib/libpthread.a(findfp.o) value=0x4;
  6978.           file /usr/lib/libc.so value=0x140);
  6979.               /my/local/pthreads/lib/libpthread.a(findfp.o) definition taken
  6980.           ld: warning: symbol `__iob' has differing sizes:
  6981.               (file /my/local/pthreads/lib/libpthread.a(findfp.o) value=0x4;
  6982.           file /usr/lib/libc.so value=0x140);
  6983.               /my/local/pthreads/lib/libpthread.a(findfp.o) definition taken
  6984.  
  6985.    * Some other warnings also can be ignored:
  6986.  
  6987.           implicit declaration of function `int strtoll(...)'
  6988.           implicit declaration of function `int strtoul(...)'
  6989.  
  6990.    * We haven't gotten `readline' to work with MIT-pthreads.  (This
  6991.      isn't needed, but may be interesting for someone.)
  6992.  
  6993. 
  6994. File: mysql.info,  Node: Post-installation,  Next: Upgrade,  Prev: Installing source,  Up: Installing
  6995.  
  6996. Post-installation Setup and Testing
  6997. ===================================
  6998.  
  6999. * Menu:
  7000.  
  7001. * mysql_install_db::            Problems running `mysql_install_db'
  7002. * Starting server::             Problems starting the MySQL server
  7003. * Automatic start::             Starting and stopping MySQL automatically
  7004.  
  7005. Once you've installed MySQL (from either a binary or source
  7006. distribution), you need to initialize the grant tables, start the
  7007. server, and make sure that the server works okay.  You may also wish to
  7008. arrange for the server to be started and stopped automatically when
  7009. your system starts up and shuts down.
  7010.  
  7011. Normally you install the grant tables and start the server like this
  7012. for installation from a source distribution:
  7013.  
  7014.      shell> ./scripts/mysql_install_db
  7015.      shell> cd mysql_installation_directory
  7016.      shell> ./bin/safe_mysqld --user=mysql &
  7017.  
  7018. For a binary distribution (not RPM or pkg packages), do this:
  7019.  
  7020.      shell> cd mysql_installation_directory
  7021.      shell> ./bin/mysql_install_db
  7022.      shell> ./bin/safe_mysqld --user=mysql &
  7023.  
  7024. This creates the `mysql' database which will hold all database
  7025. privileges, the `test' database which you can use to test MySQL and
  7026. also privilege entries for the user that run `mysql_install_db' and a
  7027. `root' user (without any passwords).  This also starts the `mysqld'
  7028. server.
  7029.  
  7030. `mysql_install_db' will not overwrite any old privilege tables, so it
  7031. should be safe to run in any circumstances.  If you don't want to have
  7032. the `test' database you can remove it with `mysqladmin -u root drop
  7033. test'.
  7034.  
  7035. Testing is most easily done from the top-level directory of the MySQL
  7036. distribution.  For a binary distribution, this is your installation
  7037. directory (typically something like `/usr/local/mysql').  For a source
  7038. distribution, this is the main directory of your MySQL source tree.
  7039.  
  7040. In the commands shown below in this section and in the following
  7041. subsections, `BINDIR' is the path to the location in which programs
  7042. like `mysqladmin' and `safe_mysqld' are installed.  For a binary
  7043. distribution, this is the `bin' directory within the distribution.  For
  7044. a source distribution, `BINDIR' is probably `/usr/local/bin', unless
  7045. you specified an installation directory other than `/usr/local' when
  7046. you ran `configure'.  `EXECDIR' is the location in which the `mysqld'
  7047. server is installed.  For a binary distribution, this is the same as
  7048. `BINDIR'.  For a source distribution, `EXECDIR' is probably
  7049. `/usr/local/libexec'.
  7050.  
  7051. Testing is described in detail below:
  7052.  
  7053.   1. If necessary, start the `mysqld' server and set up the initial
  7054.      MySQL grant tables containing the privileges that determine how
  7055.      users are allowed to connect to the server.  This is normally done
  7056.      with the `mysql_install_db' script:
  7057.  
  7058.           shell> scripts/mysql_install_db
  7059.  
  7060.      Typically, `mysql_install_db' needs to be run only the first time
  7061.      you install MySQL.  Therefore, if you are upgrading an existing
  7062.      installation, you can skip this step.  (However,
  7063.      `mysql_install_db' is quite safe to use and will not update any
  7064.      tables that already exist, so if you are unsure of what to do, you
  7065.      can always run `mysql_install_db'.)
  7066.  
  7067.      `mysql_install_db' creates six tables (`user', `db', `host',
  7068.      `tables_priv', `columns_priv', and `func') in the `mysql'
  7069.      database.  A description of the initial privileges is given in
  7070.      *Note Default privileges::.  Briefly, these privileges allow the
  7071.      MySQL `root' user to do anything, and allow anybody to create or
  7072.      use databases with a name of `'test'' or starting with `'test_''.
  7073.  
  7074.      If you don't set up the grant tables, the following error will
  7075.      appear in the log file when you start the server:
  7076.  
  7077.           mysqld: Can't find file: 'host.frm'
  7078.  
  7079.      The above may also happen with a binary MySQL distribution if you
  7080.      don't start MySQL by executing exactly `./bin/safe_mysqld'!  *Note
  7081.      `safe_mysqld': safe_mysqld.
  7082.  
  7083.      You might need to run `mysql_install_db' as `root'.  However, if
  7084.      you prefer, you can run the MySQL server as an unprivileged
  7085.      (non-`root') user, provided that user can read and write files in
  7086.      the database directory.  Instructions for running MySQL as an
  7087.      unprivileged user are given in *Note Changing MySQL user: Changing
  7088.      MySQL user.
  7089.  
  7090.      If you have problems with `mysql_install_db', see *Note
  7091.      `mysql_install_db': mysql_install_db.
  7092.  
  7093.      There are some alternatives to running the `mysql_install_db'
  7094.      script as it is provided in the MySQL distribution:
  7095.  
  7096.         * You may want to edit `mysql_install_db' before running it, to
  7097.           change the initial privileges that are installed into the
  7098.           grant tables.  This is useful if you want to install MySQL on
  7099.           a lot of machines with the same privileges.  In this case you
  7100.           probably should need only to add a few extra `INSERT'
  7101.           statements to the `mysql.user' and `mysql.db' tables!
  7102.  
  7103.         * If you want to change things in the grant tables after
  7104.           installing them, you can run `mysql_install_db', then use
  7105.           `mysql -u root mysql' to connect to the grant tables as the
  7106.           MySQL `root' user and issue SQL statements to modify the
  7107.           grant tables directly.
  7108.  
  7109.         * It is possible to re-create the grant tables completely after
  7110.           they have already been created.  You might want to do this if
  7111.           you've already installed the tables but then want to
  7112.           re-create them after editing `mysql_install_db'.
  7113.  
  7114.      For more information about these alternatives, see *Note Default
  7115.      privileges::.
  7116.  
  7117.   2. Start the MySQL server like this:
  7118.  
  7119.           shell> cd mysql_installation_directory
  7120.           shell> bin/safe_mysqld &
  7121.  
  7122.      If you have problems starting the server, see *Note Starting
  7123.      server::.
  7124.  
  7125.   3. Use `mysqladmin' to verify that the server is running.  The
  7126.      following commands provide a simple test to check that the server
  7127.      is up and responding to connections:
  7128.  
  7129.           shell> BINDIR/mysqladmin version
  7130.           shell> BINDIR/mysqladmin variables
  7131.  
  7132.      The output from `mysqladmin version' varies slightly depending on
  7133.      your platform and version of MySQL, but should be similar to that
  7134.      shown below:
  7135.  
  7136.           shell> BINDIR/mysqladmin version
  7137.           mysqladmin  Ver 8.14 Distrib 3.23.32, for linux on i586
  7138.           Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  7139.           This software comes with ABSOLUTELY NO WARRANTY. This is free software,
  7140.           and you are welcome to modify and redistribute it under the GPL license
  7141.           
  7142.           Server version          3.23.32-debug
  7143.           Protocol version        10
  7144.           Connection              Localhost via Unix socket
  7145.           TCP port                3306
  7146.           UNIX socket             /tmp/mysql.sock
  7147.           Uptime:                 16 sec
  7148.           
  7149.           Threads: 1  Questions: 9  Slow queries: 0  Opens: 7  Flush tables: 2  Open tables: 0 Queries per second avg: 0.000  Memory in use: 132K  Max memory used: 16773K
  7150.  
  7151.      To get a feeling for what else you can do with `BINDIR/mysqladmin',
  7152.      invoke it with the `--help' option.
  7153.  
  7154.   4. Verify that you can shut down the server:
  7155.  
  7156.           shell> BINDIR/mysqladmin -u root shutdown
  7157.  
  7158.   5. Verify that you can restart the server.  Do this using
  7159.      `safe_mysqld' or by invoking `mysqld' directly.  For example:
  7160.  
  7161.           shell> BINDIR/safe_mysqld --log &
  7162.  
  7163.      If `safe_mysqld' fails, try running it from the MySQL installation
  7164.      directory (if you are not already there).  If that doesn't work,
  7165.      see *Note Starting server::.
  7166.  
  7167.   6. Run some simple tests to verify that the server is working.  The
  7168.      output should be similar to what is shown below:
  7169.  
  7170.           shell> BINDIR/mysqlshow
  7171.           +-----------+
  7172.           | Databases |
  7173.           +-----------+
  7174.           | mysql     |
  7175.           +-----------+
  7176.           
  7177.           shell> BINDIR/mysqlshow mysql
  7178.           Database: mysql
  7179.           +--------------+
  7180.           |    Tables    |
  7181.           +--------------+
  7182.           | columns_priv |
  7183.           | db           |
  7184.           | func         |
  7185.           | host         |
  7186.           | tables_priv  |
  7187.           | user         |
  7188.           +--------------+
  7189.           
  7190.           shell> BINDIR/mysql -e "select host,db,user from db" mysql
  7191.           +------+--------+------+
  7192.           | host | db     | user |
  7193.           +------+--------+------+
  7194.           | %    | test   |      |
  7195.           | %    | test_% |      |
  7196.           +------+--------+------+
  7197.  
  7198.      There is also a benchmark suite in the `sql-bench' directory
  7199.      (under the MySQL installation directory) that you can use to
  7200.      compare how MySQL performs on different platforms.  The
  7201.      `sql-bench/Results' directory contains the results from many runs
  7202.      against different databases and platforms.  To run all tests,
  7203.      execute these commands:
  7204.  
  7205.           shell> cd sql-bench
  7206.           shell> run-all-tests
  7207.  
  7208.      If you don't have the `sql-bench' directory, you are probably
  7209.      using an RPM for a binary distribution.  (Source distribution RPMs
  7210.      include the benchmark directory.)  In this case, you must first
  7211.      install the benchmark suite before you can use it.  Beginning with
  7212.      MySQL Version 3.22, there are benchmark RPM files named
  7213.      `mysql-bench-VERSION-i386.rpm' that contain benchmark code and
  7214.      data.
  7215.  
  7216.      If you have a source distribution, you can also run the tests in
  7217.      the `tests' subdirectory. For example, to run
  7218.      `auto_increment.tst', do this:
  7219.  
  7220.           shell> BINDIR/mysql -vvf test < ./tests/auto_increment.tst
  7221.  
  7222.      The expected results are shown in the `./tests/auto_increment.res'
  7223.      file.
  7224.  
  7225. 
  7226. File: mysql.info,  Node: mysql_install_db,  Next: Starting server,  Prev: Post-installation,  Up: Post-installation
  7227.  
  7228. Problems Running `mysql_install_db'
  7229. -----------------------------------
  7230.  
  7231. The purpose of the `mysql_install_db' script is to generate new MySQL
  7232. privilege tables.  It will not affect any other data!  It will also not
  7233. do anything if you already have MySQL privilege tables installed!
  7234.  
  7235. If you want to re-create your privilege tables, you should take down
  7236. the `mysqld' server, if it's running, and then do something like:
  7237.  
  7238.      mv mysql-data-directory/mysql mysql-data-directory/mysql-old
  7239.      mysql_install_db
  7240.  
  7241. This section lists problems you might encounter when you run
  7242. `mysql_install_db':
  7243.  
  7244. *`mysql_install_db' doesn't install the grant tables*
  7245.      You may find that `mysql_install_db' fails to install the grant
  7246.      tables and terminates after displaying the following messages:
  7247.  
  7248.           starting mysqld daemon with databases from XXXXXX
  7249.           mysql daemon ended
  7250.  
  7251.      In this case, you should examine the log file very carefully!  The
  7252.      log should be located in the directory `XXXXXX' named by the error
  7253.      message, and should indicate why `mysqld' didn't start.  If you
  7254.      don't understand what happened, include the log when you post a
  7255.      bug report using `mysqlbug'!  *Note Bug reports::.
  7256.  
  7257. *There is already a `mysqld' daemon running*
  7258.      In this case, you probably don't have to run `mysql_install_db' at
  7259.      all.  You have to run `mysql_install_db' only once, when you
  7260.      install MySQL the first time.
  7261.  
  7262. *Installing a second `mysqld' daemon doesn't work when one daemon is running*
  7263.      This can happen when you already have an existing MySQL
  7264.      installation, but want to put a new installation in a different
  7265.      place (for example, for testing, or perhaps you simply want to run
  7266.      two installations at the same time).  Generally the problem that
  7267.      occurs when you try to run the second server is that it tries to
  7268.      use the same socket and port as the old one.  In this case you
  7269.      will get the error message: `Can't start server: Bind on TCP/IP
  7270.      port: Address already in use' or `Can't start server : Bind on
  7271.      unix socket...'. *Note Installing many servers::.
  7272.  
  7273. *You don't have write access to `/tmp'*
  7274.      If you don't have write access to create a socket file at the
  7275.      default place (in `/tmp') or permission to create temporary files
  7276.      in `/tmp,' you will get an error when running `mysql_install_db'
  7277.      or when starting or using `mysqld'.
  7278.  
  7279.      You can specify a different socket and temporary directory as
  7280.      follows:
  7281.  
  7282.           shell> TMPDIR=/some_tmp_dir/
  7283.           shell> MYSQL_UNIX_PORT=/some_tmp_dir/mysqld.sock
  7284.           shell> export TMPDIR MYSQL_UNIX_PORT
  7285.  
  7286.      *Note Problems with mysql.sock::.
  7287.  
  7288.      `some_tmp_dir' should be the path to some directory for which you
  7289.      have write permission. *Note Environment variables::.
  7290.  
  7291.      After this you should be able to run `mysql_install_db' and start
  7292.      the server with these commands:
  7293.  
  7294.           shell> scripts/mysql_install_db
  7295.           shell> BINDIR/safe_mysqld &
  7296.  
  7297. *`mysqld' crashes immediately*
  7298.      If you are running RedHat Version 5.0 with a version of `glibc'
  7299.      older than 2.0.7-5, you should make sure you have installed all
  7300.      `glibc' patches!  There is a lot of information about this in the
  7301.      MySQL mail archives.  Links to the mail archives are available
  7302.      online at `http://www.mysql.com/documentation/'.  Also, see *Note
  7303.      Linux::.
  7304.  
  7305.      You can also start `mysqld' manually using the
  7306.      `--skip-grant-tables' option and add the privilege information
  7307.      yourself using `mysql':
  7308.  
  7309.           shell> BINDIR/safe_mysqld --skip-grant-tables &
  7310.           shell> BINDIR/mysql -u root mysql
  7311.  
  7312.      From `mysql', manually execute the SQL commands in
  7313.      `mysql_install_db'.  Make sure you run `mysqladmin
  7314.      flush-privileges' or `mysqladmin reload' afterward to tell the
  7315.      server to reload the grant tables.
  7316.  
  7317. 
  7318. File: mysql.info,  Node: Starting server,  Next: Automatic start,  Prev: mysql_install_db,  Up: Post-installation
  7319.  
  7320. Problems Starting the MySQL Server
  7321. ----------------------------------
  7322.  
  7323. If you are going to use tables that support transactions (BDB, InnoDB),
  7324. you should first create a my.cnf file and set startup options for the
  7325. table types you plan to use. *Note Table types::.
  7326.  
  7327. Generally, you start the `mysqld' server in one of three ways:
  7328.  
  7329.    * By invoking `mysql.server'.  This script is used primarily at
  7330.      system startup and shutdown, and is described more fully in *Note
  7331.      Automatic start::.
  7332.  
  7333.    * By invoking `safe_mysqld', which tries to determine the proper
  7334.      options for `mysqld' and then runs it with those options. *Note
  7335.      `safe_mysqld': safe_mysqld.
  7336.  
  7337.    * On NT you should install `mysqld' as a service as follows:
  7338.           bin\mysqld-nt --install               # Install MySQL as a service
  7339.  
  7340.      You can now start/stop `mysqld' as follows:
  7341.           NET START mysql
  7342.           NET STOP mysql
  7343.  
  7344.      Note that in this case you can't use any other options for
  7345.      `mysqld'!
  7346.  
  7347.      You can remove the service as follows:
  7348.           bin\mysqld-nt --remove                # remove MySQL as a service
  7349.  
  7350.    * By invoking `mysqld' directly.
  7351.  
  7352. When the `mysqld' daemon starts up, it changes directory to the data
  7353. directory.  This is where it expects to write log files and the pid
  7354. (process ID) file, and where it expects to find databases.
  7355.  
  7356. The data directory location is hardwired in when the distribution is
  7357. compiled.  However, if `mysqld' expects to find the data directory
  7358. somewhere other than where it really is on your system, it will not work
  7359. properly.  If you have problems with incorrect paths, you can find out
  7360. what options `mysqld' allows and what the default path settings are by
  7361. invoking `mysqld' with the `--help' option.  You can override the
  7362. defaults by specifying the correct pathnames as command-line arguments
  7363. to `mysqld'.  (These options can be used with `safe_mysqld' as well.)
  7364.  
  7365. Normally you should need to tell `mysqld' only the base directory under
  7366. which MySQL is installed.  You can do this with the `--basedir' option.
  7367. You can also use `--help' to check the effect of changing path options
  7368. (note that `--help' _must_ be the final option of the `mysqld'
  7369. command).  For example:
  7370.  
  7371.      shell> EXECDIR/mysqld --basedir=/usr/local --help
  7372.  
  7373. Once you determine the path settings you want, start the server without
  7374. the `--help' option.
  7375.  
  7376. Whichever method you use to start the server, if it fails to start up
  7377. correctly, check the log file to see if you can find out why.  Log files
  7378. are located in the data directory (typically `/usr/local/mysql/data'
  7379. for a binary distribution, `/usr/local/var' for a source distribution,
  7380. `\mysql\data\mysql.err' on Windows.)  Look in the data directory for
  7381. files with names of the form `host_name.err' and `host_name.log' where
  7382. `host_name' is the name of your server host.  Then check the last few
  7383. lines of these files:
  7384.  
  7385.      shell> tail host_name.err
  7386.      shell> tail host_name.log
  7387.  
  7388. If you find something like the following in the log file:
  7389.      000729 14:50:10  bdb:  Recovery function for LSN 1 27595 failed
  7390.      000729 14:50:10  bdb:  warning: ./test/t1.db: No such file or directory
  7391.      000729 14:50:10  Can't init databases
  7392.  
  7393. This means that you didn't start `mysqld' with `--bdb-no-recover' and
  7394. Berkeley DB found something wrong with its log files when it tried to
  7395. recover your databases.  To be able to continue, you should move away
  7396. the old Berkeley DB log file from the database directory to some other
  7397. place, where you can later examine these.  The log files are named
  7398. `log.0000000001', where the number will increase over time.
  7399.  
  7400. If you are running `mysqld' with BDB table support and `mysqld' core
  7401. dumps at start this could be because of some problems with the BDB
  7402. recover log.  In this case you can try starting `mysqld' with
  7403. `--bdb-no-recover'.  If this helps, then you should remove all `log.*'
  7404. files from the data directory and try starting `mysqld' again.
  7405.  
  7406. If you get the following error, it means that some other program (or
  7407. another `mysqld' server) is already using the TCP/IP port or socket
  7408. `mysqld' is trying to use:
  7409.  
  7410.      Can't start server: Bind on TCP/IP port: Address already in use
  7411.        or
  7412.      Can't start server : Bind on unix socket...
  7413.  
  7414. Use `ps' to make sure that you don't have another `mysqld' server
  7415. running.  If you can't find another server running, you can try to
  7416. execute the command `telnet your-host-name tcp-ip-port-number' and press
  7417. `RETURN' a couple of times.  If you don't get an error message like
  7418. `telnet: Unable to connect to remote host: Connection refused',
  7419. something is using the TCP/IP port `mysqld' is trying to use.  See
  7420. *Note mysql_install_db:: and *Note Multiple servers::.
  7421.  
  7422. If `mysqld' is currently running, you can find out what path settings
  7423. it is using by executing this command:
  7424.  
  7425.      shell> mysqladmin variables
  7426.  
  7427. or
  7428.  
  7429.      shell> mysqladmin -h 'your-host-name' variables
  7430.  
  7431. If `safe_mysqld' starts the server but you can't connect to it, you
  7432. should make sure you have an entry in `/etc/hosts' that looks like this:
  7433.  
  7434.      127.0.0.1       localhost
  7435.  
  7436. This problem occurs only on systems that don't have a working thread
  7437. library and for which MySQL must be configured to use MIT-pthreads.
  7438.  
  7439. If you can't get `mysqld' to start you can try to make a trace file to
  7440. find the problem. *Note Making trace files::.
  7441.  
  7442. If you are using InnoDB tables, refer to the InnoDB-specific startup
  7443. options.  *Note InnoDB start::.
  7444.  
  7445. If you are using BDB (Berkeley DB) tables, you should familiarize
  7446. yourself with the different BDB specific startup options.  *Note BDB
  7447. start::.
  7448.  
  7449. 
  7450. File: mysql.info,  Node: Automatic start,  Prev: Starting server,  Up: Post-installation
  7451.  
  7452. Starting and Stopping MySQL Automatically
  7453. -----------------------------------------
  7454.  
  7455. The `mysql.server' and `safe_mysqld' scripts can be used to start the
  7456. server automatically at system startup time. `mysql.server' can also be
  7457. used to stop the server.
  7458.  
  7459. The `mysql.server' script can be used to start or stop the server by
  7460. invoking it with `start' or `stop' arguments:
  7461.  
  7462.      shell> mysql.server start
  7463.      shell> mysql.server stop
  7464.  
  7465. `mysql.server' can be found in the `share/mysql' directory under the
  7466. MySQL installation directory or in the `support-files' directory of the
  7467. MySQL source tree.
  7468.  
  7469. Before `mysql.server' starts the server, it changes directory to the
  7470. MySQL installation directory, then invokes `safe_mysqld'.  You might
  7471. need to edit `mysql.server' if you have a binary distribution that
  7472. you've installed in a non-standard location.  Modify it to `cd' into
  7473. the proper directory before it runs `safe_mysqld'. If you want the
  7474. server to run as some specific user, add an appropriate `user' line to
  7475. the `/etc/my.cnf' file, as shown later in this section.
  7476.  
  7477. `mysql.server stop' brings down the server by sending a signal to it.
  7478. You can take down the server manually by executing `mysqladmin
  7479. shutdown'.
  7480.  
  7481. You might want to add these start and stop commands to the appropriate
  7482. places in your `/etc/rc*' files when you start using MySQL for
  7483. production applications.  Note that if you modify `mysql.server', then
  7484. upgrade MySQL sometime, your modified version will be overwritten, so
  7485. you should make a copy of your edited version that you can reinstall.
  7486.  
  7487. If your system uses `/etc/rc.local' to start external scripts, you
  7488. should append the following to it:
  7489.      /bin/sh -c 'cd /usr/local/mysql ; ./bin/safe_mysqld --user=mysql &'
  7490.  
  7491. You can also add options for `mysql.server' in a global `/etc/my.cnf'
  7492. file.  A typical `/etc/my.cnf' file might look like this:
  7493.  
  7494.      [mysqld]
  7495.      datadir=/usr/local/mysql/var
  7496.      socket=/var/tmp/mysql.sock
  7497.      port=3306
  7498.      user=mysql
  7499.      
  7500.      [mysql.server]
  7501.      basedir=/usr/local/mysql
  7502.  
  7503. The `mysql.server' script understands the following options: `datadir',
  7504. `basedir', and `pid-file'.
  7505.  
  7506. The following table shows which option groups each of the startup
  7507. scripts read from option files:
  7508.  
  7509. *Script*       *Option groups*
  7510. `mysqld'       `mysqld' and `server'
  7511. `mysql.server' `mysql.server', `mysqld', and `server'
  7512. `safe_mysqld'  `mysql.server', `mysqld', and `server'
  7513.  
  7514. *Note Option files::.
  7515.  
  7516. 
  7517. File: mysql.info,  Node: Upgrade,  Next: Operating System Specific Notes,  Prev: Post-installation,  Up: Installing
  7518.  
  7519. Upgrading/Downgrading MySQL
  7520. ===========================
  7521.  
  7522. You can always move the MySQL form and data files between different
  7523. versions on the same architecture as long as you have the same base
  7524. version of MySQL. The current base version is 3. If you change the
  7525. character set when running MySQL (which may also change the sort
  7526. order), you must run `myisamchk -r -q' on all tables.  Otherwise your
  7527. indexes may not be ordered correctly.
  7528.  
  7529. If you are afraid of new versions, you can always rename your old
  7530. `mysqld' to something like `mysqld'-'old-version-number'.  If your new
  7531. `mysqld' then does something unexpected, you can simply shut it down
  7532. and restart with your old `mysqld'!
  7533.  
  7534. When you do an upgrade you should also back up your old databases, of
  7535. course.
  7536.  
  7537. If after an upgrade, you experience problems with recompiled client
  7538. programs, like `Commands out of sync' or unexpected core dumps, you
  7539. probably have used an old header or library file when compiling your
  7540. programs.  In this case you should check the date for your `mysql.h'
  7541. file and `libmysqlclient.a' library to verify that they are from the new
  7542. MySQL distribution.  If not, please recompile your programs!
  7543.  
  7544. If you get some problems that the new `mysqld' server doesn't want to
  7545. start or that you can't connect without a password, check that you don't
  7546. have some old `my.cnf' file from your old installation!  You can check
  7547. this with: `program-name --print-defaults'.  If this outputs anything
  7548. other than the program name, you have an active `my.cnf' file that will
  7549. affect things!
  7550.  
  7551. It is a good idea to rebuild and reinstall the `Msql-Mysql-modules'
  7552. distribution whenever you install a new release of MySQL, particularly
  7553. if you notice symptoms such as all your `DBI' scripts dumping core
  7554. after you upgrade MySQL.
  7555.  
  7556. * Menu:
  7557.  
  7558. * Upgrading-from-3.22::         Upgrading from a 3.22 version to 3.23
  7559. * Upgrading-from-3.21::         Upgrading from a 3.21 version to 3.22
  7560. * Upgrading-from-3.20::         Upgrading from a 3.20 version to 3.21
  7561. * Upgrading-to-arch::           Upgrading to another architecture
  7562.  
  7563. 
  7564. File: mysql.info,  Node: Upgrading-from-3.22,  Next: Upgrading-from-3.21,  Prev: Upgrade,  Up: Upgrade
  7565.  
  7566. Upgrading From Version 3.22 to Version 3.23
  7567. -------------------------------------------
  7568.  
  7569. MySQL Version 3.23 supports tables of the new `MyISAM' type and the old
  7570. `ISAM' type.  You don't have to convert your old tables to use these
  7571. with Version 3.23.  By default, all new tables will be created with
  7572. type `MyISAM' (unless you start `mysqld' with the
  7573. `--default-table-type=isam' option). You can change an `ISAM' table to
  7574. a `MyISAM' table with `ALTER TABLE table_name TYPE=MyISAM' or the Perl
  7575. script `mysql_convert_table_format'.
  7576.  
  7577. Version 3.22 and 3.21 clients will work without any problems with a
  7578. Version 3.23 server.
  7579.  
  7580. The following lists tell what you have to watch out for when upgrading
  7581. to Version 3.23:
  7582.  
  7583.    * All tables that uses the `tis620' character set must be fixed with
  7584.      `myisamchk -r' or `REPAIR TABLE'.
  7585.  
  7586.    * If you do a `DROP DATABASE' on a symbolic linked database, both the
  7587.      link and the original database is deleted.  (This didn't happen in
  7588.      3.22 because configure didn't detect the `readlink' system call).
  7589.  
  7590.    * `OPTIMIZE TABLE' now only works for *MyISAM* tables.  For other
  7591.      table types, you can use `ALTER TABLE' to optimize the table.
  7592.      During `OPTIMIZE TABLE' the table is now locked from other threads.
  7593.  
  7594.    * The MySQL client `mysql' is now by default started with the option
  7595.      `--no-named-commands (-g)'. This option can be disabled with
  7596.      `--enable-named-commands (-G)'. This may cause incompatibility
  7597.      problems in some cases, for example in SQL scripts that use named
  7598.      commands without a semicolon!  Long format commands still work
  7599.      from the first line.
  7600.  
  7601.    * If you are using the `german' character sort order, you must repair
  7602.      all your tables with `isamchk -r', as we have made some changes in
  7603.      the sort order!
  7604.  
  7605.    * The default return type of `IF' will now depend on both arguments
  7606.      and not only the first argument.
  7607.  
  7608.    * `AUTO_INCREMENT' will not work with negative numbers. The reason
  7609.      for this is that negative numbers caused problems when wrapping
  7610.      from -1 to 0.  `AUTO_INCREMENT' is now for MyISAM tables handled
  7611.      at a lower level and is much faster than before. For MyISAM tables
  7612.      old numbers are also not reused anymore, even if you delete some
  7613.      rows from the table.
  7614.  
  7615.    * `CASE', `DELAYED', `ELSE', `END', `FULLTEXT', `INNER', `RIGHT',
  7616.      `THEN' and `WHEN' are now reserved words.
  7617.  
  7618.    * `FLOAT(X)' is now a true floating-point type and not a value with a
  7619.      fixed number of decimals.
  7620.  
  7621.    * When declaring `DECIMAL(length,dec)' the length argument no longer
  7622.      includes a place for the sign or the decimal point.
  7623.  
  7624.    * A `TIME' string must now be of one of the following formats:
  7625.      `[[[DAYS] [H]H:]MM:]SS[.fraction]' or
  7626.      `[[[[[H]H]H]H]MM]SS[.fraction]'
  7627.  
  7628.    * `LIKE' now compares strings using the same character comparison
  7629.      rules as `'=''.  If you require the old behavior, you can compile
  7630.      MySQL with the `CXXFLAGS=-DLIKE_CMP_TOUPPER' flag.
  7631.  
  7632.    * `REGEXP' is now case insensitive for normal (not binary) strings.
  7633.  
  7634.    * When you check/repair tables you should use `CHECK TABLE' or
  7635.      `myisamchk' for `MyISAM' tables (`.MYI') and `isamchk' for ISAM
  7636.      (`.ISM') tables.
  7637.  
  7638.    * If you want your `mysqldump' files to be compatible between MySQL
  7639.      Version 3.22 and Version 3.23, you should not use the `--opt' or
  7640.      `--full' option to `mysqldump'.
  7641.  
  7642.    * Check all your calls to `DATE_FORMAT()' to make sure there is a
  7643.      `%' before each format character.  (Later MySQL Version 3.22 did
  7644.      allow this syntax.)
  7645.  
  7646.    * `mysql_fetch_fields_direct' is now a function (it was a macro) and
  7647.      it returns a pointer to a `MYSQL_FIELD' instead of a `MYSQL_FIELD'.
  7648.  
  7649.    * `mysql_num_fields()' can no longer be used on a `MYSQL*' object
  7650.      (it's now a function that takes `MYSQL_RES*' as an argument. You
  7651.      should now use `mysql_field_count()' instead.
  7652.  
  7653.    * In MySQL Version 3.22, the output of `SELECT DISTINCT ...' was
  7654.      almost always sorted.  In Version 3.23, you must use `GROUP BY' or
  7655.      `ORDER BY' to obtain sorted output.
  7656.  
  7657.    * `SUM()' now returns `NULL', instead of 0, if there is no matching
  7658.      rows. This is according to ANSI SQL.
  7659.  
  7660.    * An `AND' or `OR' with `NULL' values will now return `NULL' instead
  7661.      of 0. This mostly affects queries that use `NOT' on an `AND/OR'
  7662.      expression as `NOT NULL' = `NULL'.  `LPAD()' and `RPAD()' will
  7663.      shorten the result string if it's longer than the length argument.
  7664.  
  7665. 
  7666. File: mysql.info,  Node: Upgrading-from-3.21,  Next: Upgrading-from-3.20,  Prev: Upgrading-from-3.22,  Up: Upgrade
  7667.  
  7668. Upgrading from Version 3.21 to Version 3.22
  7669. -------------------------------------------
  7670.  
  7671. Nothing that affects compatibility has changed between Version 3.21 and
  7672. 3.22.  The only pitfall is that new tables that are created with `DATE'
  7673. type columns will use the new way to store the date. You can't access
  7674. these new fields from an old version of `mysqld'.
  7675.  
  7676. After installing MySQL Version 3.22, you should start the new server
  7677. and then run the `mysql_fix_privilege_tables' script. This will add the
  7678. new privileges that you need to use the `GRANT' command.  If you forget
  7679. this, you will get `Access denied' when you try to use `ALTER TABLE',
  7680. `CREATE INDEX', or `DROP INDEX'. If your MySQL root user requires a
  7681. password, you should give this as an argument to
  7682. `mysql_fix_privilege_tables'.
  7683.  
  7684. The C API interface to `mysql_real_connect()' has changed.  If you have
  7685. an old client program that calls this function, you must place a `0' for
  7686. the new `db' argument (or recode the client to send the `db' element
  7687. for faster connections).  You must also call `mysql_init()' before
  7688. calling `mysql_real_connect()'!  This change was done to allow the new
  7689. `mysql_options()' function to save options in the `MYSQL' handler
  7690. structure.
  7691.  
  7692. The `mysqld' variable `key_buffer' has changed names to
  7693. `key_buffer_size', but you can still use the old name in your startup
  7694. files.
  7695.  
  7696. 
  7697. File: mysql.info,  Node: Upgrading-from-3.20,  Next: Upgrading-to-arch,  Prev: Upgrading-from-3.21,  Up: Upgrade
  7698.  
  7699. Upgrading from Version 3.20 to Version 3.21
  7700. -------------------------------------------
  7701.  
  7702. If you are running a version older than Version 3.20.28 and want to
  7703. switch to Version 3.21, you need to do the following:
  7704.  
  7705. You can start the `mysqld' Version 3.21 server with `safe_mysqld
  7706. --old-protocol' to use it with clients from a Version 3.20 distribution.
  7707. In this case, the new client function `mysql_errno()' will not return
  7708. any server error, only `CR_UNKNOWN_ERROR' (but it works for client
  7709. errors), and the server uses the old `password()' checking rather than
  7710. the new one.
  7711.  
  7712. If you are *NOT* using the `--old-protocol' option to `mysqld', you
  7713. will need to make the following changes:
  7714.  
  7715.    * All client code must be recompiled. If you are using ODBC, you
  7716.      must get the new *MyODBC* 2.x driver.
  7717.  
  7718.    * The script `scripts/add_long_password' must be run to convert the
  7719.      `Password' field in the `mysql.user' table to `CHAR(16)'.
  7720.  
  7721.    * All passwords must be reassigned in the `mysql.user' table (to get
  7722.      62-bit rather than 31-bit passwords).
  7723.  
  7724.    * The table format hasn't changed, so you don't have to convert any
  7725.      tables.
  7726.  
  7727. MySQL Version 3.20.28 and above can handle the new `user' table format
  7728. without affecting clients. If you have a MySQL version earlier than
  7729. Version 3.20.28, passwords will no longer work with it if you convert
  7730. the `user' table. So to be safe, you should first upgrade to at least
  7731. Version 3.20.28 and then upgrade to Version 3.21.
  7732.  
  7733. The new client code works with a 3.20.x `mysqld' server, so if you
  7734. experience problems with 3.21.x, you can use the old 3.20.x server
  7735. without having to recompile the clients again.
  7736.  
  7737. If you are not using the `--old-protocol' option to `mysqld', old
  7738. clients will issue the error message:
  7739.  
  7740.      ERROR: Protocol mismatch. Server Version = 10 Client Version = 9
  7741.  
  7742. The new Perl `DBI'/`DBD' interface also supports the old `mysqlperl'
  7743. interface.  The only change you have to make if you use `mysqlperl' is
  7744. to change the arguments to the `connect()' function.  The new arguments
  7745. are: `host', `database', `user', `password' (the `user' and `password'
  7746. arguments have changed places).  *Note Perl `DBI' Class: Perl DBI Class.
  7747.  
  7748. The following changes may affect queries in old applications:
  7749.  
  7750.    * `HAVING' must now be specified before any `ORDER BY' clause.
  7751.  
  7752.    * The parameters to `LOCATE()' have been swapped.
  7753.  
  7754.    * There are some new reserved words. The most notable are `DATE',
  7755.      `TIME', and `TIMESTAMP'.
  7756.  
  7757. 
  7758. File: mysql.info,  Node: Upgrading-to-arch,  Prev: Upgrading-from-3.20,  Up: Upgrade
  7759.  
  7760. Upgrading to Another Architecture
  7761. ---------------------------------
  7762.  
  7763. If you are using MySQL Version 3.23, you can copy the `.frm', `.MYI',
  7764. and `.MYD' files between different architectures that support the same
  7765. floating-point format.  (MySQL takes care of any byte swapping issues.)
  7766.  
  7767. The MySQL `ISAM' data and index files (`.ISD' and `*.ISM',
  7768. respectively) are architecture-dependent and in some cases
  7769. OS-dependent.  If you want to move your applications to another machine
  7770. that has a different architecture or OS than your current machine, you
  7771. should not try to move a database by simply copying the files to the
  7772. other machine. Use `mysqldump' instead.
  7773.  
  7774. By default, `mysqldump' will create a file full of SQL statements.  You
  7775. can then transfer the file to the other machine and feed it as input to
  7776. the `mysql' client.
  7777.  
  7778. Try `mysqldump --help' to see what options are available.  If you are
  7779. moving the data to a newer version of MySQL, you should use `mysqldump
  7780. --opt' with the newer version to get a fast, compact dump.
  7781.  
  7782. The easiest (although not the fastest) way to move a database between
  7783. two machines is to run the following commands on the machine on which
  7784. the database is located:
  7785.  
  7786.      shell> mysqladmin -h 'other hostname' create db_name
  7787.      shell> mysqldump --opt db_name \
  7788.              | mysql -h 'other hostname' db_name
  7789.  
  7790. If you want to copy a database from a remote machine over a slow
  7791. network, you can use:
  7792.  
  7793.      shell> mysqladmin create db_name
  7794.      shell> mysqldump -h 'other hostname' --opt --compress db_name \
  7795.              | mysql db_name
  7796.  
  7797. You can also store the result in a file, then transfer the file to the
  7798. target machine and load the file into the database there.  For example,
  7799. you can dump a database to a file on the source machine like this:
  7800.  
  7801.      shell> mysqldump --quick db_name | gzip > db_name.contents.gz
  7802.  
  7803. (The file created in this example is compressed.) Transfer the file
  7804. containing the database contents to the target machine and run these
  7805. commands there:
  7806.  
  7807.      shell> mysqladmin create db_name
  7808.      shell> gunzip < db_name.contents.gz | mysql db_name
  7809.  
  7810. You can also use `mysqldump' and `mysqlimport' to accomplish the
  7811. database transfer.  For big tables, this is much faster than simply
  7812. using `mysqldump'.  In the commands shown below, `DUMPDIR' represents
  7813. the full pathname of the directory you use to store the output from
  7814. `mysqldump'.
  7815.  
  7816. First, create the directory for the output files and dump the database:
  7817.  
  7818.      shell> mkdir DUMPDIR
  7819.      shell> mysqldump --tab=DUMPDIR db_name
  7820.  
  7821. Then transfer the files in the `DUMPDIR' directory to some corresponding
  7822. directory on the target machine and load the files into MySQL there:
  7823.  
  7824.      shell> mysqladmin create db_name           # create database
  7825.      shell> cat DUMPDIR/*.sql | mysql db_name   # create tables in database
  7826.      shell> mysqlimport db_name DUMPDIR/*.txt   # load data into tables
  7827.  
  7828. Also, don't forget to copy the `mysql' database, because that's where
  7829. the grant tables (`user', `db', `host') are stored.  You may have to
  7830. run commands as the MySQL `root' user on the new machine until you have
  7831. the `mysql' database in place.
  7832.  
  7833. After you import the `mysql' database on the new machine, execute
  7834. `mysqladmin flush-privileges' so that the server reloads the grant table
  7835. information.
  7836.  
  7837. 
  7838. File: mysql.info,  Node: Operating System Specific Notes,  Prev: Upgrade,  Up: Installing
  7839.  
  7840. Operating System Specific Notes
  7841. ===============================
  7842.  
  7843. * Menu:
  7844.  
  7845. * Linux::                       Linux Notes (All Linux Versions)
  7846. * Windows::                     Windows Notes
  7847. * Solaris::                     Solaris Notes
  7848. * BSD Notes::                   BSD Notes
  7849. * Mac OS X::                    Mac OS X Notes
  7850. * Other Unix Notes::            Other Unix Notes
  7851. * OS/2::                        OS/2 Notes
  7852. * BeOS::                        BeOS Notes
  7853. * Novell Netware::              Novell Netware Notes
  7854.  
  7855. 
  7856. File: mysql.info,  Node: Linux,  Next: Windows,  Prev: Operating System Specific Notes,  Up: Operating System Specific Notes
  7857.  
  7858. Linux Notes (All Linux Versions)
  7859. --------------------------------
  7860.  
  7861. * Menu:
  7862.  
  7863. * Binary notes-Linux::          Linux Notes for Binary Distributions
  7864. * Linux-x86::                   Linux x86 Notes
  7865. * Linux-SPARC::                 Linux SPARC Notes
  7866. * Linux-Alpha::                 Linux Alpha Notes
  7867. * Linux-PowerPC::               Linux PowerPC Notes
  7868. * Linux-MIPS::                  Linux MIPS Notes
  7869. * Linux-IA64::                  Linux IA64 Notes
  7870.  
  7871. The notes below regarding *glibc* apply only to the situation when you
  7872. build MySQL yourself. If you are running Linux on an x86 machine, in
  7873. most cases it is much better for you to just use our binary. We link
  7874. our binaries against the best patched version of *glibc* we can come up
  7875. with and with the best compiler options, in an attempt to make it
  7876. suitable for a high-load server. So if you read the text below, and are
  7877. in doubt about what you should do, try our binary first to see if it
  7878. meets your needs, and worry about your own build only after you have
  7879. discovered that our binary is not good enough. In that case, we would
  7880. appreciate a note about it, so we can build a better binary next time.
  7881. For a typical user, even for setups with a lot of concurrent
  7882. connections and/or tables exceeding 2GB limit, our binary in most cases
  7883. is the best choice.
  7884.  
  7885. MySQL uses LinuxThreads on Linux.  If you are using an old Linux
  7886. version that doesn't have `glibc2', you must install LinuxThreads
  7887. before trying to compile MySQL.   You can get LinuxThreads at
  7888. `http://www.mysql.com/Downloads/Linux'.
  7889.  
  7890. *NOTE:* We have seen some strange problems with Linux 2.2.14 and MySQL
  7891. on SMP systems; If you have a SMP system, we recommend you to upgrade
  7892. to Linux 2.4 ASAP!  Your system will be faster and more stable by doing
  7893. this!
  7894.  
  7895. Note that `glibc' versions before and including Version 2.1.1 have a
  7896. fatal bug in `pthread_mutex_timedwait' handling, which is used when you
  7897. do `INSERT DELAYED'.  We recommend you to not use `INSERT DELAYED'
  7898. before upgrading glibc.
  7899.  
  7900. If you plan to have 1000+ concurrent connections, you will need to make
  7901. some changes to LinuxThreads, recompile it, and relink MySQL against
  7902. the new `libpthread.a'.  Increase `PTHREAD_THREADS_MAX' in
  7903. `sysdeps/unix/sysv/linux/bits/local_lim.h' to 4096 and decrease
  7904. `STACK_SIZE' in `linuxthreads/internals.h' to 256 KB. The paths are
  7905. relative to the root of `glibc' Note that MySQL will not be stable with
  7906. around 600-1000 connections if `STACK_SIZE' is the default of 2 MB.
  7907.  
  7908. If you have a problem with that MySQL can't open enough files, or
  7909. connections, it may be that you haven't configured Linux to handle
  7910. enough files.
  7911.  
  7912. In Linux 2.2 and forwards, you can check the number of allocated file
  7913. handlers by doing:
  7914.  
  7915.      cat /proc/sys/fs/file-max
  7916.      cat /proc/sys/fs/dquot-max
  7917.      cat /proc/sys/fs/super-max
  7918.  
  7919. If you have more than 16M of memory, you should add something like the
  7920. following in your boot script (`/etc/rc/boot.local' on SuSE):
  7921.  
  7922.      echo 65536 > /proc/sys/fs/file-max
  7923.      echo 8192 > /proc/sys/fs/dquot-max
  7924.      echo 1024 > /proc/sys/fs/super-max
  7925.  
  7926. You can also run the above from the command line as root, but in this
  7927. case your old limits will be used next time your computer reboots.
  7928.  
  7929. You should also add /etc/my.cnf:
  7930.  
  7931.      [safe_mysqld]
  7932.      open-files-limit=8192
  7933.  
  7934. The above should allow MySQL to create up to 8192 connections + files.
  7935.  
  7936. The `STACK_SIZE' constant in LinuxThreads controls the spacing of thread
  7937. stacks in the address space.  It needs to be large enough so that there
  7938. will be plenty of room for the stack of each individual thread, but
  7939. small enough to keep the stack of some thread from running into the
  7940. global `mysqld' data.  Unfortunately, the Linux implementation of
  7941. `mmap()', as we have experimentally discovered, will successfully unmap
  7942. an already mapped region if you ask it to map out an address already in
  7943. use, zeroing out the data on the entire page, instead of returning an
  7944. error.  So, the safety of `mysqld' or any other threaded application
  7945. depends on the "gentleman" behavior of the code that creates threads.
  7946. The user must take measures to make sure the number of running threads
  7947. at any time is sufficiently low for thread stacks to stay away from the
  7948. global heap.  With `mysqld', you should enforce this "gentleman"
  7949. behavior by setting a reasonable value for the `max_connections'
  7950. variable.
  7951.  
  7952. If you build MySQL yourself and do not want to mess with patching
  7953. LinuxThreads, you should set `max_connections' to a value no higher
  7954. than 500.  It should be even less if you have a large key buffer,  large
  7955. heap tables, or some other things that make `mysqld' allocate a lot of
  7956. memory or if you are running a 2.2 kernel with a 2GB patch. If you are
  7957. using our binary or RPM version 3.23.25 or later, you can safely set
  7958. `max_connections' at 1500, assuming no large key buffer or heap tables
  7959. with lots of data.  The more you reduce `STACK_SIZE' in LinuxThreads
  7960. the more threads you can safely create.  We recommend the values between
  7961. 128K and 256K.
  7962.  
  7963. If you use a lot of concurrent connections, you may suffer from a
  7964. "feature" in the 2.2 kernel that penalizes a process for forking or
  7965. cloning a child in an attempt to prevent a fork bomb attack.  This will
  7966. cause MySQL not to scale well as you increase the number of concurrent
  7967. clients.  On single CPU systems, we have seen this manifested in a very
  7968. slow thread creation, which means it may take a long time to connect to
  7969. MySQL (as long as 1 minute), and it may take just as long to shut it
  7970. down.  On multiple CPU systems, we have observed a gradual drop in
  7971. query speed as the number of clients increases.  In the process of
  7972. trying to find a solution, we have received a kernel patch from one of
  7973. our users, who claimed it made a lot of difference for his site.  The
  7974. patch is available here
  7975. (`http://www.mysql.com/Downloads/Patches/linux-fork.patch'). We have
  7976. now done rather extensive testing of this patch on both development and
  7977. production systems.  It has significantly improved `MySQL' performance
  7978. without causing any problems and we now recommend it to our users who
  7979. are still running high-load servers on 2.2 kernels.  This issue has
  7980. been fixed in the 2.4 kernel, so if you are not satisfied with the
  7981. current performance of your system, rather than patching your 2.2
  7982. kernel, it might be easier to just upgrade to 2.4, which will also give
  7983. you a nice SMP boost in addition to fixing this fairness bug.
  7984.  
  7985. We have tested MySQL on the 2.4 kernel on a 2 CPU machine and found
  7986. MySQL scales MUCH better - there was virtually no slowdown on query
  7987. throughput all the way up to 1000 clients, and MySQL scaling factor (
  7988. computed as the ratio of maximum throughput to the throughput with one
  7989. client) was 180%.  We have observed similar results on a 4-CPU system -
  7990. virtually no slowdown as the number of clients was increased up to
  7991. 1000, and 300% scaling factor. So for a high-load SMP server we would
  7992. definitely recommend the 2.4 kernel at this point. We have discovered
  7993. that it is essential to run `mysqld' process with the highest possible
  7994. priority on the 2.4 kernel to achieve maximum performance.  This can be
  7995. done by adding `renice -20 $$' command to `safe_mysqld'. In our testing
  7996. on a 4-CPU machine, increasing the priority gave 60% increase in
  7997. throughput with 400 clients.
  7998.  
  7999. We are currently also trying to collect more info on how well `MySQL'
  8000. performs on 2.4 kernel on 4-way and 8-way systems. If you have access
  8001. such a system and have done some benchmarks, please send a mail to
  8002. <docs@mysql.com> with the results - we will include them in the manual.
  8003.  
  8004. There is another issue that greatly hurts MySQL performance, especially
  8005. on SMP systems.  The implementation of mutex in LinuxThreads in
  8006. *glibc-2.1* is very bad for programs with many threads that only hold
  8007. the mutex for a short time. On an SMP system, ironic as it is, if you
  8008. link MySQL against unmodified *LinuxThreads*, removing processors from
  8009. the machine improves MySQL performance in many cases.  We have made a
  8010. patch available for *glibc 2.1.3*, linuxthreads-2.1-patch
  8011. (http://www.mysql.com/Downloads/Linux/linuxthreads-2.1-patch) to
  8012. correct this behavior.
  8013.  
  8014. With *glibc-2.2.2* MySQL version 3.23.36 will use the adaptive mutex,
  8015. which is much better than even the patched one in *glibc-2.1.3*. Be
  8016. warned, however, that under some conditions, the current mutex code in
  8017. *glibc-2.2.2* overspins, which hurts MySQL performance. The chance of
  8018. this condition can be reduced by renicing `mysqld' process to the
  8019. highest priority. We have also been able to correct the overspin
  8020. behavior with a patch, available here
  8021. (http://www.mysql.com/Downloads/Linux/linuxthreads-2.2.2.patch). It
  8022. combines the correction of overspin, maximum number of threads, and
  8023. stack spacing all in one. You will need to apply it in the
  8024. `linuxthreads' directory with `patch -p0
  8025. </tmp/linuxthreads-2.2.2.patch'.  We hope it will be included in some
  8026. form in to the future releases of `glibc-2.2'. In any case, if you link
  8027. against `glibc-2.2.2' you still need to correct `STACK_SIZE' and
  8028. `PTHREAD_THREADS_MAX'. We hope that the defaults will be corrected to
  8029. some more acceptable values for high-load MySQL setup in the future, so
  8030. that your own build can be reduced to `./configure; make; make install'.
  8031.  
  8032. We recommend that you use the above patches to build a special static
  8033. version of `libpthread.a' and use it only for statically linking
  8034. against `MySQL'. We know that the patches are safe for `MySQL' and
  8035. significantly improve its performance, but we cannot say anything about
  8036. other applications. If you link other applications against the patched
  8037. version of the library, or build a patched shared version and install
  8038. it on your system, you are doing it at your own risk with regard to
  8039. other applications that depend on `LinuxThreads'.
  8040.  
  8041. If you experience any strange problems during the installation of
  8042. MySQL, or with some common utilties hanging, it is very likely that
  8043. they are either library or compiler related. If this is the case, using
  8044. our binary will resolve them.
  8045.  
  8046. One known problem with the binary distribution is that with older Linux
  8047. systems that use `libc' (like RedHat 4.x or Slackware), you will get
  8048. some non-fatal problems with hostname resolution.  *Note Binary
  8049. notes-Linux::.
  8050.  
  8051. When using LinuxThreads you will see a minimum of three processes
  8052. running.  These are in fact threads.  There will be one thread for the
  8053. LinuxThreads manager, one thread to handle connections, and one thread
  8054. to handle alarms and signals.
  8055.  
  8056. Note that the Linux kernel and the LinuxThread library can by default
  8057. only have 1024 threads.  This means that you can only have up to 1021
  8058. connections to MySQL on an unpatched system.  The page
  8059. `http://www.volano.com/linuxnotes.html' contains information how to go
  8060. around this limit.
  8061.  
  8062. If you see a dead `mysqld' daemon process with `ps', this usually means
  8063. that you have found a bug in MySQL or you have a corrupted table. *Note
  8064. Crashing::.
  8065.  
  8066. To get a core dump on Linux if `mysqld' dies with a SIGSEGV signal, you
  8067. can start `mysqld' with the `--core-file' option.  Note that you also
  8068. probably need to raise the `core file size' by adding `ulimit -c
  8069. 1000000' to `safe_mysqld' or starting `safe_mysqld' with
  8070. `--core-file-sizes=1000000'. *Note `safe_mysqld': safe_mysqld.
  8071.  
  8072. If you are linking your own MySQL client and get the error:
  8073.  
  8074.      ld.so.1: ./my: fatal: libmysqlclient.so.4: open failed: No such file or directory
  8075.  
  8076. When executing them, the problem can be avoided by one of the following
  8077. methods:
  8078.  
  8079.    * Link the client with the following flag (instead of `-Lpath'):
  8080.      `-Wl,r/path-libmysqlclient.so'.
  8081.  
  8082.    * Copy `libmysqclient.so' to `/usr/lib'.
  8083.  
  8084.    * Add the pathname of the directory where `libmysqlclient.so' is
  8085.      located to the `LD_RUN_PATH' environment variable before running
  8086.      your client.
  8087.  
  8088. If you are using the Fujitsu compiler `(fcc / FCC)' you will have some
  8089. problems compiling MySQL because the Linux header files are very `gcc'
  8090. oriented.
  8091.  
  8092. The following `configure' line should work with `fcc/FCC':
  8093.  
  8094.      CC=fcc CFLAGS="-O -K fast -K lib -K omitfp -Kpreex -D_GNU_SOURCE -DCONST=const -DNO_STRTOLL_PROTO" CXX=FCC CXXFLAGS="-O -K fast -K lib  -K omitfp -K preex --no_exceptions --no_rtti -D_GNU_SOURCE -DCONST=const -Dalloca=__builtin_alloca -DNO_STRTOLL_PROTO '-D_EXTERN_INLINE=static __inline'" ./configure --prefix=/usr/local/mysql --enable-assembler --with-mysqld-ldflags=-all-static --disable-shared --with-low-memory
  8095.  
  8096. 
  8097. File: mysql.info,  Node: Binary notes-Linux,  Next: Linux-x86,  Prev: Linux,  Up: Linux
  8098.  
  8099. Linux Notes for Binary Distributions
  8100. ....................................
  8101.  
  8102. MySQL needs at least Linux Version 2.0.
  8103.  
  8104. The binary release is linked with `-static', which means you do not
  8105. normally need to worry about which version of the system libraries you
  8106. have. You need not install LinuxThreads, either.  A program linked with
  8107. `-static' is slightly bigger than a dynamically linked program but also
  8108. slightly faster (3-5%).  One problem, however, is that you can't use
  8109. user-definable functions (UDFs) with a statically linked program.  If
  8110. you are going to write or use UDF functions (this is something only for
  8111. C or C++ programmers), you must compile MySQL yourself, using dynamic
  8112. linking.
  8113.  
  8114. If you are using a `libc'-based system (instead of a `glibc2' system),
  8115. you will probably get some problems with hostname resolving and
  8116. `getpwnam()' with the binary release. (This is because `glibc'
  8117. unfortunately depends on some external libraries to resolve hostnames
  8118. and `getpwent()', even when compiled with `-static'). In this case you
  8119. probably get the following error message when you run
  8120. `mysql_install_db':
  8121.  
  8122.      Sorry, the host 'xxxx' could not be looked up
  8123.  
  8124. or the following error when you try to run `mysqld' with the `--user'
  8125. option:
  8126.  
  8127.      getpwnam: No such file or directory
  8128.  
  8129. You can solve this problem in one of the following ways:
  8130.  
  8131.    * Get a MySQL source distribution (an RPM or the `tar.gz'
  8132.      distribution) and install this instead.
  8133.  
  8134.    * Execute `mysql_install_db --force'; This will not execute the
  8135.      `resolveip' test in `mysql_install_db'.  The downside is that you
  8136.      can't use host names in the grant tables; you must use IP numbers
  8137.      instead (except for `localhost').  If you are using an old MySQL
  8138.      release that doesn't support `--force', you have to remove the
  8139.      `resolveip' test in `mysql_install' with an editor.
  8140.  
  8141.    * Start `mysqld' with `su' instead of using `--user'.
  8142.  
  8143. The Linux-Intel binary and RPM releases of MySQL are configured for the
  8144. highest possible speed.  We are always trying to use the fastest stable
  8145. compiler available.
  8146.  
  8147. MySQL Perl support requires Version Perl 5.004_03 or newer.
  8148.  
  8149. On some Linux 2.2 versions, you may get the error `Resource temporarily
  8150. unavailable' when you do a lot of new connections to a `mysqld' server
  8151. over TCP/IP.
  8152.  
  8153. The problem is that Linux has a delay between when you close a TCP/IP
  8154. socket and until this is actually freed by the system.  As there is only
  8155. room for a finite number of TCP/IP slots, you will get the above error
  8156. if you try to do too many new TCP/IP connections during a small time,
  8157. like when you run the MySQL `test-connect' benchmark over TCP/IP.
  8158.  
  8159. We have mailed about this problem a couple of times to different Linux
  8160. mailing lists but have never been able to resolve this properly.
  8161.  
  8162. The only known 'fix' to this problem is to use persistent connections in
  8163. your clients or use sockets, if you are running the database server and
  8164. clients on the same machine.  We hope that the `Linux 2.4' kernel will
  8165. fix this problem in the future.
  8166.  
  8167. 
  8168. File: mysql.info,  Node: Linux-x86,  Next: Linux-SPARC,  Prev: Binary notes-Linux,  Up: Linux
  8169.  
  8170. Linux x86 Notes
  8171. ...............
  8172.  
  8173. MySQL requires `libc' Version 5.4.12 or newer. It's known to work with
  8174. `libc' 5.4.46.  `glibc' Version 2.0.6 and later should also work. There
  8175. have been some problems with the `glibc' RPMs from RedHat, so if you
  8176. have problems, check whether or not there are any updates!  The `glibc'
  8177. 2.0.7-19 and 2.0.7-29 RPMs are known to work.
  8178.  
  8179. On some older Linux distributions, `configure' may produce an error
  8180. like this:
  8181.  
  8182.      Syntax error in sched.h. Change _P to __P in the /usr/include/sched.h file.
  8183.      See the Installation chapter in the Reference Manual.
  8184.  
  8185. Just do what the error message says and add an extra underscore to the
  8186. `_P' macro that has only one underscore, then try again.
  8187.  
  8188. You may get some warnings when compiling; those shown below can be
  8189. ignored:
  8190.  
  8191.      mysqld.cc -o objs-thread/mysqld.o
  8192.      mysqld.cc: In function `void init_signals()':
  8193.      mysqld.cc:315: warning: assignment of negative value `-1' to `long unsigned int'
  8194.      mysqld.cc: In function `void * signal_hand(void *)':
  8195.      mysqld.cc:346: warning: assignment of negative value `-1' to `long unsigned int'
  8196.  
  8197. In Debian GNU/Linux, if you want MySQL to start automatically when the
  8198. system boots, do the following:
  8199.  
  8200.      shell> cp support-files/mysql.server /etc/init.d/mysql.server
  8201.      shell> /usr/sbin/update-rc.d mysql.server defaults 99
  8202.  
  8203. `mysql.server' can be found in the `share/mysql' directory under the
  8204. MySQL installation directory or in the `support-files' directory of the
  8205. MySQL source tree.
  8206.  
  8207. If `mysqld' always core dumps when it starts up, the problem may be that
  8208. you have an old `/lib/libc.a'.  Try renaming it, then remove
  8209. `sql/mysqld' and do a new `make install' and try again.  This problem
  8210. has been reported on some Slackware installations.
  8211.  
  8212. If you get the following error when linking `mysqld', it means that
  8213. your `libg++.a' is not installed correctly:
  8214.  
  8215.      /usr/lib/libc.a(putc.o): In function `_IO_putc':
  8216.      putc.o(.text+0x0): multiple definition of `_IO_putc'
  8217.  
  8218. You can avoid using `libg++.a' by running `configure' like this:
  8219.  
  8220.      shell> CXX=gcc ./configure
  8221.  
  8222. 
  8223. File: mysql.info,  Node: Linux-SPARC,  Next: Linux-Alpha,  Prev: Linux-x86,  Up: Linux
  8224.  
  8225. Linux SPARC Notes
  8226. .................
  8227.  
  8228. In some implementations, `readdir_r()' is broken.  The symptom is that
  8229. `SHOW DATABASES' always returns an empty set.  This can be fixed by
  8230. removing `HAVE_READDIR_R' from `config.h' after configuring and before
  8231. compiling.
  8232.  
  8233. Some problems will require patching your Linux installation.  The patch
  8234. can be found at
  8235. `http://www.mysql.com/Downloads/patches/Linux-sparc-2.0.30.diff'.  This
  8236. patch is against the Linux distribution `sparclinux-2.0.30.tar.gz' that
  8237. is available at `vger.rutgers.edu' (a version of Linux that was never
  8238. merged with the official 2.0.30).  You must also install LinuxThreads
  8239. Version 0.6 or newer.
  8240.  
  8241. 
  8242. File: mysql.info,  Node: Linux-Alpha,  Next: Linux-PowerPC,  Prev: Linux-SPARC,  Up: Linux
  8243.  
  8244. Linux Alpha Notes
  8245. .................
  8246.  
  8247. MySQL Version 3.23.12 is the first MySQL version that is tested on
  8248. Linux-Alpha.  If you plan to use MySQL on Linux-Alpha, you should
  8249. ensure that you have this version or newer.
  8250.  
  8251. We have tested MySQL on Alpha with our benchmarks and test suite, and
  8252. it appears to work nicely.  The main thing we haven't yet had time to
  8253. test is how things works with many concurrent users.
  8254.  
  8255. When we compiled the standard MySQL binary we are using SuSE 6.4,
  8256. kernel 2.2.13-SMP, Compaq C compiler (V6.2-504) and Compaq C++ compiler
  8257. (V6.3-005) on a Comaq DS20 machine with an Alpha EV6 processor.
  8258.  
  8259. You can find the above compilers at
  8260. `http://www.support.compaq.com/alpha-tools').  By using these compilers,
  8261. instead of gcc, we get about 9-14 % better performance with MySQL.
  8262.  
  8263. Note that the configure line optimized the binary for the current CPU;
  8264. This means you can only use our binary if you have an Alpha EV6
  8265. processor. We also compile statically to avoid library problems.
  8266.  
  8267.      CC=ccc CFLAGS="-fast" CXX=cxx CXXFLAGS="-fast -noexceptions -nortti" ./configure --prefix=/usr/local/mysql --disable-shared --with-extra-charsets=complex --enable-thread-safe-client --with-mysqld-ldflags=-non_shared --with-client-ldflags=-non_shared
  8268.  
  8269. If you want to use egcs the following configure line worked for us:
  8270.  
  8271.      CFLAGS="-O3 -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O3 -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --disable-shared
  8272.  
  8273. Some known problems when running MySQL on Linux-Alpha:
  8274.  
  8275.    * Debugging threaded applications like MySQL will not work with `gdb
  8276.      4.18'.  You should download and use gdb 5.0 instead!
  8277.  
  8278.    * If you try linking `mysqld' statically when using `gcc', the
  8279.      resulting image will core dump at start.  In other words, *DON'T*
  8280.      use `--with-mysqld-ldflags=-all-static' with `gcc'.
  8281.  
  8282. 
  8283. File: mysql.info,  Node: Linux-PowerPC,  Next: Linux-MIPS,  Prev: Linux-Alpha,  Up: Linux
  8284.  
  8285. Linux PowerPC Notes
  8286. ...................
  8287.  
  8288. MySQL should work on MkLinux with the newest `glibc' package (tested
  8289. with `glibc' 2.0.7).
  8290.  
  8291. 
  8292. File: mysql.info,  Node: Linux-MIPS,  Next: Linux-IA64,  Prev: Linux-PowerPC,  Up: Linux
  8293.  
  8294. Linux MIPS Notes
  8295. ................
  8296.  
  8297. To get MySQL to work on Qube2, (Linux Mips), you need the newest
  8298. `glibc' libraries (`glibc-2.0.7-29C2' is known to work).  You must also
  8299. use the `egcs' C++ compiler (`egcs-1.0.2-9', `gcc 2.95.2' or newer).
  8300.  
  8301. 
  8302. File: mysql.info,  Node: Linux-IA64,  Prev: Linux-MIPS,  Up: Linux
  8303.  
  8304. Linux IA64 Notes
  8305. ................
  8306.  
  8307. To get MySQL to compile on Linux Ia64, we use the following compile
  8308. line: Using `gcc-2.96':
  8309.  
  8310.      CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql "--with-comment=Official MySQL binary" --with-extra-charsets=complex
  8311.  
  8312. On Ia64 the MySQL client binaries are using shared libraries. This means
  8313. that if you install our binary distribution in some other place than
  8314. `/usr/local/mysql' you need to either modify `/etc/ld.so.conf' or add
  8315. the path to the directory where you have `libmysqlclient.so' to the
  8316. `LD_LIBRARY_PATH' environment variable.
  8317.  
  8318. *Note Link errors::.
  8319.  
  8320. 
  8321. File: mysql.info,  Node: Windows,  Next: Solaris,  Prev: Linux,  Up: Operating System Specific Notes
  8322.  
  8323. Windows Notes
  8324. -------------
  8325.  
  8326. This section describes installation and use of MySQL on Windows.  This
  8327. information is also provided in the `README' file that comes with the
  8328. MySQL Windows distribution.
  8329.  
  8330. * Menu:
  8331.  
  8332. * Win95 start::                 Starting MySQL on Win95 / Win98
  8333. * NT start::                    Starting MySQL on NT / Win2000
  8334. * Windows running::             Running MySQL on Windows
  8335. * Windows and SSH::             Connecting to a remote MySQL from Windows with SSH
  8336. * Windows symbolic links::      Splitting data across different disks under Win32
  8337. * Windows compiling::           Compiling MySQL clients on Windows.
  8338. * Windows vs Unix::             MySQL-Windows compared to Unix MySQL
  8339.  
  8340. 
  8341. File: mysql.info,  Node: Win95 start,  Next: NT start,  Prev: Windows,  Up: Windows
  8342.  
  8343. Starting MySQL on Windows 95 or Windows 98
  8344. ..........................................
  8345.  
  8346. MySQL uses TCP/IP to connect a client to a server. (This will allow any
  8347. machine on your network to connect to your MySQL server.)  Because of
  8348. this, you must install TCP/IP on your machine before starting MySQL.
  8349. You can find TCP/IP on your Windows CD-ROM.
  8350.  
  8351. Note that if you are using an old Win95 release (for example OSR2), it's
  8352. likely that you have an old Winsock package!  MySQL requires Winsock 2!
  8353. You can get the newest Winsock from `http://www.microsoft.com/'.
  8354. Win98 has the new Winsock 2 library, so the above doesn't apply for
  8355. Win98.
  8356.  
  8357. To start the `mysqld' server, you should start an MS-DOS window and
  8358. type:
  8359.  
  8360.      C:\> C:\mysql\bin\mysqld
  8361.  
  8362. This will start `mysqld' in the background without a window.
  8363.  
  8364. You can kill the MySQL server by executing:
  8365.  
  8366.      C:\> C:\mysql\bin\mysqladmin -u root shutdown
  8367.  
  8368. Note that Win95 and Win98 don't support creation of named pipes.  On
  8369. Win95 and Win98, you can only use named pipes to connect to a remote
  8370. MySQL server running on a Windows NT server host.  (The MySQL server
  8371. must also support named pipes, of course. For example, using
  8372. `mysqld-opt' under NT will not allow named pipe connections.  You
  8373. should use either `mysqld-nt' or `mysqld-max-nt'.)
  8374.  
  8375. If `mysqld' doesn't start, please check the `\mysql\data\mysql.err'
  8376. file to see if the server wrote any message there to indicate the cause
  8377. of the problem.  You can also try to start the server with `mysqld
  8378. --standalone';  In this case, you may get some useful information on
  8379. the screen that may help solve the problem.
  8380.  
  8381. The last option is to start `mysqld' with `--standalone --debug'.  In
  8382. this case `mysqld' will write a log file `C:\mysqld.trace' that should
  8383. contain the reason why `mysqld' doesn't start. *Note Making trace
  8384. files::.
  8385.  
  8386. 
  8387. File: mysql.info,  Node: NT start,  Next: Windows running,  Prev: Win95 start,  Up: Windows
  8388.  
  8389. Starting MySQL on Windows NT or Windows 2000
  8390. ............................................
  8391.  
  8392. The Win95/Win98 section also applies to MySQL on NT/Win2000, with the
  8393. following differences:
  8394.  
  8395. To get MySQL to work with TCP/IP on NT, you must install service pack 3
  8396. (or newer)!
  8397.  
  8398. Note that everything in the following that applies for NT also applies
  8399. for Win2000!
  8400.  
  8401. For NT/Win2000, the server name is `mysqld-nt'.  Normally you should
  8402. install MySQL as a service on NT/Win2000:
  8403.  
  8404.      C:\> C:\mysql\bin\mysqld-nt --install
  8405.  
  8406. or
  8407.  
  8408.      C:\> C:\mysql\bin\mysqld-max-nt --install
  8409.  
  8410. (Under Windows NT, you can actually install any of the server binaries
  8411. as a service, but only those having names that end with `-nt.exe'
  8412. provide support for named pipes.)
  8413.  
  8414. You can start and stop the MySQL service with these commands:
  8415.  
  8416.      C:\> NET START mysql
  8417.      C:\> NET STOP mysql
  8418.  
  8419. Note that in this case you can't use any other options for `mysqld-nt'!
  8420.  
  8421. You can also run `mysqld-nt' as a stand-alone program on NT if you need
  8422. to start `mysqld-nt' with any options!  If you start `mysqld-nt'
  8423. without options on NT, `mysqld-nt' tries to start itself as a service
  8424. with the default service options.  If you have stopped `mysqld-nt', you
  8425. have to start it with `NET START mysql'.
  8426.  
  8427. The service is installed with the name `MySQL'. Once installed, it must
  8428. be started using the Services Control Manager (SCM) Utility found in the
  8429. Control Panel, or by using the `NET START MySQL' command.  If any
  8430. options are desired, they must be specified as "Startup parameters" in
  8431. the SCM utility before you start the MySQL service.  Once running,
  8432. `mysqld-nt' can be stopped using `mysqladmin', or from the SCM utility
  8433. or by using the command `NET STOP MySQL'. If you use SCM to stop
  8434. `mysqld-nt', there is a strange message from SCM about `mysqld shutdown
  8435. normally'.  When run as a service, `mysqld-nt' has no access to a
  8436. console and so no messages can be seen.
  8437.  
  8438. On NT you can get the following service error messages:
  8439.  
  8440. Permission Denied      Means that it cannot find `mysqld-nt.exe'.
  8441. Cannot Register        Means that the path is incorrect.
  8442. Failed to install      Means that the service is already installed or
  8443. service.               that the Service Control Manager is in bad state.
  8444.  
  8445. If you have problems installing `mysqld-nt' as a service, try starting
  8446. it with the full path:
  8447.  
  8448.      C:\> C:\mysql\bin\mysqld-nt --install
  8449.  
  8450. If this doesn't work, you can get `mysqld-nt' to start properly by
  8451. fixing the path in the registry!
  8452.  
  8453. If you don't want to start `mysqld-nt' as a service, you can start it as
  8454. follows:
  8455.  
  8456.      C:\> C:\mysql\bin\mysqld-nt --standalone
  8457.  
  8458. or
  8459.  
  8460.      C:\> C:\mysql\bin\mysqld --standalone --debug
  8461.  
  8462. The last version gives you a debug trace in `C:\mysqld.trace'.  *Note
  8463. Making trace files::.
  8464.  
  8465. 
  8466. File: mysql.info,  Node: Windows running,  Next: Windows and SSH,  Prev: NT start,  Up: Windows
  8467.  
  8468. Running MySQL on Windows
  8469. ........................
  8470.  
  8471. MySQL supports TCP/IP on all Windows platforms and named pipes on NT.
  8472. The default is to use named pipes for local connections on NT and
  8473. TCP/IP for all other cases if the client has TCP/IP installed.  The
  8474. host name specifies which protocol is used:
  8475.  
  8476. *Host name* *Protocol*             
  8477. NULL (none)            On NT, try named pipes first; if that doesn't
  8478.                        work, use TCP/IP. On Win95/Win98, TCP/IP is used.
  8479. .                      Named pipes
  8480. localhost              TCP/IP to current host
  8481. hostname               TCP/IP
  8482.  
  8483.  
  8484. You can force a MySQL client to use named pipes by specifying the
  8485. `--pipe' option or by specifying `.' as the host name.  Use the
  8486. `--socket' option to specify the name of the pipe.
  8487.  
  8488. Note that starting from 3.23.50, named pipes are only enabled if mysqld
  8489. is started with with `--enable-named-pipe'.  This is because some users
  8490. have experienced problems shutting down the MySQL server when one uses
  8491. named pipes.
  8492.  
  8493. You can test whether or not MySQL is working by executing the following
  8494. commands:
  8495.  
  8496.      C:\> C:\mysql\bin\mysqlshow
  8497.      C:\> C:\mysql\bin\mysqlshow -u root mysql
  8498.      C:\> C:\mysql\bin\mysqladmin version status proc
  8499.      C:\> C:\mysql\bin\mysql test
  8500.  
  8501. If `mysqld' is slow to answer to connections on Win95/Win98, there is
  8502. probably a problem with your DNS.  In this case, start `mysqld' with
  8503. `--skip-name-resolve' and use only `localhost' and IP numbers in the
  8504. MySQL grant tables.  You can also avoid DNS when connecting to a
  8505. `mysqld-nt' MySQL server running on NT by using the `--pipe' argument
  8506. to specify use of named pipes.  This works for most MySQL clients.
  8507.  
  8508. There are two versions of the MySQL command-line tool:
  8509. `mysql'            Compiled on native Windows, which offers very limited
  8510.                    text editing capabilities.
  8511. `mysqlc'           Compiled with the Cygnus GNU compiler and libraries,
  8512.                    which offers `readline' editing.
  8513.  
  8514. If you want to use `mysqlc.exe', you must copy
  8515. `C:\mysql\lib\cygwinb19.dll' to your Windows system directory
  8516. (`\windows\system' or similar place).
  8517.  
  8518. The default privileges on Windows give all local users full privileges
  8519. to all databases without specifying a password.  To make MySQL more
  8520. secure, you should set a password for all users and remove the row in
  8521. the `mysql.user' table that has `Host='localhost'' and `User='''.
  8522.  
  8523. You should also add a password for the `root' user. The following
  8524. example starts by removing the anonymous user that can be used by anyone
  8525. to access the `test' database, then sets a `root' user password:
  8526.  
  8527.      C:\> C:\mysql\bin\mysql mysql
  8528.      mysql> DELETE FROM user WHERE Host='localhost' AND User='';
  8529.      mysql> QUIT
  8530.      C:\> C:\mysql\bin\mysqladmin reload
  8531.      C:\> C:\mysql\bin\mysqladmin -u root password your_password
  8532.  
  8533. After you've set the password, if you want to take down the `mysqld'
  8534. server, you can do so using this command:
  8535.  
  8536.      C:\> mysqladmin --user=root --password=your_password shutdown
  8537.  
  8538. If you are using the old shareware version of MySQL Version 3.21 under
  8539. Windows, the above command will fail with an error: `parse error near
  8540. 'SET OPTION password''.  The fix is in to upgrade to the current MySQL
  8541. version, which is freely available.
  8542.  
  8543. With the current MySQL versions you can easily add new users and change
  8544. privileges with `GRANT' and `REVOKE' commands.  *Note GRANT::.
  8545.  
  8546. 
  8547. File: mysql.info,  Node: Windows and SSH,  Next: Windows symbolic links,  Prev: Windows running,  Up: Windows
  8548.  
  8549. Connecting to a Remote MySQL from Windows with SSH
  8550. ..................................................
  8551.  
  8552. Here is a note about how to connect to get a secure connection to remote
  8553. MySQL server with SSH (by David Carlson <dcarlson@mplcomm.com>):
  8554.  
  8555.    * Install an SSH client on your Windows machine.  As a user, the
  8556.      best non-free one I've found is from `SecureCRT' from
  8557.      `http://www.vandyke.com/'.  Another option is `f-secure' from
  8558.      `http://www.f-secure.com/'. You can also find some free ones on
  8559.      *Google* at
  8560.      `http://directory.google.com/Top/Computers/Security/Products_and_Tools/Cryptography/SSH/Clients/Windows/'.
  8561.  
  8562.    * Start your Windows SSH client.  Set `Host_Name =
  8563.      yourmysqlserver_URL_or_IP'.  Set `userid=your_userid' to log in to
  8564.      your server (probably not the same as your MySQL login/password.
  8565.  
  8566.    * Set up port forwarding. Either do a remote forward (Set
  8567.      `local_port: 3306', `remote_host: yourmysqlservername_or_ip',
  8568.      `remote_port: 3306' ) or a local forward (Set `port: 3306',
  8569.      `host: localhost', `remote port: 3306').
  8570.  
  8571.    * Save everything, otherwise you'll have to redo it the next time.
  8572.  
  8573.    * Log in to your server with SSH session you just created.
  8574.  
  8575.    * On your Windows machine, start some ODBC application (such as
  8576.      Access).
  8577.  
  8578.    * Create a new file in Windows and link to MySQL using the ODBC
  8579.      driver the same way you normally do, EXCEPT type in `localhost'
  8580.      for the MySQL host server -- not `yourmysqlservername'.
  8581.  
  8582. You should now have an ODBC connection to MySQL, encrypted using SSH.
  8583.  
  8584. 
  8585. File: mysql.info,  Node: Windows symbolic links,  Next: Windows compiling,  Prev: Windows and SSH,  Up: Windows
  8586.  
  8587. Splitting Data Across Different Disks on Windows
  8588. ................................................
  8589.  
  8590. Beginning with MySQL Version 3.23.16, the `mysqld-max' and
  8591. `mysql-max-nt' servers in the MySQL distribution are compiled with the
  8592. `-DUSE_SYMDIR' option.  This allows you to put a database on different
  8593. disk by adding a symbolic link to it (in a manner similar to the way
  8594. that symbolic links work on Unix).
  8595.  
  8596. On Windows, you make a symbolic link to a database by creating a file
  8597. that contains the path to the destination directory and saving this in
  8598. the `mysql_data' directory under the filename `database.sym'.  Note
  8599. that the symbolic link will be used only if the directory
  8600. `mysql_data_dir\database' doesn't exist.
  8601.  
  8602. For example, if the MySQL data directory is `C:\mysql\data' and you
  8603. want to have database `foo' located at `D:\data\foo', you should create
  8604. the file `C:\mysql\data\foo.sym' that contains the text `D:\data\foo\'.
  8605. After that, all tables created in the database `foo' will be created
  8606. in `D:\data\foo'.
  8607.  
  8608. Note that because of the speed penalty you get when opening every table,
  8609. we have not enabled this by default even if you have compiled MySQL
  8610. with support for this. To enable symlinks you should put in your
  8611. `my.cnf' or `my.ini' file the following entry:
  8612.  
  8613.      [mysqld]
  8614.      use-symbolic-links
  8615.  
  8616. In MySQL 4.0 we will enable symlinks by default. Then you should
  8617. instead use the `skip-symlink' option if you want to disable this.
  8618.  
  8619. 
  8620. File: mysql.info,  Node: Windows compiling,  Next: Windows vs Unix,  Prev: Windows symbolic links,  Up: Windows
  8621.  
  8622. Compiling MySQL Clients on Windows
  8623. ..................................
  8624.  
  8625. In your source files, you should include `windows.h' before you include
  8626. `mysql.h':
  8627.  
  8628.      #if defined(_WIN32) || defined(_WIN64)
  8629.      #include <windows.h>
  8630.      #endif
  8631.      #include <mysql.h>
  8632.  
  8633. You can either link your code with the dynamic `libmysql.lib' library,
  8634. which is just a wrapper to load in `libmysql.dll' on demand, or link
  8635. with the static `mysqlclient.lib' library.
  8636.  
  8637. Note that as the mysqlclient libraries are compiled as threaded
  8638. libraries, you should also compile your code to be multi-threaded!
  8639.  
  8640. 
  8641. File: mysql.info,  Node: Windows vs Unix,  Prev: Windows compiling,  Up: Windows
  8642.  
  8643. MySQL-Windows Compared to Unix MySQL
  8644. ....................................
  8645.  
  8646. MySQL-Windows has by now proven itself to be very stable. This version
  8647. of MySQL has the same features as the corresponding Unix version with
  8648. the following exceptions:
  8649.  
  8650. *Win95 and threads*
  8651.      Win95 leaks about 200 bytes of main memory for each thread
  8652.      creation.  Each connection in MySQL creates a new thread, so you
  8653.      shouldn't run `mysqld' for an extended time on Win95 if your
  8654.      server handles many connections!  WinNT and Win98 don't suffer
  8655.      from this bug.
  8656.  
  8657. *Concurrent reads*
  8658.      MySQL depends on the `pread()' and `pwrite()' calls to be able to
  8659.      mix `INSERT' and `SELECT'.  Currently we use mutexes to emulate
  8660.      `pread()'/`pwrite()'.  We will, in the long run, replace the file
  8661.      level interface with a virtual interface so that we can use the
  8662.      `readfile()'/`writefile()' interface on NT to get more speed.  The
  8663.      current implementation limits the number of open files MySQL can
  8664.      use to 1024, which means that you will not be able to run as many
  8665.      concurrent threads on NT as on Unix.
  8666.  
  8667. *Blocking read*
  8668.      MySQL uses a blocking read for each connection.  This means that:
  8669.  
  8670.         * A connection will not be disconnected automatically after 8
  8671.           hours, as happens with the Unix version of MySQL.
  8672.  
  8673.         * If a connection hangs, it's impossible to break it without
  8674.           killing MySQL.
  8675.  
  8676.         * `mysqladmin kill' will not work on a sleeping connection.
  8677.  
  8678.         * `mysqladmin shutdown' can't abort as long as there are
  8679.           sleeping connections.
  8680.  
  8681.      We plan to fix this problem when our Windows developers have
  8682.      figured out a nice workaround.
  8683.  
  8684. *UDF functions*
  8685.      For the moment, MySQL-Windows does not support user-definable
  8686.      functions.
  8687.  
  8688. *`DROP DATABASE'*
  8689.      You can't drop a database that is in use by some thread.
  8690.  
  8691. *Killing MySQL from the task manager*
  8692.      You can't kill MySQL from the task manager or with the shutdown
  8693.      utility in Win95.  You must take it down with `mysqladmin
  8694.      shutdown'.
  8695.  
  8696. *Case-insensitive names*
  8697.      Filenames are case insensitive on Windows, so database and table
  8698.      names are also case insensitive in MySQL for Windows.  The only
  8699.      restriction is that database and table names must be specified
  8700.      using the same case throughout a given statement.  *Note Name case
  8701.      sensitivity::.
  8702.  
  8703. *The `\' directory character*
  8704.      Pathname components in Win95 are separated by the `\' character,
  8705.      which is also the escape character in MySQL.  If you are using
  8706.      `LOAD DATA INFILE' or `SELECT ... INTO OUTFILE', you must double
  8707.      the `\' character:
  8708.  
  8709.           mysql> LOAD DATA INFILE "C:\\tmp\\skr.txt" INTO TABLE skr;
  8710.           mysql> SELECT * INTO OUTFILE 'C:\\tmp\\skr.txt' FROM skr;
  8711.  
  8712.      Alternatively, use Unix style filenames with `/' characters:
  8713.  
  8714.           mysql> LOAD DATA INFILE "C:/tmp/skr.txt" INTO TABLE skr;
  8715.           mysql> SELECT * INTO OUTFILE 'C:/tmp/skr.txt' FROM skr;
  8716.  
  8717. *`Can't open named pipe' error*
  8718.      If you use a MySQL 3.22 version on NT with the newest mysql-clients
  8719.      you will get the following error:
  8720.  
  8721.           error 2017: can't open named pipe to host: . pipe...
  8722.  
  8723.      This is because the release version of MySQL uses named pipes on NT
  8724.      by default.  You can avoid this error by using the
  8725.      `--host=localhost' option to the new MySQL clients or create an
  8726.      option file `C:\my.cnf' that contains the following information:
  8727.  
  8728.           [client]
  8729.           host = localhost
  8730.  
  8731.      Starting from 3.23.50, named pipes are only enabled if mysqld is
  8732.      started with `--enable-named-pipe'.
  8733.  
  8734. *`Access denied for user' error*
  8735.      If you get the error `Access denied for user: 'some-user@unknown'
  8736.      to database 'mysql'' when accessing a MySQL server on the same
  8737.      machine, this means that MySQL can't resolve your host name
  8738.      properly.
  8739.  
  8740.      To fix this, you should create a file `\windows\hosts' with the
  8741.      following information:
  8742.  
  8743.           127.0.0.1       localhost
  8744.  
  8745. *`ALTER TABLE'*
  8746.      While you are executing an `ALTER TABLE' statement, the table is
  8747.      locked from usage by other threads.  This has to do with the fact
  8748.      that on Windows, you can't delete a file that is in use by another
  8749.      threads.  (In the future, we may find some way to work around this
  8750.      problem.)
  8751.  
  8752. *`DROP TABLE' on a table that is in use by a `MERGE' table will not work*
  8753.      The `MERGE' handler does its table mapping hidden from MySQL.
  8754.      Because Windows doesn't allow you to drop files that are open, you
  8755.      first must flush all `MERGE' tables (with `FLUSH TABLES') or drop
  8756.      the `MERGE' table before dropping the table.  We will fix this at
  8757.      the same time we introduce `VIEW's.
  8758.  
  8759. Here are some open issues for anyone who might want to help us with the
  8760. Windows release:
  8761.  
  8762.    * Make a single-user `MYSQL.DLL' server.  This should include
  8763.      everything in a standard MySQL server, except thread creation.
  8764.      This will make MySQL much easier to use in applications that don't
  8765.      need a true client/server and don't need to access the server from
  8766.      other hosts.
  8767.  
  8768.    * Add some nice start and shutdown icons to the MySQL installation.
  8769.  
  8770.    * Create a tool to manage registry entries for the MySQL startup
  8771.      options.  The registry entry reading is already coded into
  8772.      `mysqld.cc', but it should be recoded to be more parameter
  8773.      oriented.  The tool should also be able to update the `C:\my.cnf'
  8774.      option file if the user prefers to use that instead of the
  8775.      registry.
  8776.  
  8777.    * When registering `mysqld' as a service with `--install' (on NT) it
  8778.      would be nice if you could also add default options on the command
  8779.      line.  For the moment, the workaround is to list the parameters in
  8780.      the `C:\my.cnf' file instead.
  8781.  
  8782.    * It would be real nice to be able to kill `mysqld' from the task
  8783.      manager.  For the moment, you must use `mysqladmin shutdown'.
  8784.  
  8785.    * Port `readline' to Windows for use in the `mysql' command line
  8786.      tool.
  8787.  
  8788.    * GUI versions of the standard MySQL clients (`mysql', `mysqlshow',
  8789.      `mysqladmin', and `mysqldump') would be nice.
  8790.  
  8791.    * It would be nice if the socket read and write functions in `net.c'
  8792.      were interruptible. This would make it possible to kill open
  8793.      threads with `mysqladmin kill' on Windows.
  8794.  
  8795.    * `mysqld' always starts in the "C" locale and not in the default
  8796.      locale.  We would like to have `mysqld' use the current locale for
  8797.      the sort order.
  8798.  
  8799.    * Implement UDF functions with `.DLL's.
  8800.  
  8801.    * Add macros to use the faster thread-safe increment/decrement
  8802.      methods provided by Windows.
  8803.  
  8804.  
  8805. Other Windows-specific issues are described in the `README' file that
  8806. comes with the MySQL-Windows distribution.
  8807.  
  8808. 
  8809. File: mysql.info,  Node: Solaris,  Next: BSD Notes,  Prev: Windows,  Up: Operating System Specific Notes
  8810.  
  8811. Solaris Notes
  8812. -------------
  8813.  
  8814. On Solaris, you may run into trouble even before you get the MySQL
  8815. distribution unpacked!  Solaris `tar' can't handle long file names, so
  8816. you may see an error like this when you unpack MySQL:
  8817.  
  8818.      x mysql-3.22.12-beta/bench/Results/ATIS-mysql_odbc-NT_4.0-cmp-db2,informix,ms-sql,mysql,oracle,solid,sybase, 0 bytes, 0 tape blocks
  8819.      tar: directory checksum error
  8820.  
  8821. In this case, you must use GNU `tar' (`gtar') to unpack the
  8822. distribution.  You can find a precompiled copy for Solaris at
  8823. `http://www.mysql.com/Downloads/'.
  8824.  
  8825. Sun native threads work only on Solaris 2.5 and higher.  For Version
  8826. 2.4 and earlier, MySQL will automatically use MIT-pthreads.  *Note
  8827. MIT-pthreads::.
  8828.  
  8829. If you get the following error from configure:
  8830.  
  8831.      checking for restartable system calls... configure: error can not run test
  8832.      programs while cross compiling
  8833.  
  8834. This means that you have something wrong with your compiler
  8835. installation!  In this case you should upgrade your compiler to a newer
  8836. version.  You may also be able to solve this problem by inserting the
  8837. following row into the `config.cache' file:
  8838.  
  8839.      ac_cv_sys_restartable_syscalls=${ac_cv_sys_restartable_syscalls='no'}
  8840.  
  8841. If you are using Solaris on a SPARC, the recommended compiler is `gcc'
  8842. 2.95.2.  You can find this at `http://gcc.gnu.org/'.  Note that `egcs'
  8843. 1.1.1 and `gcc' 2.8.1 don't work reliably on SPARC!
  8844.  
  8845. The recommended `configure' line when using `gcc' 2.95.2 is:
  8846.  
  8847.      CC=gcc CFLAGS="-O3" \
  8848.      CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" \
  8849.      ./configure --prefix=/usr/local/mysql --with-low-memory --enable-assembler
  8850.  
  8851. If you have a ultra sparc, you can get 4 % more performance by adding
  8852. "-mcpu=v8 -Wa,-xarch=v8plusa" to CFLAGS and CXXFLAGS.
  8853.  
  8854. If you have Sun Workshop (Fortre) 5.3 (or newer) compiler, you can run
  8855. `configure' like this:
  8856.  
  8857.      CC=cc CFLAGS="-Xa -fast -xO4 -native -xstrconst -mt" \
  8858.      CXX=CC CXXFLAGS="-noex -xO4 -mt" \
  8859.      ./configure --prefix=/usr/local/mysql --enable-assembler
  8860.  
  8861. In the MySQL benchmarks, we got a 6 % speedup on an Ultrasparc when
  8862. using Sun Workshop 5.3 compared to using gcc with -mcpu flags.
  8863.  
  8864. If you get a problem with `fdatasync' or `sched_yield', you can fix
  8865. this by adding `LIBS=-lrt' to the configure line
  8866.  
  8867. The following paragraph is only relevant for older compilers than
  8868. WorkShop 5.3:
  8869.  
  8870. You may also have to edit the `configure' script to change this line:
  8871.  
  8872.      #if !defined(__STDC__) || __STDC__ != 1
  8873.  
  8874. to this:
  8875.  
  8876.      #if !defined(__STDC__)
  8877.  
  8878. If you turn on `__STDC__' with the `-Xc' option, the Sun compiler can't
  8879. compile with the Solaris `pthread.h' header file.  This is a Sun bug
  8880. (broken compiler or broken include file).
  8881.  
  8882. If `mysqld' issues the error message shown below when you run it, you
  8883. have tried to compile MySQL with the Sun compiler without enabling the
  8884. multi-thread option (`-mt'):
  8885.  
  8886.      libc internal error: _rmutex_unlock: rmutex not held
  8887.  
  8888. Add `-mt' to `CFLAGS' and `CXXFLAGS' and try again.
  8889.  
  8890. If you get the following error when compiling MySQL with `gcc', it
  8891. means that your `gcc' is not configured for your version of Solaris:
  8892.  
  8893.      shell> gcc -O3 -g -O2 -DDBUG_OFF  -o thr_alarm ...
  8894.      ./thr_alarm.c: In function `signal_hand':
  8895.      ./thr_alarm.c:556: too many arguments to function `sigwait'
  8896.  
  8897. The proper thing to do in this case is to get the newest version of
  8898. `gcc' and compile it with your current `gcc' compiler!  At least for
  8899. Solaris 2.5, almost all binary versions of `gcc' have old, unusable
  8900. include files that will break all programs that use threads (and
  8901. possibly other programs)!
  8902.  
  8903. Solaris doesn't provide static versions of all system libraries
  8904. (`libpthreads' and `libdl'), so you can't compile MySQL with
  8905. `--static'.  If you try to do so, you will get the error:
  8906.  
  8907.      ld: fatal: library -ldl: not found
  8908.      
  8909.      or
  8910.      
  8911.      undefined reference to `dlopen'
  8912.      
  8913.      or
  8914.      
  8915.      cannot find -lrt
  8916.  
  8917. If too many processes try to connect very rapidly to `mysqld', you will
  8918. see this error in the MySQL log:
  8919.  
  8920.      Error in accept: Protocol error
  8921.  
  8922. You might try starting the server with the `--set-variable back_log=50'
  8923. option as a workaround for this. *Note Command-line options::.
  8924.  
  8925. If you are linking your own MySQL client, you might get the following
  8926. error when you try to execute it:
  8927.  
  8928.      ld.so.1: ./my: fatal: libmysqlclient.so.#: open failed: No such file or directory
  8929.  
  8930. The problem can be avoided by one of the following methods:
  8931.  
  8932.    * Link the client with the following flag (instead of `-Lpath'):
  8933.      `-Wl,r/full-path-to-libmysqlclient.so'.
  8934.  
  8935.    * Copy `libmysqclient.so' to `/usr/lib'.
  8936.  
  8937.    * Add the pathname of the directory where `libmysqlclient.so' is
  8938.      located to the `LD_RUN_PATH' environment variable before running
  8939.      your client.
  8940.  
  8941. When using the `--with-libwrap' configure option, you must also include
  8942. the libraries that `libwrap.a' needs:
  8943.  
  8944.      --with-libwrap="/opt/NUtcpwrapper-7.6/lib/libwrap.a -lnsl -lsocket
  8945.  
  8946. If you have problems with configure trying to link with `-lz' and you
  8947. don't have `zlib' installed, you have two options:
  8948.  
  8949.    * If you want to be able to use the compressed communication
  8950.      protocol, you need to get and install zlib from ftp.gnu.org.
  8951.  
  8952.    * Configure with `--with-named-z-libs=no'.
  8953.  
  8954. If you are using gcc and have problems with loading `UDF' functions
  8955. into MySQL, try adding `-lgcc' to the link line for the `UDF' function.
  8956.  
  8957. If you would like MySQL to start automatically, you can copy
  8958. `support-files/mysql.server' to `/etc/init.d' and create a symbolic
  8959. link to it named `/etc/rc3.d/S99mysql.server'.
  8960.  
  8961. * Menu:
  8962.  
  8963. * Solaris 2.7::                 Solaris 2.7/2.8 Notes
  8964. * Solaris x86::                 Solaris x86 Notes
  8965.  
  8966. 
  8967. File: mysql.info,  Node: Solaris 2.7,  Next: Solaris x86,  Prev: Solaris,  Up: Solaris
  8968.  
  8969. Solaris 2.7/2.8 Notes
  8970. .....................
  8971.  
  8972. You can normally use a Solaris 2.6 binary on Solaris 2.7 and 2.8.  Most
  8973. of the Solaris 2.6 issues also apply for Solaris 2.7 and 2.8.
  8974.  
  8975. Note that MySQL Version 3.23.4 and above should be able to autodetect
  8976. new versions of Solaris and enable workarounds for the following
  8977. problems!
  8978.  
  8979. Solaris 2.7 / 2.8 has some bugs in the include files.  You may see the
  8980. following error when you use `gcc':
  8981.  
  8982.      /usr/include/widec.h:42: warning: `getwc' redefined
  8983.      /usr/include/wchar.h:326: warning: this is the location of the previous
  8984.      definition
  8985.  
  8986. If this occurs, you can do the following to fix the problem:
  8987.  
  8988. Copy `/usr/include/widec.h' to `.../lib/gcc-lib/os/gcc-version/include'
  8989. and change line 41 from:
  8990.  
  8991.      #if     !defined(lint) && !defined(__lint)
  8992.      
  8993.      to
  8994.      
  8995.      #if     !defined(lint) && !defined(__lint) && !defined(getwc)
  8996.  
  8997. Alternatively, you can edit `/usr/include/widec.h' directly.  Either
  8998. way, after you make the fix, you should remove `config.cache' and run
  8999. `configure' again!
  9000.  
  9001. If you get errors like this when you run `make', it's because
  9002. `configure' didn't detect the `curses.h' file (probably because of the
  9003. error in `/usr/include/widec.h'):
  9004.  
  9005.      In file included from mysql.cc:50:
  9006.      /usr/include/term.h:1060: syntax error before `,'
  9007.      /usr/include/term.h:1081: syntax error before `;'
  9008.  
  9009. The solution to this is to do one of the following:
  9010.  
  9011.    * Configure with `CFLAGS=-DHAVE_CURSES_H CXXFLAGS=-DHAVE_CURSES_H
  9012.      ./configure'.
  9013.  
  9014.    * Edit `/usr/include/widec.h' as indicted above and rerun configure.
  9015.  
  9016.    * Remove the `#define HAVE_TERM' line from `config.h' file and run
  9017.      `make' again.
  9018.  
  9019. If you get a problem that your linker can't find `-lz' when linking
  9020. your client program, the problem is probably that your `libz.so' file is
  9021. installed in `/usr/local/lib'.  You can fix this by one of the
  9022. following methods:
  9023.  
  9024.    * Add `/usr/local/lib' to `LD_LIBRARY_PATH'.
  9025.  
  9026.    * Add a link to `libz.so' from `/lib'.
  9027.  
  9028.    * If you are using Solaris 8, you can install the optional zlib from
  9029.      your Solaris 8 CD distribution.
  9030.  
  9031.    * Configure MySQL with the `--with-named-z-libs=no' option.
  9032.  
  9033. 
  9034. File: mysql.info,  Node: Solaris x86,  Prev: Solaris 2.7,  Up: Solaris
  9035.  
  9036. Solaris x86 Notes
  9037. .................
  9038.  
  9039. On Solaris 2.8 on x86, `mysqld' will core dump if you run 'strip' in.
  9040.  
  9041. If you are using `gcc' or `egcs' on Solaris x86 and you experience
  9042. problems with core dumps under load, you should use the following
  9043. `configure' command:
  9044.  
  9045.      CC=gcc CFLAGS="-O3 -fomit-frame-pointer -DHAVE_CURSES_H" \
  9046.      CXX=gcc \
  9047.      CXXFLAGS="-O3 -fomit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti -DHAVE_CURSES_H" \
  9048.      ./configure --prefix=/usr/local/mysql
  9049.  
  9050. This will avoid problems with the `libstdc++' library and with C++
  9051. exceptions.
  9052.  
  9053. If this doesn't help, you should compile a debug version and run it
  9054. with a trace file or under `gdb'.  *Note Using gdb on mysqld::.
  9055.  
  9056. 
  9057. File: mysql.info,  Node: BSD Notes,  Next: Mac OS X,  Prev: Solaris,  Up: Operating System Specific Notes
  9058.  
  9059. BSD Notes
  9060. ---------
  9061.  
  9062. * Menu:
  9063.  
  9064. * FreeBSD::                     FreeBSD Notes
  9065. * NetBSD::                      NetBSD notes
  9066. * OpenBSD::                     OpenBSD Notes
  9067. * OpenBSD 2.5::                 OpenBSD 2.5 Notes
  9068. * OpenBSD 2.8::                 OpenBSD 2.8 Notes
  9069. * BSDI::                        BSD/OS Notes
  9070. * BSDI2::                       BSD/OS Version 2.x Notes
  9071. * BSDI3::                       BSD/OS Version 3.x Notes
  9072. * BSDI4::                       BSD/OS Version 4.x Notes
  9073.  
  9074. 
  9075. File: mysql.info,  Node: FreeBSD,  Next: NetBSD,  Prev: BSD Notes,  Up: BSD Notes
  9076.  
  9077. FreeBSD Notes
  9078. .............
  9079.  
  9080. FreeBSD 3.x is recommended for running MySQL since the thread package
  9081. is much more integrated.
  9082.  
  9083. The easiest and therefor the preferred way to install is to use the
  9084. mysql-server and mysql-client ports available on
  9085. `http://www.freebsd.org'.
  9086.  
  9087. Using these gives you:
  9088.    * A working MySQL with all optimizations known to work on your
  9089.      version of FreeBSD enabled.
  9090.  
  9091.    * Automatic configuration and build.
  9092.  
  9093.    * Startup scripts installed in /usr/local/etc/rc.d.
  9094.  
  9095.    * Ability to see which files that are installed with pkg_info -L.
  9096.      And to remove them all with pkg_delete if you no longer want MySQL
  9097.      on that machine.
  9098.  
  9099. It is recommended you use MIT-pthreads on FreeBSD 2.x and native
  9100. threads on Versions 3 and up. It is possible to run with  native
  9101. threads on some late 2.2.x versions but you may encounter problems
  9102. shutting down `mysqld'.
  9103.  
  9104. The MySQL `Makefile's require GNU make (`gmake') to work.  If you want
  9105. to compile MySQL you need to install GNU `make' first.
  9106.  
  9107. Be sure to have your name resolver setup correct.  Otherwise you may
  9108. experience resolver delays or failures when connecting to `mysqld'.
  9109.  
  9110. Make sure that the `localhost' entry in the `/etc/hosts' file is
  9111. correct (otherwise you will have problems connecting to the database).
  9112. The `/etc/hosts' file should start with a line:
  9113.  
  9114.      127.0.0.1       localhost localhost.your.domain
  9115.  
  9116. If you notice that `configure' will use MIT-pthreads, you should read
  9117. the MIT-pthreads notes.  *Note MIT-pthreads::.
  9118.  
  9119. If you get an error from `make install' that it can't find
  9120. `/usr/include/pthreads', `configure' didn't detect that you need
  9121. MIT-pthreads.  This is fixed by executing these commands:
  9122.  
  9123.      shell> rm config.cache
  9124.      shell> ./configure --with-mit-threads
  9125.  
  9126. FreeBSD is also known to have a very low default file handle limit.
  9127. *Note Not enough file handles::.  Uncomment the ulimit -n section in
  9128. safe_mysqld or raise the limits for the `mysqld' user in /etc/login.conf
  9129. (and rebuild it with cap_mkdb /etc/login.conf).  Also be sure you set
  9130. the appropriate class for this user in the password file if you are not
  9131. using the default (use: chpass mysqld-user-name).  *Note `safe_mysqld':
  9132. safe_mysqld.
  9133.  
  9134. If you get problems with the current date in MySQL, setting the `TZ'
  9135. variable will probably help.  *Note Environment variables::.
  9136.  
  9137. To get a secure and stable system you should only use FreeBSD kernels
  9138. that are marked `-STABLE'.
  9139.  
  9140. 
  9141. File: mysql.info,  Node: NetBSD,  Next: OpenBSD,  Prev: FreeBSD,  Up: BSD Notes
  9142.  
  9143. NetBSD notes
  9144. ............
  9145.  
  9146. To compile on NetBSD you need GNU `make'.  Otherwise the compile will
  9147. crash when `make' tries to run `lint' on C++ files.
  9148.  
  9149. 
  9150. File: mysql.info,  Node: OpenBSD,  Next: OpenBSD 2.5,  Prev: NetBSD,  Up: BSD Notes
  9151.  
  9152. OpenBSD Notes
  9153. .............
  9154.  
  9155. * Menu:
  9156.  
  9157. * OpenBSD 2.5::                 OpenBSD 2.5 Notes
  9158. * OpenBSD 2.8::                 OpenBSD 2.8 Notes
  9159.  
  9160. 
  9161. File: mysql.info,  Node: OpenBSD 2.5,  Next: OpenBSD 2.8,  Prev: OpenBSD,  Up: BSD Notes
  9162.  
  9163. OpenBSD 2.5 Notes
  9164. .................
  9165.  
  9166. On OpenBSD Version 2.5, you can compile MySQL with native threads with
  9167. the following options:
  9168.  
  9169.      CFLAGS=-pthread CXXFLAGS=-pthread ./configure --with-mit-threads=no
  9170.  
  9171. 
  9172. File: mysql.info,  Node: OpenBSD 2.8,  Next: BSDI,  Prev: OpenBSD 2.5,  Up: BSD Notes
  9173.  
  9174. OpenBSD 2.8 Notes
  9175. .................
  9176.  
  9177. Our users have reported that OpenBSD 2.8 has a threading bug which
  9178. causes problems with MySQL.  The OpenBSD Developers have fixed the
  9179. problem, but as of January 25th, 2001, it's only available in the
  9180. "-current" branch.  The symptoms of this threading bug are: slow
  9181. response, high load, high CPU usage, and crashes.
  9182.  
  9183. 
  9184. File: mysql.info,  Node: BSDI,  Next: BSDI2,  Prev: OpenBSD 2.8,  Up: BSD Notes
  9185.  
  9186. BSD/OS Notes
  9187. ............
  9188.  
  9189. * Menu:
  9190.  
  9191. * BSDI2::                       BSD/OS 2.x notes
  9192. * BSDI3::                       BSD/OS 3.x notes
  9193. * BSDI4::                       BSD/OS 4.x notes
  9194.  
  9195. 
  9196. File: mysql.info,  Node: BSDI2,  Next: BSDI3,  Prev: BSDI,  Up: BSD Notes
  9197.  
  9198. BSD/OS Version 2.x Notes
  9199. ........................
  9200.  
  9201. If you get the following error when compiling MySQL, your `ulimit'
  9202. value for virtual memory is too low:
  9203.  
  9204.      item_func.h: In method `Item_func_ge::Item_func_ge(const Item_func_ge &)':
  9205.      item_func.h:28: virtual memory exhausted
  9206.      make[2]: *** [item_func.o] Error 1
  9207.  
  9208. Try using `ulimit -v 80000' and run `make' again.  If this doesn't work
  9209. and you are using `bash', try switching to `csh' or `sh'; some BSDI
  9210. users have reported problems with `bash' and `ulimit'.
  9211.  
  9212. If you are using `gcc', you may also use have to use the
  9213. `--with-low-memory' flag for `configure' to be able to compile
  9214. `sql_yacc.cc'.
  9215.  
  9216. If you get problems with the current date in MySQL, setting the `TZ'
  9217. variable will probably help.  *Note Environment variables::.
  9218.  
  9219. 
  9220. File: mysql.info,  Node: BSDI3,  Next: BSDI4,  Prev: BSDI2,  Up: BSD Notes
  9221.  
  9222. BSD/OS Version 3.x Notes
  9223. ........................
  9224.  
  9225. Upgrade to BSD/OS Version 3.1.  If that is not possible, install
  9226. BSDIpatch M300-038.
  9227.  
  9228. Use the following command when configuring MySQL:
  9229.  
  9230.      shell> env CXX=shlicc++ CC=shlicc2 \
  9231.             ./configure \
  9232.                 --prefix=/usr/local/mysql \
  9233.                 --localstatedir=/var/mysql \
  9234.                 --without-perl \
  9235.                 --with-unix-socket-path=/var/mysql/mysql.sock
  9236.  
  9237. The following is also known to work:
  9238.  
  9239.      shell> env CC=gcc CXX=gcc CXXFLAGS=-O3 \
  9240.             ./configure \
  9241.                 --prefix=/usr/local/mysql \
  9242.                 --with-unix-socket-path=/var/mysql/mysql.sock
  9243.  
  9244. You can change the directory locations if you wish, or just use the
  9245. defaults by not specifying any locations.
  9246.  
  9247. If you have problems with performance under heavy load, try using the
  9248. `--skip-thread-priority' option to `mysqld'!  This will run all threads
  9249. with the same priority; on BSDI Version 3.1, this gives better
  9250. performance (at least until BSDI fixes their thread scheduler).
  9251.  
  9252. If you get the error `virtual memory exhausted' while compiling, you
  9253. should try using `ulimit -v 80000' and run `make' again.  If this
  9254. doesn't work and you are using `bash', try switching to `csh' or `sh';
  9255. some BSDI users have reported problems with `bash' and `ulimit'.
  9256.  
  9257. 
  9258. File: mysql.info,  Node: BSDI4,  Prev: BSDI3,  Up: BSD Notes
  9259.  
  9260. BSD/OS Version 4.x Notes
  9261. ........................
  9262.  
  9263. BSDI Version 4.x has some thread-related bugs.  If you want to use
  9264. MySQL on this, you should install all thread-related patches.  At least
  9265. M400-023 should be installed.
  9266.  
  9267. On some BSDI Version 4.x systems, you may get problems with shared
  9268. libraries.  The symptom is that you can't execute any client programs,
  9269. for example, `mysqladmin'.  In this case you need to reconfigure not to
  9270. use shared libraries with the `--disable-shared' option to configure.
  9271.  
  9272. Some customers have had problems on BSDI 4.0.1 that the `mysqld' binary
  9273. after a while can't open tables.  This is because some library/system
  9274. related bug causes `mysqld' to change current directory without asking
  9275. for this!
  9276.  
  9277. The fix is to either upgrade to 3.23.34 or after running `configure'
  9278. remove the line `#define HAVE_REALPATH' from `config.h' before running
  9279. make.
  9280.  
  9281. Note that the above means that you can't symbolic link a database
  9282. directories to another database directory or symbolic link a table to
  9283. another database on BSDI!  (Making a symbolic link to another disk is
  9284. ok).
  9285.  
  9286. 
  9287. File: mysql.info,  Node: Mac OS X,  Next: Other Unix Notes,  Prev: BSD Notes,  Up: Operating System Specific Notes
  9288.  
  9289. Mac OS X Notes
  9290. --------------
  9291.  
  9292. * Menu:
  9293.  
  9294. * Mac OS X Public Beta::        Mac OS X Public Beta
  9295. * Mac OS X Server::             Mac OS X Server
  9296.  
  9297. 
  9298. File: mysql.info,  Node: Mac OS X Public Beta,  Next: Mac OS X Server,  Prev: Mac OS X,  Up: Mac OS X
  9299.  
  9300. Mac OS X Public Beta
  9301. ....................
  9302.  
  9303. MySQL should work without any problems on Mac OS X Public Beta
  9304. (Darwin).  You don't need the pthread patches for this OS!
  9305.  
  9306. 
  9307. File: mysql.info,  Node: Mac OS X Server,  Prev: Mac OS X Public Beta,  Up: Mac OS X
  9308.  
  9309. Mac OS X Server
  9310. ...............
  9311.  
  9312. Before trying to configure MySQL on Mac OS X server you must first
  9313. install the pthread package from `http://www.prnet.de/RegEx/mysql.html'.
  9314.  
  9315. Our binary for Mac OS X is compiled on Rhapsody 5.5 with the following
  9316. configure line:
  9317.  
  9318.      CC=gcc CFLAGS="-O2 -fomit-frame-pointer" CXX=gcc CXXFLAGS="-O2 -fomit-frame-pointer" ./configure --prefix=/usr/local/mysql "--with-comment=Official MySQL binary" --with-extra-charsets=complex  --disable-shared
  9319.  
  9320. You might want to also add aliases to your shell's resource file to
  9321. access `mysql' and `mysqladmin' from the command line:
  9322.  
  9323.      alias mysql '/usr/local/mysql/bin/mysql'
  9324.      alias mysqladmin '/usr/local/mysql/bin/mysqladmin'
  9325.  
  9326. 
  9327. File: mysql.info,  Node: Other Unix Notes,  Next: OS/2,  Prev: Mac OS X,  Up: Operating System Specific Notes
  9328.  
  9329. Other Unix Notes
  9330. ----------------
  9331.  
  9332. * Menu:
  9333.  
  9334. * Binary notes-HP-UX::          HP-UX Notes for Binary Distributions
  9335. * HP-UX 10.20::                 HP-UX Version 10.20 Notes
  9336. * HP-UX 11.x::                  HP-UX Version 11.x Notes
  9337. * IBM-AIX::                     IBM-AIX notes
  9338. * SunOS::                       SunOS 4 Notes
  9339. * Alpha-DEC-UNIX::              Alpha-DEC-UNIX Notes (Tru64)
  9340. * Alpha-DEC-OSF1::              Alpha-DEC-OSF1 Notes
  9341. * SGI-Irix::                    SGI Irix Notes
  9342. * SCO::                         SCO Notes
  9343. * SCO Unixware::                SCO Unixware Version 7.0 Notes
  9344.  
  9345. 
  9346. File: mysql.info,  Node: Binary notes-HP-UX,  Next: HP-UX 10.20,  Prev: Other Unix Notes,  Up: Other Unix Notes
  9347.  
  9348. HP-UX Notes for Binary Distributions
  9349. ....................................
  9350.  
  9351. Some of the binary distributions of MySQL for HP-UX is distributed as
  9352. an HP depot file and as a tar file.  To use the depot file you must be
  9353. running at least HP-UX 10.x to have access to HP's software depot tools.
  9354.  
  9355. The HP version of MySQL was compiled on an HP 9000/8xx server under
  9356. HP-UX 10.20, and uses MIT-pthreads.  It is known to work well under
  9357. this configuration.  MySQL Version 3.22.26 and newer can also be built
  9358. with HP's native thread package.
  9359.  
  9360. Other configurations that may work:
  9361.  
  9362.    * HP 9000/7xx running HP-UX 10.20+
  9363.  
  9364.    * HP 9000/8xx running HP-UX 10.30
  9365.  
  9366. The following configurations almost definitely won't work:
  9367.  
  9368.    * HP 9000/7xx or 8xx running HP-UX 10.x where x < 2
  9369.  
  9370.    * HP 9000/7xx or 8xx running HP-UX 9.x
  9371.  
  9372. To install the distribution, use one of the commands below, where
  9373. `/path/to/depot' is the full pathname of the depot file:
  9374.  
  9375.    * To install everything, including the server, client and
  9376.      development tools:
  9377.  
  9378.           shell> /usr/sbin/swinstall -s /path/to/depot mysql.full
  9379.  
  9380.    * To install only the server:
  9381.  
  9382.           shell> /usr/sbin/swinstall -s /path/to/depot mysql.server
  9383.  
  9384.    * To install only the client package:
  9385.  
  9386.           shell> /usr/sbin/swinstall -s /path/to/depot mysql.client
  9387.  
  9388.    * To install only the development tools:
  9389.  
  9390.           shell> /usr/sbin/swinstall -s /path/to/depot mysql.developer
  9391.  
  9392. The depot places binaries and libraries in `/opt/mysql' and data in
  9393. `/var/opt/mysql'. The depot also creates the appropriate entries in
  9394. `/etc/init.d' and `/etc/rc2.d' to start the server automatically at
  9395. boot time.  Obviously, this entails being `root' to install.
  9396.  
  9397. To install the HP-UX tar.gz distribution, you must have a copy of GNU
  9398. `tar'.
  9399.  
  9400. 
  9401. File: mysql.info,  Node: HP-UX 10.20,  Next: HP-UX 11.x,  Prev: Binary notes-HP-UX,  Up: Other Unix Notes
  9402.  
  9403. HP-UX Version 10.20 Notes
  9404. .........................
  9405.  
  9406. There are a couple of small problems when compiling MySQL on HP-UX.  We
  9407. recommend that you use `gcc' instead of the HP-UX native compiler,
  9408. because `gcc' produces better code!
  9409.  
  9410. We recommend using gcc 2.95 on HP-UX.  Don't use high optimization
  9411. flags (like -O6) as this may not be safe on HP-UX.
  9412.  
  9413. Note that MIT-pthreads can't be compiled with the HP-UX compiler
  9414. because it can't compile `.S' (assembler) files.
  9415.  
  9416. The following configure line should work:
  9417.  
  9418.      CFLAGS="-DHPUX -I/opt/dce/include" CXXFLAGS="-DHPUX -I/opt/dce/include -felide-constructors -fno-exceptions -fno-rtti" CXX=gcc ./configure --with-pthread --with-named-thread-libs='-ldce' --prefix=/usr/local/mysql --disable-shared
  9419.  
  9420. If you are compiling `gcc' 2.95 yourself, you should NOT link it with
  9421. the DCE libraries (`libdce.a' or `libcma.a') if you want to compile
  9422. MySQL with MIT-pthreads.  If you mix the DCE and MIT-pthreads packages
  9423. you will get a `mysqld' to which you cannot connect.  Remove the DCE
  9424. libraries while you compile `gcc' 2.95!
  9425.  
  9426. 
  9427. File: mysql.info,  Node: HP-UX 11.x,  Next: IBM-AIX,  Prev: HP-UX 10.20,  Up: Other Unix Notes
  9428.  
  9429. HP-UX Version 11.x Notes
  9430. ........................
  9431.  
  9432. For HP-UX Version 11.x we recommend MySQL Version 3.23.15 or later.
  9433.  
  9434. Because of some critical bugs in the standard HP-UX libraries, you
  9435. should install the following patches before trying to run MySQL on
  9436. HP-UX 11.0:
  9437.  
  9438.      PHKL_22840 Streams cumulative
  9439.      PHNE_22397 ARPA cumulative
  9440.  
  9441. This will solve a problem that one gets `EWOULDBLOCK' from `recv()' and
  9442. `EBADF' from `accept()' in threaded applications.
  9443.  
  9444. If you are using `gcc' 2.95.1 on an unpatched HP-UX 11.x system, you
  9445. will get the error:
  9446.  
  9447.      In file included from /usr/include/unistd.h:11,
  9448.                       from ../include/global.h:125,
  9449.                       from mysql_priv.h:15,
  9450.                       from item.cc:19:
  9451.      /usr/include/sys/unistd.h:184: declaration of C function ...
  9452.      /usr/include/sys/pthread.h:440: previous declaration ...
  9453.      In file included from item.h:306,
  9454.                       from mysql_priv.h:158,
  9455.                       from item.cc:19:
  9456.  
  9457. The problem is that HP-UX doesn't define `pthreads_atfork()'
  9458. consistently.  It has conflicting prototypes in
  9459. `/usr/include/sys/unistd.h':184 and `/usr/include/sys/pthread.h':440
  9460. (details below).
  9461.  
  9462. One solution is to copy `/usr/include/sys/unistd.h' into
  9463. `mysql/include' and edit `unistd.h' and change it to match the
  9464. definition in `pthread.h'.  Here's the diff:
  9465.  
  9466.      183,184c183,184
  9467.      <      extern int pthread_atfork(void (*prepare)(), void (*parent)(),
  9468.      <                                                void (*child)());
  9469.      ---
  9470.      >      extern int pthread_atfork(void (*prepare)(void), void (*parent)(void),
  9471.      >                                                void (*child)(void));
  9472.  
  9473. After this, the following configure line should work:
  9474.  
  9475.      CFLAGS="-fomit-frame-pointer -O3 -fpic" CXX=gcc CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti -O3" ./configure --prefix=/usr/local/mysql --disable-shared
  9476.  
  9477. Here is some information that a HP-UX Version 11.x user sent us about
  9478. compiling MySQL with HP-UX:x compiler:
  9479.  
  9480.       Environment:
  9481.            proper compilers.
  9482.               setenv CC cc
  9483.               setenv CXX aCC
  9484.            flags
  9485.               setenv CFLAGS -D_REENTRANT
  9486.               setenv CXXFLAGS -D_REENTRANT
  9487.               setenv CPPFLAGS -D_REENTRANT
  9488.           % aCC -V
  9489.           aCC: HP ANSI C++ B3910B X.03.14.06
  9490.           % cc -V /tmp/empty.c
  9491.           cpp.ansi: HP92453-01 A.11.02.00 HP C Preprocessor (ANSI)
  9492.           ccom: HP92453-01 A.11.01.00 HP C Compiler
  9493.           cc: "/tmp/empty.c", line 1: warning 501: Empty source file.
  9494.      
  9495.        configuration:
  9496.           ./configure  --with-pthread        \
  9497.           --prefix=/source-control/mysql     \
  9498.           --with-named-thread-libs=-lpthread \
  9499.           --with-low-memory
  9500.      
  9501.          added '#define _CTYPE_INCLUDED' to include/m_ctype.h. This
  9502.          symbol is the one defined in HP's /usr/include/ctype.h:
  9503.      
  9504.           /* Don't include std ctype.h when this is included */
  9505.           #define _CTYPE_H
  9506.           #define __CTYPE_INCLUDED
  9507.           #define _CTYPE_INCLUDED
  9508.           #define _CTYPE_USING   /* Don't put names in global namespace. */
  9509.  
  9510.    * I had to use the compile-time flag `-D_REENTRANT' to get the
  9511.      compiler to recognize the prototype for `localtime_r'.
  9512.      Alternatively I could have supplied the prototype for
  9513.      `localtime_r'. But I wanted to catch other bugs without needing to
  9514.      run into them.  I wasn't sure where I needed it, so I added it to
  9515.      all flags.
  9516.  
  9517.    * The optimization flags used by MySQL (-O3) are not recognized by
  9518.      HP's compilers.  I did not change the flags.
  9519.  
  9520. If you get the following error from `configure'
  9521.  
  9522.      checking for cc option to accept ANSI C... no
  9523.      configure: error: MySQL requires a ANSI C compiler (and a C++ compiler). Try gcc. See the Installation chapter in the Reference Manual.
  9524.  
  9525. Check that you don't have the path to the K&R compiler before the path
  9526. to the HP-UX C and C++ compiler.
  9527.  
  9528. 
  9529. File: mysql.info,  Node: IBM-AIX,  Next: SunOS,  Prev: HP-UX 11.x,  Up: Other Unix Notes
  9530.  
  9531. IBM-AIX notes
  9532. .............
  9533.  
  9534. Automatic detection of `xlC' is missing from Autoconf, so a `configure'
  9535. command something like this is needed when compiling MySQL (This
  9536. example uses the IBM compiler):
  9537.  
  9538.      export CC="xlc_r -ma -O3 -qstrict -qoptimize=3 -qmaxmem=8192 "
  9539.      export CXX="xlC_r -ma -O3 -qstrict -qoptimize=3 -qmaxmem=8192"
  9540.      export CFLAGS="-I /usr/local/include"
  9541.      export LDFLAGS="-L /usr/local/lib"
  9542.      export CPPFLAGS=$CFLAGS
  9543.      export CXXFLAGS=$CFLAGS
  9544.      
  9545.      ./configure --prefix=/usr/local \
  9546.              --localstatedir=/var/mysql \
  9547.              --sysconfdir=/etc/mysql \
  9548.              --sbindir='/usr/local/bin' \
  9549.              --libexecdir='/usr/local/bin' \
  9550.              --enable-thread-safe-client \
  9551.              --enable-large-files
  9552.  
  9553. Above are the options used to compile the MySQL distribution that can
  9554. be found at `http://www-frec.bull.com/'.
  9555.  
  9556. If you change the `-O3' to `-O2' in the above configure line, you must
  9557. also remove the `-qstrict' option (this is a limitation in the IBM C
  9558. compiler).
  9559.  
  9560. If you are using `gcc' or `egcs' to compile MySQL, you *MUST* use the
  9561. `-fno-exceptions' flag, as the exception handling in `gcc'/`egcs' is
  9562. not thread safe!  (This is tested with `egcs' 1.1.).  There are also
  9563. some known problems with IBM's assembler, which may cause it to
  9564. generate bad code when used with gcc.
  9565.  
  9566. We recommend the following `configure' line with `egcs' and `gcc 2.95'
  9567. on AIX:
  9568.  
  9569.      CC="gcc -pipe -mcpu=power -Wa,-many" \
  9570.      CXX="gcc -pipe -mcpu=power -Wa,-many" \
  9571.      CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti" \
  9572.      ./configure --prefix=/usr/local/mysql --with-low-memory
  9573.  
  9574. The `-Wa,-many' is necessary for the compile to be successful.  IBM is
  9575. aware of this problem but is in to hurry to fix it because of the
  9576. workaround available.  We don't know if the `-fno-exceptions' is
  9577. required with `gcc 2.95', but as MySQL doesn't use exceptions and the
  9578. above option generates faster code, we recommend that you should always
  9579. use this option with `egcs / gcc'.
  9580.  
  9581. If you get a problem with assembler code try changing the -mcpu=xxx to
  9582. match your cpu. Typically power2, power, or powerpc may need to be used,
  9583. alternatively you might need to use 604 or 604e. I'm not positive but I
  9584. would think using "power" would likely be safe most of the time, even on
  9585. a power2 machine.
  9586.  
  9587. If you don't know what your cpu is then do a "uname -m", this will give
  9588. you back a string that looks like "000514676700", with a format of
  9589. xxyyyyyymmss where xx and ss are always 0's, yyyyyy is a unique system
  9590. id and mm is the id of the CPU Planar. A chart of these values can be
  9591. found at
  9592. `http://www.rs6000.ibm.com/doc_link/en_US/a_doc_lib/cmds/aixcmds5/uname.htm'.
  9593. This will give you a machine type and a machine model you can use to
  9594. determine what type of cpu you have.
  9595.  
  9596. If you have problems with signals (MySQL dies unexpectedly under high
  9597. load) you may have found an OS bug with threads and signals.  In this
  9598. case you can tell MySQL not to use signals by configuring with:
  9599.  
  9600.      shell> CFLAGS=-DDONT_USE_THR_ALARM CXX=gcc \
  9601.             CXXFLAGS="-felide-constructors -fno-exceptions -fno-rtti -DDONT_USE_THR_ALARM" \
  9602.             ./configure --prefix=/usr/local/mysql --with-debug --with-low-memory
  9603.  
  9604. This doesn't affect the performance of MySQL, but has the side effect
  9605. that you can't kill clients that are "sleeping" on a connection with
  9606. `mysqladmin kill' or `mysqladmin shutdown'.  Instead, the client will
  9607. die when it issues its next command.
  9608.  
  9609. On some versions of AIX, linking with `libbind.a' makes `getservbyname'
  9610. core dump.  This is an AIX bug and should be reported to IBM.
  9611.  
  9612. For AIX 4.2.1 and gcc you have to do the following changes.
  9613.  
  9614. After configuring, edit `config.h' and `include/my_config.h' and change
  9615. the line that says
  9616.  
  9617.      #define HAVE_SNPRINTF 1
  9618.  
  9619. to
  9620.  
  9621.      #undef HAVE_SNPRINTF
  9622.  
  9623. And finally, in `mysqld.cc' you need to add a prototype for initgoups.
  9624.  
  9625.      #ifdef _AIX41
  9626.      extern "C" int initgroups(const char *,int);
  9627.      #endif
  9628.  
  9629. 
  9630. File: mysql.info,  Node: SunOS,  Next: Alpha-DEC-UNIX,  Prev: IBM-AIX,  Up: Other Unix Notes
  9631.  
  9632. SunOS 4 Notes
  9633. .............
  9634.  
  9635. On SunOS 4, MIT-pthreads is needed to compile MySQL, which in turn
  9636. means you will need GNU `make'.
  9637.  
  9638. Some SunOS 4 systems have problems with dynamic libraries and `libtool'.
  9639. You can use the following `configure' line to avoid this problem:
  9640.  
  9641.      shell> ./configure --disable-shared --with-mysqld-ldflags=-all-static
  9642.  
  9643. When compiling `readline', you may get warnings about duplicate defines.
  9644. These may be ignored.
  9645.  
  9646. When compiling `mysqld', there will be some `implicit declaration of
  9647. function' warnings. These may be ignored.
  9648.  
  9649. 
  9650. File: mysql.info,  Node: Alpha-DEC-UNIX,  Next: Alpha-DEC-OSF1,  Prev: SunOS,  Up: Other Unix Notes
  9651.  
  9652. Alpha-DEC-UNIX Notes (Tru64)
  9653. ............................
  9654.  
  9655. If you are using egcs 1.1.2 on Digital Unix, you should upgrade to gcc
  9656. 2.95.2, as egcs on DEC has some serious bugs!
  9657.  
  9658. When compiling threaded programs under Digital Unix, the documentation
  9659. recommends using the `-pthread' option for `cc' and `cxx' and the
  9660. libraries `-lmach -lexc' (in addition to `-lpthread').  You should run
  9661. `configure' something like this:
  9662.  
  9663.      CC="cc -pthread" CXX="cxx -pthread -O" \
  9664.      ./configure --with-named-thread-libs="-lpthread -lmach -lexc -lc"
  9665.  
  9666. When compiling `mysqld', you may see a couple of warnings like this:
  9667.  
  9668.      mysqld.cc: In function void handle_connections()':
  9669.      mysqld.cc:626: passing long unsigned int *' as argument 3 of
  9670.      accept(int,sockadddr *, int *)'
  9671.  
  9672. You can safely ignore these warnings.  They occur because `configure'
  9673. can detect only errors, not warnings.
  9674.  
  9675. If you start the server directly from the command line, you may have
  9676. problems with it dying when you log out.  (When you log out, your
  9677. outstanding processes receive a `SIGHUP' signal.)  If so, try starting
  9678. the server like this:
  9679.  
  9680.      shell> nohup mysqld [options] &
  9681.  
  9682. `nohup' causes the command following it to ignore any `SIGHUP' signal
  9683. sent from the terminal.  Alternatively, start the server by running
  9684. `safe_mysqld', which invokes `mysqld' using `nohup' for you.  *Note
  9685. `safe_mysqld': safe_mysqld.
  9686.  
  9687. If you get a problem when compiling mysys/get_opt.c, just remove the
  9688. line #define _NO_PROTO from the start of that file!
  9689.  
  9690. If you are using Compac's CC compiler, the following configure line
  9691. should work:
  9692.  
  9693.      CC="cc -pthread"
  9694.      CFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed all -arch host"
  9695.      CXX="cxx -pthread"
  9696.      CXXFLAGS="-O4 -ansi_alias -ansi_args -fast -inline speed all -arch host"
  9697.      export CC CFLAGS CXX CXXFLAGS
  9698.      ./configure \
  9699.      --prefix=/usr/local/mysql \
  9700.      --with-low-memory \
  9701.      --enable-large-files \
  9702.      --enable-shared=yes \
  9703.      --with-named-thread-libs="-lpthread -lmach -lexc -lc"
  9704.      gnumake
  9705.  
  9706. If you get a problem with libtool, when compiling with shared libraries
  9707. as above, when linking `mysql', you should be able to get around this
  9708. by issuing:
  9709.  
  9710.      cd mysql
  9711.      /bin/sh ../libtool --mode=link cxx -pthread  -O3 -DDBUG_OFF \
  9712.      -O4 -ansi_alias -ansi_args -fast -inline speed \
  9713.      -speculate all \ -arch host  -DUNDEF_HAVE_GETHOSTBYNAME_R \
  9714.      -o mysql  mysql.o readline.o sql_string.o completion_hash.o \
  9715.      ../readline/libreadline.a -lcurses \
  9716.      ../libmysql/.libs/libmysqlclient.so  -lm
  9717.      cd ..
  9718.      gnumake
  9719.      gnumake install
  9720.      scripts/mysql_install_db
  9721.  
  9722. 
  9723. File: mysql.info,  Node: Alpha-DEC-OSF1,  Next: SGI-Irix,  Prev: Alpha-DEC-UNIX,  Up: Other Unix Notes
  9724.  
  9725. Alpha-DEC-OSF1 Notes
  9726. ....................
  9727.  
  9728. If you have problems compiling and have DEC `CC' and `gcc' installed,
  9729. try running `configure' like this:
  9730.  
  9731.      CC=cc CFLAGS=-O CXX=gcc CXXFLAGS=-O3 \
  9732.      ./configure --prefix=/usr/local/mysql
  9733.  
  9734. If you get problems with the `c_asm.h' file, you can create and use a
  9735. 'dummy' `c_asm.h' file with:
  9736.  
  9737.      touch include/c_asm.h
  9738.      CC=gcc CFLAGS=-I./include \
  9739.      CXX=gcc CXXFLAGS=-O3 \
  9740.      ./configure --prefix=/usr/local/mysql
  9741.  
  9742. Note that the following problems with the `ld' program can be fixed by
  9743. downloading the latest DEC (Compaq) patch kit from:
  9744. `http://ftp.support.compaq.com/public/unix/'.
  9745.  
  9746. On OSF1 V4.0D and compiler "DEC C V5.6-071 on Digital Unix V4.0 (Rev.
  9747. 878)" the compiler had some strange behavior (undefined `asm' symbols).
  9748. `/bin/ld' also appears to be broken (problems with `_exit undefined'
  9749. errors occuring while linking `mysqld').  On this system, we have
  9750. managed to compile MySQL with the following `configure' line, after
  9751. replacing `/bin/ld' with the version from OSF 4.0C:
  9752.  
  9753.      CC=gcc CXX=gcc CXXFLAGS=-O3 ./configure --prefix=/usr/local/mysql
  9754.  
  9755. With the Digital compiler "C++ V6.1-029", the following should work:
  9756.  
  9757.      CC=cc -pthread
  9758.      CFLAGS=-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all -arch host
  9759.      CXX=cxx -pthread
  9760.      CXXFLAGS=-O4 -ansi_alias -ansi_args -fast -inline speed -speculate all -arch host -noexceptions -nortti
  9761.      export CC CFLAGS CXX CXXFLAGS
  9762.      ./configure --prefix=/usr/mysql/mysql --with-mysqld-ldflags=-all-static --disable-shared --with-named-thread-libs="-lmach -lexc -lc"
  9763.  
  9764. In some versions of OSF1, the `alloca()' function is broken. Fix this
  9765. by removing the line in `config.h' that defines `'HAVE_ALLOCA''.
  9766.  
  9767. The `alloca()' function also may have an incorrect prototype in
  9768. `/usr/include/alloca.h'.  This warning resulting from this can be
  9769. ignored.
  9770.  
  9771. `configure' will use the following thread libraries automatically:
  9772. `--with-named-thread-libs="-lpthread -lmach -lexc -lc"'.
  9773.  
  9774. When using `gcc', you can also try running `configure' like this:
  9775.  
  9776.      shell> CFLAGS=-D_PTHREAD_USE_D4 CXX=gcc CXXFLAGS=-O3 ./configure ....
  9777.  
  9778. If you have problems with signals (MySQL dies unexpectedly under high
  9779. load), you may have found an OS bug with threads and signals. In this
  9780. case you can tell MySQL not to use signals by configuring with:
  9781.  
  9782.      shell> CFLAGS=-DDONT_USE_THR_ALARM \
  9783.             CXXFLAGS=-DDONT_USE_THR_ALARM \
  9784.             ./configure ...
  9785.  
  9786. This doesn't affect the performance of MySQL, but has the side effect
  9787. that you can't kill clients that are "sleeping" on a connection with
  9788. `mysqladmin kill' or `mysqladmin shutdown'.  Instead, the client will
  9789. die when it issues its next command.
  9790.  
  9791. With `gcc' 2.95.2, you will probably run into the following compile
  9792. error:
  9793.  
  9794.      sql_acl.cc:1456: Internal compiler error in `scan_region', at except.c:2566
  9795.      Please submit a full bug report.
  9796.  
  9797. To fix this you should change to the `sql' directory and do a "cut and
  9798. paste" of the last `gcc' line, but change `-O3' to `-O0' (or add `-O0'
  9799. immediately after `gcc' if you don't have any `-O' option on your
  9800. compile line.)  After this is done you can just change back to the
  9801. top-level directly and run `make' again.
  9802.  
  9803. 
  9804. File: mysql.info,  Node: SGI-Irix,  Next: SCO,  Prev: Alpha-DEC-OSF1,  Up: Other Unix Notes
  9805.  
  9806. SGI Irix Notes
  9807. ..............
  9808.  
  9809. If you are using Irix Version 6.5.3 or newer `mysqld' will only be able
  9810. to create threads if you run it as a user with `CAP_SCHED_MGT'
  9811. privileges (like `root') or give the `mysqld' server this privilege
  9812. with the following shell command:
  9813.  
  9814.      shell> chcap "CAP_SCHED_MGT+epi" /opt/mysql/libexec/mysqld
  9815.  
  9816. You may have to undefine some things in `config.h' after running
  9817. `configure' and before compiling.
  9818.  
  9819. In some Irix implementations, the `alloca()' function is broken.  If the
  9820. `mysqld' server dies on some `SELECT' statements, remove the lines from
  9821. `config.h' that define `HAVE_ALLOC' and `HAVE_ALLOCA_H'.  If
  9822. `mysqladmin create' doesn't work, remove the line from `config.h' that
  9823. defines `HAVE_READDIR_R'.  You may have to remove the `HAVE_TERM_H'
  9824. line as well.
  9825.  
  9826. SGI recommends that you install all of the patches on this page as a
  9827. set:
  9828. http://support.sgi.com/surfzone/patches/patchset/6.2_indigo.rps.html
  9829.  
  9830. At the very minimum, you should install the latest kernel rollup, the
  9831. latest `rld' rollup, and the latest `libc' rollup.
  9832.  
  9833. You definitely need all the POSIX patches on this page, for pthreads
  9834. support:
  9835.  
  9836. `http://support.sgi.com/surfzone/patches/patchset/6.2_posix.rps.html'
  9837.  
  9838. If you get the something like the following error when compiling
  9839. `mysql.cc':
  9840.  
  9841.      "/usr/include/curses.h", line 82: error(1084): invalid combination of type
  9842.  
  9843. Type the following in the top-level directory of your MySQL source tree:
  9844.  
  9845.      shell> extra/replace bool curses_bool < /usr/include/curses.h > include/curses.h
  9846.      shell> make
  9847.  
  9848. There have also been reports of scheduling problems.  If only one
  9849. thread is running, things go slow.  Avoid this by starting another
  9850. client.  This may lead to a 2-to-10-fold increase in execution speed
  9851. thereafter for the other thread.  This is a poorly understood problem
  9852. with Irix threads; you may have to improvise to find solutions until
  9853. this can be fixed.
  9854.  
  9855. If you are compiling with `gcc', you can use the following `configure'
  9856. command:
  9857.  
  9858.      CC=gcc CXX=gcc CXXFLAGS=-O3 \
  9859.      ./configure --prefix=/usr/local/mysql --enable-thread-safe-client --with-named-thread-libs=-lpthread
  9860.  
  9861. On Irix 6.5.11 with native Irix C and C++ compilers ver. 7.3.1.2, the
  9862. following is reported to work
  9863.  
  9864.      CC=cc CXX=CC CFLAGS='-O3 -n32 -TARG:platform=IP22 -I/usr/local/include \
  9865.      -L/usr/local/lib' CXXFLAGS='-O3 -n32 -TARG:platform=IP22 \
  9866.      -I/usr/local/include -L/usr/local/lib' ./configure --prefix=/usr/local/mysql \
  9867.      --with-berkeley-db --with-innodb \
  9868.      --with-libwrap=/usr/local --with-named-curses-libs=/usr/local/lib/libncurses.a
  9869.  
  9870. 
  9871. File: mysql.info,  Node: SCO,  Next: SCO Unixware,  Prev: SGI-Irix,  Up: Other Unix Notes
  9872.  
  9873. SCO Notes
  9874. .........
  9875.  
  9876. The current port is tested only on a "sco3.2v5.0.4" and "sco3.2v5.0.5"
  9877. system.  There has also been a lot of progress on a port to "sco
  9878. 3.2v4.2".
  9879.  
  9880. For the moment the recommended compiler on OpenServer is gcc 2.95.2.
  9881. With this you should be able to compile MySQL with just:
  9882.  
  9883.      CC=gcc CXX=gcc ./configure ... (options)
  9884.  
  9885.   1. For OpenServer 5.0.X you need to use GDS in Skunkware 95 (95q4c).
  9886.      This is necessary because GNU `gcc' 2.7.2 in Skunkware 97 does not
  9887.      have GNU `as'.  You can also use `egcs' 1.1.2 or newer
  9888.      `http://www.egcs.com/'.  If you are using `egcs' 1.1.2 you have to
  9889.      execute the following command:
  9890.  
  9891.           shell> cp -p /usr/include/pthread/stdtypes.h /usr/local/lib/gcc-lib/i386-pc-sco3.2v5.0.5/egcs-2.91.66/include/pthread/
  9892.  
  9893.   2. You need the port of GCC 2.5.x for this product and the Development
  9894.      system.  They are required on this version of SCO Unix.  You cannot
  9895.      just use the GCC Dev system.
  9896.  
  9897.   3. You should get the FSU Pthreads package and install it first.
  9898.      This can be found at
  9899.      `http://www.cs.wustl.edu/~schmidt/ACE_wrappers/FSU-threads.tar.gz'.
  9900.      You can also get a precompiled package from
  9901.      `http://www.mysql.com/Downloads/SCO/FSU-threads-3.5c.tar.gz'.
  9902.  
  9903.   4. FSU Pthreads can be compiled with SCO Unix 4.2 with tcpip.  Or
  9904.      OpenServer 3.0 or Open Desktop 3.0 (OS 3.0 ODT 3.0), with the SCO
  9905.      Development System installed using a good port of GCC 2.5.x ODT or
  9906.      OS 3.0 you will need a good port of GCC 2.5.x There are a lot of
  9907.      problems without a good port.  The port for this product requires
  9908.      the SCO Unix Development system.  Without it, you are missing the
  9909.      libraries and the linker that is needed.
  9910.  
  9911.   5. To build FSU Pthreads on your system, do the following:
  9912.  
  9913.        a. Run `./configure' in the `threads/src' directory and select
  9914.           the SCO OpenServer option. This command copies
  9915.           `Makefile.SCO5' to `Makefile'.
  9916.  
  9917.        b. Run `make'.
  9918.  
  9919.        c. To install in the default `/usr/include' directory, login as
  9920.           root, then `cd' to the `thread/src' directory, and run `make
  9921.           install'.
  9922.  
  9923.   6. Remember to use GNU `make' when making MySQL.
  9924.  
  9925.   7. If you don't start `safe_mysqld' as root, you probably will get
  9926.      only the default 110 open files per process.  `mysqld' will write
  9927.      a note about this in the log file.
  9928.  
  9929.   8. With SCO 3.2V5.0.5, you should use FSU Pthreads version 3.5c or
  9930.      newer.  You should also use gcc 2.95.2 or newer!
  9931.  
  9932.      The following `configure' command should work:
  9933.  
  9934.           shell> ./configure --prefix=/usr/local/mysql --disable-shared
  9935.  
  9936.   9. With SCO 3.2V4.2, you should use FSU Pthreads version 3.5c or
  9937.      newer.  The following `configure' command should work:
  9938.  
  9939.           shell> CFLAGS="-D_XOPEN_XPG4" CXX=gcc CXXFLAGS="-D_XOPEN_XPG4" \
  9940.                  ./configure \
  9941.                      --prefix=/usr/local/mysql \
  9942.                      --with-named-thread-libs="-lgthreads -lsocket -lgen -lgthreads" \
  9943.                      --with-named-curses-libs="-lcurses"
  9944.  
  9945.      You may get some problems with some include files. In this case,
  9946.      you can find new SCO-specific include files at
  9947.      `http://www.mysql.com/Downloads/SCO/SCO-3.2v4.2-includes.tar.gz'.
  9948.      You should unpack this file in the `include' directory of your
  9949.      MySQL source tree.
  9950.  
  9951. SCO development notes:
  9952.  
  9953.    * MySQL should automatically detect FSU Pthreads and link `mysqld'
  9954.      with `-lgthreads -lsocket -lgthreads'.
  9955.  
  9956.    * The SCO development libraries are re-entrant in FSU Pthreads.  SCO
  9957.      claims that its libraries' functions are re-entrant, so they must
  9958.      be reentrant with FSU Pthreads.  FSU Pthreads on OpenServer tries
  9959.      to use the SCO scheme to make re-entrant libraries.
  9960.  
  9961.    * FSU Pthreads (at least the version at `http://www.mysql.com/')
  9962.      comes linked with GNU `malloc'.  If you encounter problems with
  9963.      memory usage, make sure that `gmalloc.o' is included in
  9964.      `libgthreads.a' and `libgthreads.so'.
  9965.  
  9966.    * In FSU Pthreads, the following system calls are pthreads-aware:
  9967.      `read()', `write()', `getmsg()', `connect()', `accept()',
  9968.      `select()', and `wait()'.
  9969.  
  9970.    * The CSSA-2001-SCO.35.2 (the patch is listed in custom as
  9971.      erg711905-dscr_remap security patch (ver 2.0.0) breaks FSU threads
  9972.      and makes mysqld instable.  You have to remove this one if you
  9973.      want to run mysqld on an OpenServer 5.0.6 machine.
  9974.  
  9975. If you want to install DBI on SCO, you have to edit the `Makefile' in
  9976. DBI-xxx and each subdirectory.
  9977.  
  9978. Note that the following assumes gcc 2.95.2 or newer:
  9979.  
  9980.      OLD:                                  NEW:
  9981.      CC = cc                               CC = gcc
  9982.      CCCDLFLAGS = -KPIC -W1,-Bexport       CCCDLFLAGS = -fpic
  9983.      CCDLFLAGS = -wl,-Bexport              CCDLFLAGS =
  9984.      
  9985.      LD = ld                               LD = gcc -G -fpic
  9986.      LDDLFLAGS = -G -L/usr/local/lib       LDDLFLAGS = -L/usr/local/lib
  9987.      LDFLAGS = -belf -L/usr/local/lib      LDFLAGS = -L/usr/local/lib
  9988.      
  9989.      LD = ld                               LD = gcc -G -fpic
  9990.      OPTIMISE = -Od                        OPTIMISE = -O1
  9991.      
  9992.      OLD:
  9993.      CCCFLAGS = -belf -dy -w0 -U M_XENIX -DPERL_SCO5 -I/usr/local/include
  9994.      
  9995.      NEW:
  9996.      CCFLAGS = -U M_XENIX -DPERL_SCO5 -I/usr/local/include
  9997.  
  9998. This is because the Perl dynaloader will not load the `DBI' modules if
  9999. they were compiled with `icc' or `cc'.
  10000.  
  10001. Perl works best when compiled with `cc'.
  10002.  
  10003. 
  10004. File: mysql.info,  Node: SCO Unixware,  Prev: SCO,  Up: Other Unix Notes
  10005.  
  10006. SCO Unixware Version 7.0 Notes
  10007. ..............................
  10008.  
  10009. You must use a version of MySQL at least as recent as Version 3.22.13
  10010. because that version fixes some portability problems under Unixware.
  10011.  
  10012. We have been able to compile MySQL with the following `configure'
  10013. command on Unixware Version 7.0.1:
  10014.  
  10015.      CC=cc CXX=CC ./configure --prefix=/usr/local/mysql
  10016.  
  10017. If you want to use `gcc', you must use `gcc' 2.95.2 or newer.
  10018.  
  10019. * Menu:
  10020.  
  10021. * OS/2::                        OS/2 Notes
  10022.  
  10023. 
  10024. File: mysql.info,  Node: OS/2,  Next: BeOS,  Prev: Other Unix Notes,  Up: Operating System Specific Notes
  10025.  
  10026. OS/2 Notes
  10027. ----------
  10028.  
  10029. MySQL uses quite a few open files. Because of this, you should add
  10030. something like the following to your `CONFIG.SYS' file:
  10031.  
  10032.      SET EMXOPT=-c -n -h1024
  10033.  
  10034. If you don't do this, you will probably run into the following error:
  10035.  
  10036.      File 'xxxx' not found (Errcode: 24)
  10037.  
  10038. When using MySQL with OS/2 Warp 3, FixPack 29 or above is required.
  10039. With OS/2 Warp 4, FixPack 4 or above is required. This is a requirement
  10040. of the Pthreads library.  MySQL must be installed in a partition that
  10041. supports long filenames such as HPFS, FAT32, etc.
  10042.  
  10043. The `INSTALL.CMD' script must be run from OS/2's own `CMD.EXE' and may
  10044. not work with replacement shells such as `4OS2.EXE'.
  10045.  
  10046. The `scripts/mysql-install-db' script has been renamed.  It is now
  10047. called `install.cmd' and is a REXX script, which will set up the default
  10048. MySQL security settings and create the WorkPlace Shell icons for MySQL.
  10049.  
  10050. Dynamic module support is compiled in but not fully tested. Dynamic
  10051. modules should be compiled using the Pthreads run-time library.
  10052.  
  10053.      gcc -Zdll -Zmt -Zcrtdll=pthrdrtl -I../include -I../regex -I.. \
  10054.          -o example udf_example.cc -L../lib -lmysqlclient udf_example.def
  10055.      mv example.dll example.udf
  10056.  
  10057. *Note:* Due to limitations in OS/2, UDF module name stems must not
  10058. exceed 8 characters. Modules are stored in the `/mysql2/udf' directory;
  10059. the `safe-mysqld.cmd' script will put this directory in the
  10060. `BEGINLIBPATH' environment variable. When using UDF modules, specified
  10061. extensions are ignored -- it is assumed to be `.udf'.  For example, in
  10062. Unix, the shared module might be named `example.so' and you would load
  10063. a function from it like this:
  10064.  
  10065.      mysql> CREATE FUNCTION metaphon RETURNS STRING SONAME "example.so";
  10066.  
  10067. Is OS/2, the module would be named `example.udf', but you would not
  10068. specify the module extension:
  10069.  
  10070.      mysql> CREATE FUNCTION metaphon RETURNS STRING SONAME "example";
  10071.  
  10072. 
  10073. File: mysql.info,  Node: BeOS,  Next: Novell Netware,  Prev: OS/2,  Up: Operating System Specific Notes
  10074.  
  10075. BeOS Notes
  10076. ----------
  10077.  
  10078. We are really interested in getting MySQL to work on BeOS, but
  10079. unfortunately we don't have any person who knows BeOS or has time to do
  10080. a port.
  10081.  
  10082. We are interested in finding someone to do a port, and we will help them
  10083. with any technical questions they may have while doing the port.
  10084.  
  10085. We have previously talked with some BeOS developers that have said that
  10086. MySQL is 80% ported to BeOS, but we haven't heard from them in a while.
  10087.  
  10088. 
  10089. File: mysql.info,  Node: Novell Netware,  Prev: BeOS,  Up: Operating System Specific Notes
  10090.  
  10091. Novell Netware Notes
  10092. --------------------
  10093.  
  10094. We are really interested in getting MySQL to work on Netware, but
  10095. unfortunately we don't have any person who knows Netware or has time to
  10096. do a port.
  10097.  
  10098. We are interested in finding someone to do a port, and we will help them
  10099. with any technical questions they may have while doing the port.
  10100.  
  10101. 
  10102. File: mysql.info,  Node: Tutorial,  Next: MySQL Database Administration,  Prev: Installing,  Up: Top
  10103.  
  10104. Introduction to MySQL: A MySQL Tutorial
  10105. ***************************************
  10106.  
  10107. * Menu:
  10108.  
  10109. * Connecting-disconnecting::    Connecting to and disconnecting from the server
  10110. * Entering queries::            Entering queries
  10111. * Database use::                Creating and using a database
  10112. * Getting information::         Getting information about databases and tables
  10113. * Examples::                    Examples
  10114. * Batch mode::                  Using `mysql' in batch mode
  10115. * Twin::                        Queries from twin project
  10116. * Apache::                      Using MySQL with Apache
  10117.  
  10118. This chapter provides a tutorial introduction to MySQL by showing how
  10119. to use the `mysql' client program to create and use a simple database.
  10120. `mysql' (sometimes referred to as the "terminal monitor" or just
  10121. "monitor") is an interactive program that allows you to connect to a
  10122. MySQL server, run queries, and view the results.  `mysql' may also be
  10123. used in batch mode: you place your queries in a file beforehand, then
  10124. tell `mysql' to execute the contents of the file.  Both ways of using
  10125. `mysql' are covered here.
  10126.  
  10127. To see a list of options provided by `mysql', invoke it with the
  10128. `--help' option:
  10129.  
  10130.      shell> mysql --help
  10131.  
  10132. This chapter assumes that `mysql' is installed on your machine and that
  10133. a MySQL server is available to which you can connect.  If this is not
  10134. true, contact your MySQL administrator.  (If _you_ are the
  10135. administrator, you will need to consult other sections of this manual.)
  10136.  
  10137. This chapter describes the entire process of setting up and using a
  10138. database.  If you are interested only in accessing an already-existing
  10139. database, you may want to skip over the sections that describe how to
  10140. create the database and the tables it contains.
  10141.  
  10142. Because this chapter is tutorial in nature, many details are
  10143. necessarily left out.  Consult the relevant sections of the manual for
  10144. more information on the topics covered here.
  10145.  
  10146. 
  10147. File: mysql.info,  Node: Connecting-disconnecting,  Next: Entering queries,  Prev: Tutorial,  Up: Tutorial
  10148.  
  10149. Connecting to and Disconnecting from the Server
  10150. ===============================================
  10151.  
  10152. To connect to the server, you'll usually need to provide a MySQL user
  10153. name when you invoke `mysql' and, most likely, a password.  If the
  10154. server runs on a machine other than the one where you log in, you'll
  10155. also need to specify a hostname.  Contact your administrator to find
  10156. out what connection parameters you should use to connect (that is, what
  10157. host, user name, and password to use).  Once you know the proper
  10158. parameters, you should be able to connect like this:
  10159.  
  10160.      shell> mysql -h host -u user -p
  10161.      Enter password: ********
  10162.  
  10163. The `********' represents your password; enter it when `mysql' displays
  10164. the `Enter password:' prompt.
  10165.  
  10166. If that works, you should see some introductory information followed by
  10167. a `mysql>' prompt:
  10168.  
  10169.      shell> mysql -h host -u user -p
  10170.      Enter password: ********
  10171.      Welcome to the MySQL monitor.  Commands end with ; or \g.
  10172.      Your MySQL connection id is 459 to server version: 3.22.20a-log
  10173.      
  10174.      Type 'help' for help.
  10175.      
  10176.      mysql>
  10177.  
  10178. The prompt tells you that `mysql' is ready for you to enter commands.
  10179.  
  10180. Some MySQL installations allow users to connect as the anonymous
  10181. (unnamed) user to the server running on the local host.  If this is the
  10182. case on your machine, you should be able to connect to that server by
  10183. invoking `mysql' without any options:
  10184.  
  10185.      shell> mysql
  10186.  
  10187. After you have connected successfully, you can disconnect any time by
  10188. typing `QUIT' at the `mysql>' prompt:
  10189.  
  10190.      mysql> QUIT
  10191.      Bye
  10192.  
  10193. You can also disconnect by pressing Control-D.
  10194.  
  10195. Most examples in the following sections assume you are connected to the
  10196. server.  They indicate this by the `mysql>' prompt.
  10197.  
  10198. 
  10199. File: mysql.info,  Node: Entering queries,  Next: Database use,  Prev: Connecting-disconnecting,  Up: Tutorial
  10200.  
  10201. Entering Queries
  10202. ================
  10203.  
  10204. Make sure you are connected to the server, as discussed in the previous
  10205. section.  Doing so will not in itself select any database to work with,
  10206. but that's okay.  At this point, it's more important to find out a
  10207. little about how to issue queries than to jump right in creating
  10208. tables, loading data into them, and retrieving data from them.  This
  10209. section describes the basic principles of entering commands, using
  10210. several queries you can try out to familiarize yourself with how
  10211. `mysql' works.
  10212.  
  10213. Here's a simple command that asks the server to tell you its version
  10214. number and the current date.  Type it in as shown below following the
  10215. `mysql>' prompt and hit the RETURN key:
  10216.  
  10217.      mysql> SELECT VERSION(), CURRENT_DATE;
  10218.      +--------------+--------------+
  10219.      | version()    | CURRENT_DATE |
  10220.      +--------------+--------------+
  10221.      | 3.22.20a-log | 1999-03-19   |
  10222.      +--------------+--------------+
  10223.      1 row in set (0.01 sec)
  10224.      mysql>
  10225.  
  10226. This query illustrates several things about `mysql':
  10227.  
  10228.    * A command normally consists of a SQL statement followed by a
  10229.      semicolon.  (There are some exceptions where a semicolon is not
  10230.      needed.  `QUIT', mentioned earlier, is one of them.  We'll get to
  10231.      others later.)
  10232.  
  10233.    * When you issue a command, `mysql' sends it to the server for
  10234.      execution and displays the results, then prints another `mysql>'
  10235.      to indicate that it is ready for another command.
  10236.  
  10237.    * `mysql' displays query output as a table (rows and columns).  The
  10238.      first row contains labels for the columns.  The rows following are
  10239.      the query results.  Normally, column labels are the names of the
  10240.      columns you fetch from database tables.  If you're retrieving the
  10241.      value of an expression rather than a table column (as in the
  10242.      example just shown), `mysql' labels the column using the
  10243.      expression itself.
  10244.  
  10245.    * `mysql' shows how many rows were returned and how long the query
  10246.      took to execute, which gives you a rough idea of server
  10247.      performance.  These values are imprecise because they represent
  10248.      wall clock time (not CPU or machine time), and because they are
  10249.      affected by factors such as server load and network latency.  (For
  10250.      brevity, the "rows in set" line is not shown in the remaining
  10251.      examples in this chapter.)
  10252.  
  10253. Keywords may be entered in any lettercase.  The following queries are
  10254. equivalent:
  10255.  
  10256.      mysql> SELECT VERSION(), CURRENT_DATE;
  10257.      mysql> select version(), current_date;
  10258.      mysql> SeLeCt vErSiOn(), current_DATE;
  10259.  
  10260. Here's another query.  It demonstrates that you can use `mysql' as a
  10261. simple calculator:
  10262.  
  10263.      mysql> SELECT SIN(PI()/4), (4+1)*5;
  10264.      +-------------+---------+
  10265.      | SIN(PI()/4) | (4+1)*5 |
  10266.      +-------------+---------+
  10267.      |    0.707107 |      25 |
  10268.      +-------------+---------+
  10269.  
  10270. The commands shown thus far have been relatively short, single-line
  10271. statements.  You can even enter multiple statements on a single line.
  10272. Just end each one with a semicolon:
  10273.  
  10274.      mysql> SELECT VERSION(); SELECT NOW();
  10275.      +--------------+
  10276.      | version()    |
  10277.      +--------------+
  10278.      | 3.22.20a-log |
  10279.      +--------------+
  10280.      
  10281.      +---------------------+
  10282.      | NOW()               |
  10283.      +---------------------+
  10284.      | 1999-03-19 00:15:33 |
  10285.      +---------------------+
  10286.  
  10287. A command need not be given all on a single line, so lengthy commands
  10288. that require several lines are not a problem.  `mysql' determines where
  10289. your statement ends by looking for the terminating semicolon, not by
  10290. looking for the end of the input line.  (In other words, `mysql'
  10291. accepts free-format input:  it collects input lines but does not
  10292. execute them until it sees the semicolon.)
  10293.  
  10294. Here's a simple multiple-line statement:
  10295.  
  10296.      mysql> SELECT
  10297.          -> USER()
  10298.          -> ,
  10299.          -> CURRENT_DATE;
  10300.      +--------------------+--------------+
  10301.      | USER()             | CURRENT_DATE |
  10302.      +--------------------+--------------+
  10303.      | joesmith@localhost | 1999-03-18   |
  10304.      +--------------------+--------------+
  10305.  
  10306. In this example, notice how the prompt changes from `mysql>' to `->'
  10307. after you enter the first line of a multiple-line query.  This is how
  10308. `mysql' indicates that it hasn't seen a complete statement and is
  10309. waiting for the rest.  The prompt is your friend, because it provides
  10310. valuable feedback.  If you use that feedback, you will always be aware
  10311. of what `mysql' is waiting for.
  10312.  
  10313. If you decide you don't want to execute a command that you are in the
  10314. process of entering, cancel it by typing `\c':
  10315.  
  10316.      mysql> SELECT
  10317.          -> USER()
  10318.          -> \c
  10319.      mysql>
  10320.  
  10321. Here, too, notice the prompt.  It switches back to `mysql>' after you
  10322. type `\c', providing feedback to indicate that `mysql' is ready for a
  10323. new command.
  10324.  
  10325. The following table shows each of the prompts you may see and
  10326. summarizes what they mean about the state that `mysql' is in:
  10327.  
  10328. *Prompt**Meaning*
  10329. `mysql>'Ready for new command.
  10330. `       Waiting for next line of multiple-line command.
  10331. ->'     
  10332. `       Waiting for next line, collecting a string that begins with a
  10333. '>'     single quote (`'').
  10334. `       Waiting for next line, collecting a string that begins with a
  10335. ">'     double quote (`"').
  10336.  
  10337. Multiple-line statements commonly occur by accident when you intend to
  10338. issue a command on a single line, but forget the terminating semicolon.
  10339. In this case, `mysql' waits for more input:
  10340.  
  10341.      mysql> SELECT USER()
  10342.          ->
  10343.  
  10344. If this happens to you (you think you've entered a statement but the
  10345. only response is a `->' prompt), most likely `mysql' is waiting for the
  10346. semicolon.  If you don't notice what the prompt is telling you, you
  10347. might sit there for a while before realizing what you need to do.
  10348. Enter a semicolon to complete the statement, and `mysql' will execute
  10349. it:
  10350.  
  10351.      mysql> SELECT USER()
  10352.          -> ;
  10353.      +--------------------+
  10354.      | USER()             |
  10355.      +--------------------+
  10356.      | joesmith@localhost |
  10357.      +--------------------+
  10358.  
  10359. The `'>' and `">' prompts occur during string collection.  In MySQL,
  10360. you can write strings surrounded by either `'' or `"' characters (for
  10361. example, `'hello'' or `"goodbye"'), and `mysql' lets you enter strings
  10362. that span multiple lines.  When you see a `'>' or `">' prompt, it means
  10363. that you've entered a line containing a string that begins with a `''
  10364. or `"' quote character, but have not yet entered the matching quote
  10365. that terminates the string.  That's fine if you really are entering a
  10366. multiple-line string, but how likely is that?  Not very.  More often,
  10367. the `'>' and `">' prompts indicate that you've inadvertantly left out a
  10368. quote character.  For example:
  10369.  
  10370.      mysql> SELECT * FROM my_table WHERE name = "Smith AND age < 30;
  10371.          ">
  10372.  
  10373. If you enter this `SELECT' statement, then hit RETURN and wait for the
  10374. result, nothing will happen.  Instead of wondering why this query takes
  10375. so long, notice the clue provided by the `">' prompt.  It tells you
  10376. that `mysql' expects to see the rest of an unterminated string.  (Do
  10377. you see the error in the statement?  The string `"Smith' is missing the
  10378. second quote.)
  10379.  
  10380. At this point, what do you do?  The simplest thing is to cancel the
  10381. command.  However, you cannot just type `\c' in this case, because
  10382. `mysql' interprets it as part of the string that it is collecting!
  10383. Instead, enter the closing quote character (so `mysql' knows you've
  10384. finished the string), then type `\c':
  10385.  
  10386.      mysql> SELECT * FROM my_table WHERE name = "Smith AND age < 30;
  10387.          "> "\c
  10388.      mysql>
  10389.  
  10390. The prompt changes back to `mysql>', indicating that `mysql' is ready
  10391. for a new command.
  10392.  
  10393. It's important to know what the `'>' and `">' prompts signify, because
  10394. if you mistakenly enter an unterminated string, any further lines you
  10395. type will appear to be ignored by `mysql' -- including a line
  10396. containing `QUIT'!  This can be quite confusing, especially if you
  10397. don't know that you need to supply the terminating quote before you can
  10398. cancel the current command.
  10399.  
  10400. 
  10401. File: mysql.info,  Node: Database use,  Next: Getting information,  Prev: Entering queries,  Up: Tutorial
  10402.  
  10403. Creating and Using a Database
  10404. =============================
  10405.  
  10406. * Menu:
  10407.  
  10408. * Creating database::           Creating a database
  10409. * Creating tables::             Creating a table
  10410. * Loading tables::              Loading data into a table
  10411. * Retrieving data::             Retrieving information from a table
  10412.  
  10413. Now that you know how to enter commands, it's time to access a database.
  10414.  
  10415. Suppose you have several pets in your home (your menagerie) and you'd
  10416. like to keep track of various types of information about them.  You can
  10417. do so by creating tables to hold your data and loading them with the
  10418. desired information.  Then you can answer different sorts of questions
  10419. about your animals by retrieving data from the tables.  This section
  10420. shows you how to:
  10421.  
  10422.    * Create a database
  10423.  
  10424.    * Create a table
  10425.  
  10426.    * Load data into the table
  10427.  
  10428.    * Retrieve data from the table in various ways
  10429.  
  10430.    * Use multiple tables
  10431.  
  10432. The menagerie database will be simple (deliberately), but it is not
  10433. difficult to think of real-world situations in which a similar type of
  10434. database might be used.  For example, a database like this could be
  10435. used by a farmer to keep track of livestock, or by a veterinarian to
  10436. keep track of patient records.  A menagerie distribution containing
  10437. some of the queries and sample data used in the following sections can
  10438. be obtained from the MySQL Web site.  It's available in either
  10439. compressed `tar' format
  10440. (http://www.mysql.com/Downloads/Contrib/Examples/menagerie.tar.gz) or
  10441. Zip format
  10442. (http://www.mysql.com/Downloads/Contrib/Examples/menagerie.zip).
  10443.  
  10444. Use the `SHOW' statement to find out what databases currently exist on
  10445. the server:
  10446.  
  10447.      mysql> SHOW DATABASES;
  10448.      +----------+
  10449.      | Database |
  10450.      +----------+
  10451.      | mysql    |
  10452.      | test     |
  10453.      | tmp      |
  10454.      +----------+
  10455.  
  10456. The list of databases is probably different on your machine, but the
  10457. `mysql' and `test' databases are likely to be among them.  The `mysql'
  10458. database is required because it describes user access privileges.  The
  10459. `test' database is often provided as a workspace for users to try
  10460. things out.
  10461.  
  10462. If the `test' database exists, try to access it:
  10463.  
  10464.      mysql> USE test
  10465.      Database changed
  10466.  
  10467. Note that `USE', like `QUIT', does not require a semicolon.  (You can
  10468. terminate such statements with a semicolon if you like; it does no
  10469. harm.)  The `USE' statement is special in another way, too:  it must be
  10470. given on a single line.
  10471.  
  10472. You can use the `test' database (if you have access to it) for the
  10473. examples that follow, but anything you create in that database can be
  10474. removed by anyone else with access to it.  For this reason, you should
  10475. probably ask your MySQL administrator for permission to use a database
  10476. of your own.  Suppose you want to call yours `menagerie'.  The
  10477. administrator needs to execute a command like this:
  10478.  
  10479.      mysql> GRANT ALL ON menagerie.* TO your_mysql_name;
  10480.  
  10481. where `your_mysql_name' is the MySQL user name assigned to you.
  10482.  
  10483. 
  10484. File: mysql.info,  Node: Creating database,  Next: Creating tables,  Prev: Database use,  Up: Database use
  10485.  
  10486. Creating and Selecting a Database
  10487. ---------------------------------
  10488.  
  10489. If the administrator creates your database for you when setting up your
  10490. permissions, you can begin using it.  Otherwise, you need to create it
  10491. yourself:
  10492.  
  10493.      mysql> CREATE DATABASE menagerie;
  10494.  
  10495. Under Unix, database names are case sensitive (unlike SQL keywords), so
  10496. you must always refer to your database as `menagerie', not as
  10497. `Menagerie', `MENAGERIE', or some other variant.  This is also true for
  10498. table names.  (Under Windows, this restriction does not apply, although
  10499. you must refer to databases and tables using the same lettercase
  10500. throughout a given query.)
  10501.  
  10502. Creating a database does not select it for use; you must do that
  10503. explicitly.  To make `menagerie' the current database, use this command:
  10504.  
  10505.      mysql> USE menagerie
  10506.      Database changed
  10507.  
  10508. Your database needs to be created only once, but you must select it for
  10509. use each time you begin a `mysql' session.  You can do this by issuing a
  10510. `USE' statement as shown above.  Alternatively, you can select the
  10511. database on the command line when you invoke `mysql'.  Just specify its
  10512. name after any connection parameters that you might need to provide.
  10513. For example:
  10514.  
  10515.      shell> mysql -h host -u user -p menagerie
  10516.      Enter password: ********
  10517.  
  10518. Note that `menagerie' is not your password on the command just shown.
  10519. If you want to supply your password on the command line after the `-p'
  10520. option, you must do so with no intervening space (for example, as
  10521. `-pmypassword', not as `-p mypassword').  However, putting your
  10522. password on the command line is not recommended, because doing so
  10523. exposes it to snooping by other users logged in on your machine.
  10524.  
  10525. 
  10526. File: mysql.info,  Node: Creating tables,  Next: Loading tables,  Prev: Creating database,  Up: Database use
  10527.  
  10528. Creating a Table
  10529. ----------------
  10530.  
  10531. Creating the database is the easy part, but at this point it's empty, as
  10532. `SHOW TABLES' will tell you:
  10533.  
  10534.      mysql> SHOW TABLES;
  10535.      Empty set (0.00 sec)
  10536.  
  10537. The harder part is deciding what the structure of your database should
  10538. be: what tables you will need and what columns will be in each of them.
  10539.  
  10540. You'll want a table that contains a record for each of your pets.  This
  10541. can be called the `pet' table, and it should contain, as a bare minimum,
  10542. each animal's name.  Because the name by itself is not very
  10543. interesting, the table should contain other information.  For example,
  10544. if more than one person in your family keeps pets, you might want to
  10545. list each animal's owner.  You might also want to record some basic
  10546. descriptive information such as species and sex.
  10547.  
  10548. How about age?  That might be of interest, but it's not a good thing to
  10549. store in a database.  Age changes as time passes, which means you'd
  10550. have to update your records often.  Instead, it's better to store a
  10551. fixed value such as date of birth.  Then, whenever you need age, you
  10552. can calculate it as the difference between the current date and the
  10553. birth date.  MySQL provides functions for doing date arithmetic, so
  10554. this is not difficult.  Storing birth date rather than age has other
  10555. advantages, too:
  10556.  
  10557.    * You can use the database for tasks such as generating reminders
  10558.      for upcoming pet birthdays.  (If you think this type of query is
  10559.      somewhat silly, note that it is the same question you might ask in
  10560.      the context of a business database to identify clients to whom
  10561.      you'll soon need to send out birthday greetings, for that
  10562.      computer-assisted personal touch.)
  10563.  
  10564.    * You can calculate age in relation to dates other than the current
  10565.      date.  For example, if you store death date in the database, you
  10566.      can easily calculate how old a pet was when it died.
  10567.  
  10568. You can probably think of other types of information that would be
  10569. useful in the `pet' table, but the ones identified so far are
  10570. sufficient for now: name, owner, species, sex, birth, and death.
  10571.  
  10572. Use a `CREATE TABLE' statement to specify the layout of your table:
  10573.  
  10574.      mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),
  10575.          -> species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
  10576.  
  10577. `VARCHAR' is a good choice for the `name', `owner', and `species'
  10578. columns because the column values will vary in length.  The lengths of
  10579. those columns need not all be the same, and need not be `20'.  You can
  10580. pick any length from `1' to `255', whatever seems most reasonable to
  10581. you.  (If you make a poor choice and it turns out later that you need a
  10582. longer field, MySQL provides an `ALTER TABLE' statement.)
  10583.  
  10584. Animal sex can be represented in a variety of ways, for example, `"m"'
  10585. and `"f"', or perhaps `"male"' and `"female"'.  It's simplest to use
  10586. the single characters `"m"' and `"f"'.
  10587.  
  10588. The use of the `DATE' data type for the `birth' and `death' columns is
  10589. a fairly obvious choice.
  10590.  
  10591. Now that you have created a table, `SHOW TABLES' should produce some
  10592. output:
  10593.  
  10594.      mysql> SHOW TABLES;
  10595.      +---------------------+
  10596.      | Tables in menagerie |
  10597.      +---------------------+
  10598.      | pet                 |
  10599.      +---------------------+
  10600.  
  10601. To verify that your table was created the way you expected, use a
  10602. `DESCRIBE' statement:
  10603.  
  10604.      mysql> DESCRIBE pet;
  10605.      +---------+-------------+------+-----+---------+-------+
  10606.      | Field   | Type        | Null | Key | Default | Extra |
  10607.      +---------+-------------+------+-----+---------+-------+
  10608.      | name    | varchar(20) | YES  |     | NULL    |       |
  10609.      | owner   | varchar(20) | YES  |     | NULL    |       |
  10610.      | species | varchar(20) | YES  |     | NULL    |       |
  10611.      | sex     | char(1)     | YES  |     | NULL    |       |
  10612.      | birth   | date        | YES  |     | NULL    |       |
  10613.      | death   | date        | YES  |     | NULL    |       |
  10614.      +---------+-------------+------+-----+---------+-------+
  10615.  
  10616. You can use `DESCRIBE' any time, for example, if you forget the names of
  10617. the columns in your table or what types they are.
  10618.  
  10619. 
  10620. File: mysql.info,  Node: Loading tables,  Next: Retrieving data,  Prev: Creating tables,  Up: Database use
  10621.  
  10622. Loading Data into a Table
  10623. -------------------------
  10624.  
  10625. After creating your table, you need to populate it.  The `LOAD DATA' and
  10626. `INSERT' statements are useful for this.
  10627.  
  10628. Suppose your pet records can be described as shown below.  (Observe
  10629. that MySQL expects dates in `YYYY-MM-DD' format; this may be different
  10630. than what you are used to.)
  10631.  
  10632. *name*       *owner*      *species*    *sex*        *birth*      *death*
  10633. Fluffy       Harold       cat          f            1993-02-04   
  10634. Claws        Gwen         cat          m            1994-03-17   
  10635. Buffy        Harold       dog          f            1989-05-13   
  10636. Fang         Benny        dog          m            1990-08-27   
  10637. Bowser       Diane        dog          m            1998-08-31   1995-07-29
  10638. Chirpy       Gwen         bird         f            1998-09-11   
  10639. Whistler     Gwen         bird                      1997-12-09   
  10640. Slim         Benny        snake        m            1996-04-29   
  10641.  
  10642. Because you are beginning with an empty table, an easy way to populate
  10643. it is to create a text file containing a row for each of your animals,
  10644. then load the contents of the file into the table with a single
  10645. statement.
  10646.  
  10647. You could create a text file `pet.txt' containing one record per line,
  10648. with values separated by tabs, and given in the order in which the
  10649. columns were listed in the `CREATE TABLE' statement.  For missing
  10650. values (such as unknown sexes or death dates for animals that are still
  10651. living), you can use `NULL' values.  To represent these in your text
  10652. file, use `\N'.  For example, the record for Whistler the bird would
  10653. look like this (where the whitespace between values is a single tab
  10654. character):
  10655.  
  10656. `Whistler'  `Gwen'      `bird'      `\N'        `1997-12-09'       `\N'
  10657.  
  10658. To load the text file `pet.txt' into the `pet' table, use this command:
  10659.  
  10660.      mysql> LOAD DATA LOCAL INFILE "pet.txt" INTO TABLE pet;
  10661.  
  10662. You can specify the column value separator and end of line marker
  10663. explicitly in the `LOAD DATA' statement if you wish, but the defaults
  10664. are tab and linefeed.  These are sufficient for the statement to read
  10665. the file `pet.txt' properly.
  10666.  
  10667. When you want to add new records one at a time, the `INSERT' statement
  10668. is useful.  In its simplest form, you supply values for each column, in
  10669. the order in which the columns were listed in the `CREATE TABLE'
  10670. statement.  Suppose Diane gets a new hamster named Puffball.  You could
  10671. add a new record using an `INSERT' statement like this:
  10672.  
  10673.      mysql> INSERT INTO pet
  10674.          -> VALUES ('Puffball','Diane','hamster','f','1999-03-30',NULL);
  10675.  
  10676. Note that string and date values are specified as quoted strings here.
  10677. Also, with `INSERT', you can insert `NULL' directly to represent a
  10678. missing value.  You do not use `\N' like you do with `LOAD DATA'.
  10679.  
  10680. From this example, you should be able to see that there would be a lot
  10681. more typing involved to load your records initially using several
  10682. `INSERT' statements rather than a single `LOAD DATA' statement.
  10683.  
  10684. 
  10685. File: mysql.info,  Node: Retrieving data,  Prev: Loading tables,  Up: Database use
  10686.  
  10687. Retrieving Information from a Table
  10688. -----------------------------------
  10689.  
  10690. * Menu:
  10691.  
  10692. * Selecting all::               Selecting all data
  10693. * Selecting rows::              Selecting particular rows
  10694. * Selecting columns::           Selecting particular columns
  10695. * Sorting rows::                Sorting rows
  10696. * Date calculations::           Date calculations
  10697. * Working with NULL::           Working with `NULL' values
  10698. * Pattern matching::            Pattern matching
  10699. * Counting rows::               Counting rows
  10700. * Multiple tables::             Using More Than one Table
  10701.  
  10702. The `SELECT' statement is used to pull information from a table.  The
  10703. general form of the statement is:
  10704.  
  10705.      SELECT what_to_select
  10706.      FROM which_table
  10707.      WHERE conditions_to_satisfy
  10708.  
  10709. `what_to_select' indicates what you want to see.  This can be a list of
  10710. columns, or `*' to indicate "all columns." `which_table' indicates the
  10711. table from which you want to retrieve data.  The `WHERE' clause is
  10712. optional.  If it's present, `conditions_to_satisfy' specifies
  10713. conditions that rows must satisfy to qualify for retrieval.
  10714.  
  10715. 
  10716. File: mysql.info,  Node: Selecting all,  Next: Selecting rows,  Prev: Retrieving data,  Up: Retrieving data
  10717.  
  10718. Selecting All Data
  10719. ..................
  10720.  
  10721. The simplest form of `SELECT' retrieves everything from a table:
  10722.  
  10723.      mysql> SELECT * FROM pet;
  10724.      +----------+--------+---------+------+------------+------------+
  10725.      | name     | owner  | species | sex  | birth      | death      |
  10726.      +----------+--------+---------+------+------------+------------+
  10727.      | Fluffy   | Harold | cat     | f    | 1993-02-04 | NULL       |
  10728.      | Claws    | Gwen   | cat     | m    | 1994-03-17 | NULL       |
  10729.      | Buffy    | Harold | dog     | f    | 1989-05-13 | NULL       |
  10730.      | Fang     | Benny  | dog     | m    | 1990-08-27 | NULL       |
  10731.      | Bowser   | Diane  | dog     | m    | 1998-08-31 | 1995-07-29 |
  10732.      | Chirpy   | Gwen   | bird    | f    | 1998-09-11 | NULL       |
  10733.      | Whistler | Gwen   | bird    | NULL | 1997-12-09 | NULL       |
  10734.      | Slim     | Benny  | snake   | m    | 1996-04-29 | NULL       |
  10735.      | Puffball | Diane  | hamster | f    | 1999-03-30 | NULL       |
  10736.      +----------+--------+---------+------+------------+------------+
  10737.  
  10738. This form of `SELECT' is useful if you want to review your entire table,
  10739. for instance, after you've just loaded it with your initial dataset.
  10740. As it happens, the output just shown reveals an error in your data
  10741. file:  Bowser appears to have been born after he died!  Consulting your
  10742. original pedigree papers, you find that the correct birth year is 1989,
  10743. not 1998.
  10744.  
  10745. There are are least a couple of ways to fix this:
  10746.  
  10747.    * Edit the file `pet.txt' to correct the error, then empty the table
  10748.      and reload it using `DELETE' and `LOAD DATA':
  10749.  
  10750.           mysql> SET AUTOCOMMIT=1;  # Used for quick re-create of the table
  10751.           mysql> DELETE FROM pet;
  10752.           mysql> LOAD DATA LOCAL INFILE "pet.txt" INTO TABLE pet;
  10753.  
  10754.      However, if you do this, you must also re-enter the record for
  10755.      Puffball.
  10756.  
  10757.    * Fix only the erroneous record with an `UPDATE' statement:
  10758.  
  10759.           mysql> UPDATE pet SET birth = "1989-08-31" WHERE name = "Bowser";
  10760.  
  10761. As shown above, it is easy to retrieve an entire table.  But typically
  10762. you don't want to do that, particularly when the table becomes large.
  10763. Instead, you're usually more interested in answering a particular
  10764. question, in which case you specify some constraints on the information
  10765. you want.  Let's look at some selection queries in terms of questions
  10766. about your pets that they answer.
  10767.  
  10768. 
  10769. File: mysql.info,  Node: Selecting rows,  Next: Selecting columns,  Prev: Selecting all,  Up: Retrieving data
  10770.  
  10771. Selecting Particular Rows
  10772. .........................
  10773.  
  10774. You can select only particular rows from your table.  For example, if
  10775. you want to verify the change that you made to Bowser's birth date,
  10776. select Bowser's record like this:
  10777.  
  10778.      mysql> SELECT * FROM pet WHERE name = "Bowser";
  10779.      +--------+-------+---------+------+------------+------------+
  10780.      | name   | owner | species | sex  | birth      | death      |
  10781.      +--------+-------+---------+------+------------+------------+
  10782.      | Bowser | Diane | dog     | m    | 1989-08-31 | 1995-07-29 |
  10783.      +--------+-------+---------+------+------------+------------+
  10784.  
  10785. The output confirms that the year is correctly recorded now as 1989,
  10786. not 1998.
  10787.  
  10788. String comparisons are normally case insensitive, so you can specify the
  10789. name as `"bowser"', `"BOWSER"', etc.  The query result will be the same.
  10790.  
  10791. You can specify conditions on any column, not just `name'.  For example,
  10792. if you want to know which animals were born after 1998, test the `birth'
  10793. column:
  10794.  
  10795.      mysql> SELECT * FROM pet WHERE birth >= "1998-1-1";
  10796.      +----------+-------+---------+------+------------+-------+
  10797.      | name     | owner | species | sex  | birth      | death |
  10798.      +----------+-------+---------+------+------------+-------+
  10799.      | Chirpy   | Gwen  | bird    | f    | 1998-09-11 | NULL  |
  10800.      | Puffball | Diane | hamster | f    | 1999-03-30 | NULL  |
  10801.      +----------+-------+---------+------+------------+-------+
  10802.  
  10803. You can combine conditions, for example, to locate female dogs:
  10804.  
  10805.      mysql> SELECT * FROM pet WHERE species = "dog" AND sex = "f";
  10806.      +-------+--------+---------+------+------------+-------+
  10807.      | name  | owner  | species | sex  | birth      | death |
  10808.      +-------+--------+---------+------+------------+-------+
  10809.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  10810.      +-------+--------+---------+------+------------+-------+
  10811.  
  10812. The preceding query uses the `AND' logical operator.  There is also an
  10813. `OR' operator:
  10814.  
  10815.      mysql> SELECT * FROM pet WHERE species = "snake" OR species = "bird";
  10816.      +----------+-------+---------+------+------------+-------+
  10817.      | name     | owner | species | sex  | birth      | death |
  10818.      +----------+-------+---------+------+------------+-------+
  10819.      | Chirpy   | Gwen  | bird    | f    | 1998-09-11 | NULL  |
  10820.      | Whistler | Gwen  | bird    | NULL | 1997-12-09 | NULL  |
  10821.      | Slim     | Benny | snake   | m    | 1996-04-29 | NULL  |
  10822.      +----------+-------+---------+------+------------+-------+
  10823.  
  10824. `AND' and `OR' may be intermixed.  If you do that, it's a good idea to
  10825. use parentheses to indicate how conditions should be grouped:
  10826.  
  10827.      mysql> SELECT * FROM pet WHERE (species = "cat" AND sex = "m")
  10828.          -> OR (species = "dog" AND sex = "f");
  10829.      +-------+--------+---------+------+------------+-------+
  10830.      | name  | owner  | species | sex  | birth      | death |
  10831.      +-------+--------+---------+------+------------+-------+
  10832.      | Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
  10833.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  10834.      +-------+--------+---------+------+------------+-------+
  10835.  
  10836. 
  10837. File: mysql.info,  Node: Selecting columns,  Next: Sorting rows,  Prev: Selecting rows,  Up: Retrieving data
  10838.  
  10839. Selecting Particular Columns
  10840. ............................
  10841.  
  10842. If you don't want to see entire rows from your table, just name the
  10843. columns in which you're interested, separated by commas.  For example,
  10844. if you want to know when your animals were born, select the `name' and
  10845. `birth' columns:
  10846.  
  10847.      mysql> SELECT name, birth FROM pet;
  10848.      +----------+------------+
  10849.      | name     | birth      |
  10850.      +----------+------------+
  10851.      | Fluffy   | 1993-02-04 |
  10852.      | Claws    | 1994-03-17 |
  10853.      | Buffy    | 1989-05-13 |
  10854.      | Fang     | 1990-08-27 |
  10855.      | Bowser   | 1989-08-31 |
  10856.      | Chirpy   | 1998-09-11 |
  10857.      | Whistler | 1997-12-09 |
  10858.      | Slim     | 1996-04-29 |
  10859.      | Puffball | 1999-03-30 |
  10860.      +----------+------------+
  10861.  
  10862. To find out who owns pets, use this query:
  10863.  
  10864.      mysql> SELECT owner FROM pet;
  10865.      +--------+
  10866.      | owner  |
  10867.      +--------+
  10868.      | Harold |
  10869.      | Gwen   |
  10870.      | Harold |
  10871.      | Benny  |
  10872.      | Diane  |
  10873.      | Gwen   |
  10874.      | Gwen   |
  10875.      | Benny  |
  10876.      | Diane  |
  10877.      +--------+
  10878.  
  10879. However, notice that the query simply retrieves the `owner' field from
  10880. each record, and some of them appear more than once.  To minimize the
  10881. output, retrieve each unique output record just once by adding the
  10882. keyword `DISTINCT':
  10883.  
  10884.      mysql> SELECT DISTINCT owner FROM pet;
  10885.      +--------+
  10886.      | owner  |
  10887.      +--------+
  10888.      | Benny  |
  10889.      | Diane  |
  10890.      | Gwen   |
  10891.      | Harold |
  10892.      +--------+
  10893.  
  10894. You can use a `WHERE' clause to combine row selection with column
  10895. selection.  For example, to get birth dates for dogs and cats only, use
  10896. this query:
  10897.  
  10898.      mysql> SELECT name, species, birth FROM pet
  10899.          -> WHERE species = "dog" OR species = "cat";
  10900.      +--------+---------+------------+
  10901.      | name   | species | birth      |
  10902.      +--------+---------+------------+
  10903.      | Fluffy | cat     | 1993-02-04 |
  10904.      | Claws  | cat     | 1994-03-17 |
  10905.      | Buffy  | dog     | 1989-05-13 |
  10906.      | Fang   | dog     | 1990-08-27 |
  10907.      | Bowser | dog     | 1989-08-31 |
  10908.      +--------+---------+------------+
  10909.  
  10910. 
  10911. File: mysql.info,  Node: Sorting rows,  Next: Date calculations,  Prev: Selecting columns,  Up: Retrieving data
  10912.  
  10913. Sorting Rows
  10914. ............
  10915.  
  10916. You may have noticed in the preceding examples that the result rows are
  10917. displayed in no particular order.  However, it's often easier to examine
  10918. query output when the rows are sorted in some meaningful way.  To sort a
  10919. result, use an `ORDER BY' clause.
  10920.  
  10921. Here are animal birthdays, sorted by date:
  10922.  
  10923.      mysql> SELECT name, birth FROM pet ORDER BY birth;
  10924.      +----------+------------+
  10925.      | name     | birth      |
  10926.      +----------+------------+
  10927.      | Buffy    | 1989-05-13 |
  10928.      | Bowser   | 1989-08-31 |
  10929.      | Fang     | 1990-08-27 |
  10930.      | Fluffy   | 1993-02-04 |
  10931.      | Claws    | 1994-03-17 |
  10932.      | Slim     | 1996-04-29 |
  10933.      | Whistler | 1997-12-09 |
  10934.      | Chirpy   | 1998-09-11 |
  10935.      | Puffball | 1999-03-30 |
  10936.      +----------+------------+
  10937.  
  10938. To sort in reverse order, add the `DESC' (descending) keyword to the
  10939. name of the column you are sorting by:
  10940.  
  10941.      mysql> SELECT name, birth FROM pet ORDER BY birth DESC;
  10942.      +----------+------------+
  10943.      | name     | birth      |
  10944.      +----------+------------+
  10945.      | Puffball | 1999-03-30 |
  10946.      | Chirpy   | 1998-09-11 |
  10947.      | Whistler | 1997-12-09 |
  10948.      | Slim     | 1996-04-29 |
  10949.      | Claws    | 1994-03-17 |
  10950.      | Fluffy   | 1993-02-04 |
  10951.      | Fang     | 1990-08-27 |
  10952.      | Bowser   | 1989-08-31 |
  10953.      | Buffy    | 1989-05-13 |
  10954.      +----------+------------+
  10955.  
  10956. You can sort on multiple columns.  For example, to sort by type of
  10957. animal, then by birth date within animal type with youngest animals
  10958. first, use the following query:
  10959.  
  10960.      mysql> SELECT name, species, birth FROM pet ORDER BY species, birth DESC;
  10961.      +----------+---------+------------+
  10962.      | name     | species | birth      |
  10963.      +----------+---------+------------+
  10964.      | Chirpy   | bird    | 1998-09-11 |
  10965.      | Whistler | bird    | 1997-12-09 |
  10966.      | Claws    | cat     | 1994-03-17 |
  10967.      | Fluffy   | cat     | 1993-02-04 |
  10968.      | Fang     | dog     | 1990-08-27 |
  10969.      | Bowser   | dog     | 1989-08-31 |
  10970.      | Buffy    | dog     | 1989-05-13 |
  10971.      | Puffball | hamster | 1999-03-30 |
  10972.      | Slim     | snake   | 1996-04-29 |
  10973.      +----------+---------+------------+
  10974.  
  10975. Note that the `DESC' keyword applies only to the column name immediately
  10976. preceding it (`birth'); `species' values are still sorted in ascending
  10977. order.
  10978.  
  10979. 
  10980. File: mysql.info,  Node: Date calculations,  Next: Working with NULL,  Prev: Sorting rows,  Up: Retrieving data
  10981.  
  10982. Date Calculations
  10983. .................
  10984.  
  10985. MySQL provides several functions that you can use to perform
  10986. calculations on dates, for example, to calculate ages or extract parts
  10987. of dates.
  10988.  
  10989. To determine how many years old each of your pets is, compute the
  10990. difference in the year part of the current date and the birth date, then
  10991. subtract one if the current date occurs earlier in the calendar year
  10992. than the birth date.  The following query shows, for each pet, the
  10993. birth date, the current date, and the age in years.
  10994.  
  10995.      mysql> SELECT name, birth, CURRENT_DATE,
  10996.          -> (YEAR(CURRENT_DATE)-YEAR(birth))
  10997.          -> - (RIGHT(CURRENT_DATE,5)<RIGHT(birth,5))
  10998.          -> AS age
  10999.          -> FROM pet;
  11000.      +----------+------------+--------------+------+
  11001.      | name     | birth      | CURRENT_DATE | age  |
  11002.      +----------+------------+--------------+------+
  11003.      | Fluffy   | 1993-02-04 | 2001-08-29   |    8 |
  11004.      | Claws    | 1994-03-17 | 2001-08-29   |    7 |
  11005.      | Buffy    | 1989-05-13 | 2001-08-29   |   12 |
  11006.      | Fang     | 1990-08-27 | 2001-08-29   |   11 |
  11007.      | Bowser   | 1989-08-31 | 2001-08-29   |   11 |
  11008.      | Chirpy   | 1998-09-11 | 2001-08-29   |    2 |
  11009.      | Whistler | 1997-12-09 | 2001-08-29   |    3 |
  11010.      | Slim     | 1996-04-29 | 2001-08-29   |    5 |
  11011.      | Puffball | 1999-03-30 | 2001-08-29   |    2 |
  11012.      +----------+------------+--------------+------+
  11013.  
  11014. Here, `YEAR()' pulls out the year part of a date and `RIGHT()' pulls
  11015. off the rightmost five characters that represent the `MM-DD' (calendar
  11016. year) part of the date.  The part of the expression that compares the
  11017. `MM-DD' values evaluates to 1 or 0, which adjusts the year difference
  11018. down a year if `CURRENT_DATE' occurs earlier in the year than `birth'.
  11019. The full expression is somewhat ungainly, so an alias (`age') is used
  11020. to make the output column label more meaningful.
  11021.  
  11022. The query works, but the result could be scanned more easily if the rows
  11023. were presented in some order.  This can be done by adding an `ORDER BY
  11024. name' clause to sort the output by name:
  11025.  
  11026.      mysql> SELECT name, birth, CURRENT_DATE,
  11027.          -> (YEAR(CURRENT_DATE)-YEAR(birth))
  11028.          -> - (RIGHT(CURRENT_DATE,5)<RIGHT(birth,5))
  11029.          -> AS age
  11030.          -> FROM pet ORDER BY name;
  11031.      +----------+------------+--------------+------+
  11032.      | name     | birth      | CURRENT_DATE | age  |
  11033.      +----------+------------+--------------+------+
  11034.      | Bowser   | 1989-08-31 | 2001-08-29   |   11 |
  11035.      | Buffy    | 1989-05-13 | 2001-08-29   |   12 |
  11036.      | Chirpy   | 1998-09-11 | 2001-08-29   |    2 |
  11037.      | Claws    | 1994-03-17 | 2001-08-29   |    7 |
  11038.      | Fang     | 1990-08-27 | 2001-08-29   |   11 |
  11039.      | Fluffy   | 1993-02-04 | 2001-08-29   |    8 |
  11040.      | Puffball | 1999-03-30 | 2001-08-29   |    2 |
  11041.      | Slim     | 1996-04-29 | 2001-08-29   |    5 |
  11042.      | Whistler | 1997-12-09 | 2001-08-29   |    3 |
  11043.      +----------+------------+--------------+------+
  11044.  
  11045. To sort the output by `age' rather than `name', just use a different
  11046. `ORDER BY' clause:
  11047.  
  11048.      mysql> SELECT name, birth, CURRENT_DATE,
  11049.          -> (YEAR(CURRENT_DATE)-YEAR(birth))
  11050.          -> - (RIGHT(CURRENT_DATE,5)<RIGHT(birth,5))
  11051.          -> AS age
  11052.          -> FROM pet ORDER BY age;
  11053.      +----------+------------+--------------+------+
  11054.      | name     | birth      | CURRENT_DATE | age  |
  11055.      +----------+------------+--------------+------+
  11056.      | Chirpy   | 1998-09-11 | 2001-08-29   |    2 |
  11057.      | Puffball | 1999-03-30 | 2001-08-29   |    2 |
  11058.      | Whistler | 1997-12-09 | 2001-08-29   |    3 |
  11059.      | Slim     | 1996-04-29 | 2001-08-29   |    5 |
  11060.      | Claws    | 1994-03-17 | 2001-08-29   |    7 |
  11061.      | Fluffy   | 1993-02-04 | 2001-08-29   |    8 |
  11062.      | Fang     | 1990-08-27 | 2001-08-29   |   11 |
  11063.      | Bowser   | 1989-08-31 | 2001-08-29   |   11 |
  11064.      | Buffy    | 1989-05-13 | 2001-08-29   |   12 |
  11065.      +----------+------------+--------------+------+
  11066.  
  11067. A similar query can be used to determine age at death for animals that
  11068. have died.  You determine which animals these are by checking whether
  11069. or not the `death' value is `NULL'.  Then, for those with non-`NULL'
  11070. values, compute the difference between the `death' and `birth' values:
  11071.  
  11072.      mysql> SELECT name, birth, death,
  11073.          -> (YEAR(death)-YEAR(birth)) - (RIGHT(death,5)<RIGHT(birth,5))
  11074.          -> AS age
  11075.          -> FROM pet WHERE death IS NOT NULL ORDER BY age;
  11076.      +--------+------------+------------+------+
  11077.      | name   | birth      | death      | age  |
  11078.      +--------+------------+------------+------+
  11079.      | Bowser | 1989-08-31 | 1995-07-29 |    5 |
  11080.      +--------+------------+------------+------+
  11081.  
  11082. The query uses `death IS NOT NULL' rather than `death != NULL' because
  11083. `NULL' is a special value.  This is explained later.  *Note Working
  11084. with `NULL': Working with NULL.
  11085.  
  11086. What if you want to know which animals have birthdays next month?  For
  11087. this type of calculation, year and day are irrelevant; you simply want
  11088. to extract the month part of the `birth' column.  MySQL provides several
  11089. date-part extraction functions, such as `YEAR()', `MONTH()', and
  11090. `DAYOFMONTH()'.  `MONTH()' is the appropriate function here.  To see
  11091. how it works, run a simple query that displays the value of both
  11092. `birth' and `MONTH(birth)':
  11093.  
  11094.      mysql> SELECT name, birth, MONTH(birth) FROM pet;
  11095.      +----------+------------+--------------+
  11096.      | name     | birth      | MONTH(birth) |
  11097.      +----------+------------+--------------+
  11098.      | Fluffy   | 1993-02-04 |            2 |
  11099.      | Claws    | 1994-03-17 |            3 |
  11100.      | Buffy    | 1989-05-13 |            5 |
  11101.      | Fang     | 1990-08-27 |            8 |
  11102.      | Bowser   | 1989-08-31 |            8 |
  11103.      | Chirpy   | 1998-09-11 |            9 |
  11104.      | Whistler | 1997-12-09 |           12 |
  11105.      | Slim     | 1996-04-29 |            4 |
  11106.      | Puffball | 1999-03-30 |            3 |
  11107.      +----------+------------+--------------+
  11108.  
  11109. Finding animals with birthdays in the upcoming month is easy, too.
  11110. Suppose the current month is April.  Then the month value is `4' and
  11111. you look for animals born in May (month 5) like this:
  11112.  
  11113.      mysql> SELECT name, birth FROM pet WHERE MONTH(birth) = 5;
  11114.      +-------+------------+
  11115.      | name  | birth      |
  11116.      +-------+------------+
  11117.      | Buffy | 1989-05-13 |
  11118.      +-------+------------+
  11119.  
  11120. There is a small complication if the current month is December, of
  11121. course.  You don't just add one to the month number (`12') and look for
  11122. animals born in month 13, because there is no such month.  Instead, you
  11123. look for animals born in January (month 1).
  11124.  
  11125. You can even write the query so that it works no matter what the current
  11126. month is.  That way you don't have to use a particular month number in
  11127. the query.  `DATE_ADD()' allows you to add a time interval to a given
  11128. date.  If you add a month to the value of `NOW()', then extract the
  11129. month part with `MONTH()', the result produces the month in which to
  11130. look for birthdays:
  11131.  
  11132.      mysql> SELECT name, birth FROM pet
  11133.          -> WHERE MONTH(birth) = MONTH(DATE_ADD(NOW(), INTERVAL 1 MONTH));
  11134.  
  11135. A different way to accomplish the same task is to add `1' to get the
  11136. next month after the current one (after using the modulo function
  11137. (`MOD') to wrap around the month value to `0' if it is currently `12'):
  11138.  
  11139.      mysql> SELECT name, birth FROM pet
  11140.          -> WHERE MONTH(birth) = MOD(MONTH(NOW()), 12) + 1;
  11141.  
  11142. Note that `MONTH' returns a number between 1 and 12. And
  11143. `MOD(something,12)' returns a number between 0 and 11. So the addition
  11144. has to be after the `MOD()', otherwise we would go from November (11)
  11145. to January (1).
  11146.  
  11147. 
  11148. File: mysql.info,  Node: Working with NULL,  Next: Pattern matching,  Prev: Date calculations,  Up: Retrieving data
  11149.  
  11150. Working with `NULL' Values
  11151. ..........................
  11152.  
  11153. The `NULL' value can be surprising until you get used to it.
  11154. Conceptually, `NULL' means missing value or unknown value and it is
  11155. treated somewhat differently than other values.  To test for `NULL',
  11156. you cannot use the arithmetic comparison operators such as `=', `<', or
  11157. `!='.  To demonstrate this for yourself, try the following query:
  11158.  
  11159.      mysql> SELECT 1 = NULL, 1 != NULL, 1 < NULL, 1 > NULL;
  11160.      +----------+-----------+----------+----------+
  11161.      | 1 = NULL | 1 != NULL | 1 < NULL | 1 > NULL |
  11162.      +----------+-----------+----------+----------+
  11163.      |     NULL |      NULL |     NULL |     NULL |
  11164.      +----------+-----------+----------+----------+
  11165.  
  11166. Clearly you get no meaningful results from these comparisons.  Use the
  11167. `IS NULL' and `IS NOT NULL' operators instead:
  11168.  
  11169.      mysql> SELECT 1 IS NULL, 1 IS NOT NULL;
  11170.      +-----------+---------------+
  11171.      | 1 IS NULL | 1 IS NOT NULL |
  11172.      +-----------+---------------+
  11173.      |         0 |             1 |
  11174.      +-----------+---------------+
  11175.  
  11176. In MySQL, 0 or `NULL' means false and anything else means true.  The
  11177. default truth value from a boolean operation is 1.
  11178.  
  11179. This special treatment of `NULL' is why, in the previous section, it
  11180. was necessary to determine which animals are no longer alive using
  11181. `death IS NOT NULL' instead of `death != NULL'.
  11182.  
  11183. 
  11184. File: mysql.info,  Node: Pattern matching,  Next: Counting rows,  Prev: Working with NULL,  Up: Retrieving data
  11185.  
  11186. Pattern Matching
  11187. ................
  11188.  
  11189. MySQL provides standard SQL pattern matching as well as a form of
  11190. pattern matching based on extended regular expressions similar to those
  11191. used by Unix utilities such as `vi', `grep', and `sed'.
  11192.  
  11193. SQL pattern matching allows you to use `_' to match any single
  11194. character and `%' to match an arbitrary number of characters (including
  11195. zero characters).  In MySQL, SQL patterns are case insensitive by
  11196. default.  Some examples are shown below.  Note that you do not use `='
  11197. or `!=' when you use SQL patterns; use the `LIKE' or `NOT LIKE'
  11198. comparison operators instead.
  11199.  
  11200. To find names beginning with `b':
  11201.  
  11202.      mysql> SELECT * FROM pet WHERE name LIKE "b%";
  11203.      +--------+--------+---------+------+------------+------------+
  11204.      | name   | owner  | species | sex  | birth      | death      |
  11205.      +--------+--------+---------+------+------------+------------+
  11206.      | Buffy  | Harold | dog     | f    | 1989-05-13 | NULL       |
  11207.      | Bowser | Diane  | dog     | m    | 1989-08-31 | 1995-07-29 |
  11208.      +--------+--------+---------+------+------------+------------+
  11209.  
  11210. To find names ending with `fy':
  11211.  
  11212.      mysql> SELECT * FROM pet WHERE name LIKE "%fy";
  11213.      +--------+--------+---------+------+------------+-------+
  11214.      | name   | owner  | species | sex  | birth      | death |
  11215.      +--------+--------+---------+------+------------+-------+
  11216.      | Fluffy | Harold | cat     | f    | 1993-02-04 | NULL  |
  11217.      | Buffy  | Harold | dog     | f    | 1989-05-13 | NULL  |
  11218.      +--------+--------+---------+------+------------+-------+
  11219.  
  11220. To find names containing a `w':
  11221.  
  11222.      mysql> SELECT * FROM pet WHERE name LIKE "%w%";
  11223.      +----------+-------+---------+------+------------+------------+
  11224.      | name     | owner | species | sex  | birth      | death      |
  11225.      +----------+-------+---------+------+------------+------------+
  11226.      | Claws    | Gwen  | cat     | m    | 1994-03-17 | NULL       |
  11227.      | Bowser   | Diane | dog     | m    | 1989-08-31 | 1995-07-29 |
  11228.      | Whistler | Gwen  | bird    | NULL | 1997-12-09 | NULL       |
  11229.      +----------+-------+---------+------+------------+------------+
  11230.  
  11231. To find names containing exactly five characters, use the `_' pattern
  11232. character:
  11233.  
  11234.      mysql> SELECT * FROM pet WHERE name LIKE "_____";
  11235.      +-------+--------+---------+------+------------+-------+
  11236.      | name  | owner  | species | sex  | birth      | death |
  11237.      +-------+--------+---------+------+------------+-------+
  11238.      | Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
  11239.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  11240.      +-------+--------+---------+------+------------+-------+
  11241.  
  11242. The other type of pattern matching provided by MySQL uses extended
  11243. regular expressions.  When you test for a match for this type of
  11244. pattern, use the `REGEXP' and `NOT REGEXP' operators (or `RLIKE' and
  11245. `NOT RLIKE', which are synonyms).
  11246.  
  11247. Some characteristics of extended regular expressions are:
  11248.  
  11249.    * `.' matches any single character.
  11250.  
  11251.    * A character class `[...]' matches any character within the
  11252.      brackets.  For example, `[abc]' matches `a', `b', or `c'.  To name
  11253.      a range of characters, use a dash.  `[a-z]' matches any lowercase
  11254.      letter, whereas `[0-9]' matches any digit.
  11255.  
  11256.    * `*' matches zero or more instances of the thing preceding it.  For
  11257.      example, `x*' matches any number of `x' characters, `[0-9]*'
  11258.      matches any number of digits, and `.*' matches any number of
  11259.      anything.
  11260.  
  11261.    * Regular expressions are case sensitive, but you can use a
  11262.      character class to match both lettercases if you wish.  For
  11263.      example, `[aA]' matches lowercase or uppercase `a' and `[a-zA-Z]'
  11264.      matches any letter in either case.
  11265.  
  11266.    * The pattern matches if it occurs anywhere in the value being
  11267.      tested.  (SQL patterns match only if they match the entire value.)
  11268.  
  11269.    * To anchor a pattern so that it must match the beginning or end of
  11270.      the value being tested, use `^' at the beginning or `$' at the end
  11271.      of the pattern.
  11272.  
  11273. To demonstrate how extended regular expressions work, the `LIKE' queries
  11274. shown above are rewritten below to use `REGEXP'.
  11275.  
  11276. To find names beginning with `b', use `^' to match the beginning of the
  11277. name:
  11278.  
  11279.      mysql> SELECT * FROM pet WHERE name REGEXP "^b";
  11280.      +--------+--------+---------+------+------------+------------+
  11281.      | name   | owner  | species | sex  | birth      | death      |
  11282.      +--------+--------+---------+------+------------+------------+
  11283.      | Buffy  | Harold | dog     | f    | 1989-05-13 | NULL       |
  11284.      | Bowser | Diane  | dog     | m    | 1989-08-31 | 1995-07-29 |
  11285.      +--------+--------+---------+------+------------+------------+
  11286.  
  11287. Prior to MySQL Version 3.23.4, `REGEXP' is case sensitive, and the
  11288. previous query will return no rows. To match either lowercase or
  11289. uppercase `b', use this query instead:
  11290.  
  11291.      mysql> SELECT * FROM pet WHERE name REGEXP "^[bB]";
  11292.  
  11293. From MySQL 3.23.4 on, to force a `REGEXP' comparison to be case
  11294. sensitive, use the `BINARY' keyword to make one of the strings a binary
  11295. string. This query will match only lowercase `b' at the beginning of a
  11296. name:
  11297.  
  11298.      mysql> SELECT * FROM pet WHERE name REGEXP BINARY "^b";
  11299.  
  11300. To find names ending with `fy', use `$' to match the end of the name:
  11301.  
  11302.      mysql> SELECT * FROM pet WHERE name REGEXP "fy$";
  11303.      +--------+--------+---------+------+------------+-------+
  11304.      | name   | owner  | species | sex  | birth      | death |
  11305.      +--------+--------+---------+------+------------+-------+
  11306.      | Fluffy | Harold | cat     | f    | 1993-02-04 | NULL  |
  11307.      | Buffy  | Harold | dog     | f    | 1989-05-13 | NULL  |
  11308.      +--------+--------+---------+------+------------+-------+
  11309.  
  11310. To find names containing a lowercase or uppercase `w', use this query:
  11311.  
  11312.      mysql> SELECT * FROM pet WHERE name REGEXP "w";
  11313.      +----------+-------+---------+------+------------+------------+
  11314.      | name     | owner | species | sex  | birth      | death      |
  11315.      +----------+-------+---------+------+------------+------------+
  11316.      | Claws    | Gwen  | cat     | m    | 1994-03-17 | NULL       |
  11317.      | Bowser   | Diane | dog     | m    | 1989-08-31 | 1995-07-29 |
  11318.      | Whistler | Gwen  | bird    | NULL | 1997-12-09 | NULL       |
  11319.      +----------+-------+---------+------+------------+------------+
  11320.  
  11321. Because a regular expression pattern matches if it occurs anywhere in
  11322. the value, it is not necessary in the previous query to put a wild card
  11323. on either side of the pattern to get it to match the entire value like
  11324. it would be if you used a SQL pattern.
  11325.  
  11326. To find names containing exactly five characters, use `^' and `$' to
  11327. match the beginning and end of the name, and five instances of `.' in
  11328. between:
  11329.  
  11330.      mysql> SELECT * FROM pet WHERE name REGEXP "^.....$";
  11331.      +-------+--------+---------+------+------------+-------+
  11332.      | name  | owner  | species | sex  | birth      | death |
  11333.      +-------+--------+---------+------+------------+-------+
  11334.      | Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
  11335.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  11336.      +-------+--------+---------+------+------------+-------+
  11337.  
  11338. You could also write the previous query using the `{n}'
  11339. "repeat-`n'-times" operator:
  11340.  
  11341.      mysql> SELECT * FROM pet WHERE name REGEXP "^.{5}$";
  11342.      +-------+--------+---------+------+------------+-------+
  11343.      | name  | owner  | species | sex  | birth      | death |
  11344.      +-------+--------+---------+------+------------+-------+
  11345.      | Claws | Gwen   | cat     | m    | 1994-03-17 | NULL  |
  11346.      | Buffy | Harold | dog     | f    | 1989-05-13 | NULL  |
  11347.      +-------+--------+---------+------+------------+-------+
  11348.  
  11349. 
  11350. File: mysql.info,  Node: Counting rows,  Next: Multiple tables,  Prev: Pattern matching,  Up: Retrieving data
  11351.  
  11352. Counting Rows
  11353. .............
  11354.  
  11355. Databases are often used to answer the question, "How often does a
  11356. certain type of data occur in a table?"  For example, you might want to
  11357. know how many pets you have, or how many pets each owner has, or you
  11358. might want to perform various kinds of censuses on your animals.
  11359.  
  11360. Counting the total number of animals you have is the same question as
  11361. "How many rows are in the `pet' table?" because there is one record per
  11362. pet.  The `COUNT()' function counts the number of non-`NULL' results, so
  11363. the query to count your animals looks like this:
  11364.  
  11365.      mysql> SELECT COUNT(*) FROM pet;
  11366.      +----------+
  11367.      | COUNT(*) |
  11368.      +----------+
  11369.      |        9 |
  11370.      +----------+
  11371.  
  11372. Earlier, you retrieved the names of the people who owned pets.  You can
  11373. use `COUNT()' if you want to find out how many pets each owner has:
  11374.  
  11375.      mysql> SELECT owner, COUNT(*) FROM pet GROUP BY owner;
  11376.      +--------+----------+
  11377.      | owner  | COUNT(*) |
  11378.      +--------+----------+
  11379.      | Benny  |        2 |
  11380.      | Diane  |        2 |
  11381.      | Gwen   |        3 |
  11382.      | Harold |        2 |
  11383.      +--------+----------+
  11384.  
  11385. Note the use of `GROUP BY' to group together all records for each
  11386. `owner'.  Without it, all you get is an error message:
  11387.  
  11388.      mysql> SELECT owner, COUNT(owner) FROM pet;
  11389.      ERROR 1140 at line 1: Mixing of GROUP columns (MIN(),MAX(),COUNT()...)
  11390.      with no GROUP columns is illegal if there is no GROUP BY clause
  11391.  
  11392. `COUNT()' and `GROUP BY' are useful for characterizing your data in
  11393. various ways.  The following examples show different ways to perform
  11394. animal census operations.
  11395.  
  11396. Number of animals per species:
  11397.  
  11398.      mysql> SELECT species, COUNT(*) FROM pet GROUP BY species;
  11399.      +---------+----------+
  11400.      | species | COUNT(*) |
  11401.      +---------+----------+
  11402.      | bird    |        2 |
  11403.      | cat     |        2 |
  11404.      | dog     |        3 |
  11405.      | hamster |        1 |
  11406.      | snake   |        1 |
  11407.      +---------+----------+
  11408.  
  11409. Number of animals per sex:
  11410.  
  11411.      mysql> SELECT sex, COUNT(*) FROM pet GROUP BY sex;
  11412.      +------+----------+
  11413.      | sex  | COUNT(*) |
  11414.      +------+----------+
  11415.      | NULL |        1 |
  11416.      | f    |        4 |
  11417.      | m    |        4 |
  11418.      +------+----------+
  11419.  
  11420. (In this output, `NULL' indicates sex unknown.)
  11421.  
  11422. Number of animals per combination of species and sex:
  11423.  
  11424.      mysql> SELECT species, sex, COUNT(*) FROM pet GROUP BY species, sex;
  11425.      +---------+------+----------+
  11426.      | species | sex  | COUNT(*) |
  11427.      +---------+------+----------+
  11428.      | bird    | NULL |        1 |
  11429.      | bird    | f    |        1 |
  11430.      | cat     | f    |        1 |
  11431.      | cat     | m    |        1 |
  11432.      | dog     | f    |        1 |
  11433.      | dog     | m    |        2 |
  11434.      | hamster | f    |        1 |
  11435.      | snake   | m    |        1 |
  11436.      +---------+------+----------+
  11437.  
  11438. You need not retrieve an entire table when you use `COUNT()'.  For
  11439. example, the previous query, when performed just on dogs and cats,
  11440. looks like this:
  11441.  
  11442.      mysql> SELECT species, sex, COUNT(*) FROM pet
  11443.          -> WHERE species = "dog" OR species = "cat"
  11444.          -> GROUP BY species, sex;
  11445.      +---------+------+----------+
  11446.      | species | sex  | COUNT(*) |
  11447.      +---------+------+----------+
  11448.      | cat     | f    |        1 |
  11449.      | cat     | m    |        1 |
  11450.      | dog     | f    |        1 |
  11451.      | dog     | m    |        2 |
  11452.      +---------+------+----------+
  11453.  
  11454. Or, if you wanted the number of animals per sex only for known-sex
  11455. animals:
  11456.  
  11457.      mysql> SELECT species, sex, COUNT(*) FROM pet
  11458.          -> WHERE sex IS NOT NULL
  11459.          -> GROUP BY species, sex;
  11460.      +---------+------+----------+
  11461.      | species | sex  | COUNT(*) |
  11462.      +---------+------+----------+
  11463.      | bird    | f    |        1 |
  11464.      | cat     | f    |        1 |
  11465.      | cat     | m    |        1 |
  11466.      | dog     | f    |        1 |
  11467.      | dog     | m    |        2 |
  11468.      | hamster | f    |        1 |
  11469.      | snake   | m    |        1 |
  11470.      +---------+------+----------+
  11471.  
  11472. 
  11473. File: mysql.info,  Node: Multiple tables,  Prev: Counting rows,  Up: Retrieving data
  11474.  
  11475. Using More Than one Table
  11476. .........................
  11477.  
  11478. The `pet' table keeps track of which pets you have.  If you want to
  11479. record other information about them, such as events in their lives like
  11480. visits to the vet or when litters are born, you need another table.
  11481. What should this table look like? It needs:
  11482.  
  11483.    * To contain the pet name so you know which animal each event
  11484.      pertains to.
  11485.  
  11486.    * A date so you know when the event occurred.
  11487.  
  11488.    * A field to describe the event.
  11489.  
  11490.    * An event type field, if you want to be able to categorize events.
  11491.  
  11492. Given these considerations, the `CREATE TABLE' statement for the
  11493. `event' table might look like this:
  11494.  
  11495.      mysql> CREATE TABLE event (name VARCHAR(20), date DATE,
  11496.          -> type VARCHAR(15), remark VARCHAR(255));
  11497.  
  11498. As with the `pet' table, it's easiest to load the initial records by
  11499. creating a tab-delimited text file containing the information:
  11500.  
  11501. Fluffy      1995-05-15  litter      4 kittens, 3 female, 1 male
  11502. Buffy       1993-06-23  litter      5 puppies, 2 female, 3 male
  11503. Buffy       1994-06-19  litter      3 puppies, 3 female
  11504. Chirpy      1999-03-21  vet         needed beak straightened
  11505. Slim        1997-08-03  vet         broken rib
  11506. Bowser      1991-10-12  kennel      
  11507. Fang        1991-10-12  kennel      
  11508. Fang        1998-08-28  birthday    Gave him a new chew toy
  11509. Claws       1998-03-17  birthday    Gave him a new flea collar
  11510. Whistler    1998-12-09  birthday    First birthday
  11511.  
  11512. Load the records like this:
  11513.  
  11514.      mysql> LOAD DATA LOCAL INFILE "event.txt" INTO TABLE event;
  11515.  
  11516. Based on what you've learned from the queries you've run on the `pet'
  11517. table, you should be able to perform retrievals on the records in the
  11518. `event' table; the principles are the same.  But when is the `event'
  11519. table by itself insufficient to answer questions you might ask?
  11520.  
  11521. Suppose you want to find out the ages of each pet when they had their
  11522. litters.  The `event' table indicates when this occurred, but to
  11523. calculate the age of the mother, you need her birth date.  Because that
  11524. is stored in the `pet' table, you need both tables for the query:
  11525.  
  11526.      mysql> SELECT pet.name, (TO_DAYS(date) - TO_DAYS(birth))/365 AS age, remark
  11527.          -> FROM pet, event
  11528.          -> WHERE pet.name = event.name AND type = "litter";
  11529.      +--------+------+-----------------------------+
  11530.      | name   | age  | remark                      |
  11531.      +--------+------+-----------------------------+
  11532.      | Fluffy | 2.27 | 4 kittens, 3 female, 1 male |
  11533.      | Buffy  | 4.12 | 5 puppies, 2 female, 3 male |
  11534.      | Buffy  | 5.10 | 3 puppies, 3 female         |
  11535.      +--------+------+-----------------------------+
  11536.  
  11537. There are several things to note about this query:
  11538.  
  11539.    * The `FROM' clause lists two tables because the query needs to pull
  11540.      information from both of them.
  11541.  
  11542.    * When combining (joining) information from multiple tables, you
  11543.      need to specify how records in one table can be matched to records
  11544.      in the other.  This is easy because they both have a `name'
  11545.      column.  The query uses `WHERE' clause to match up records in the
  11546.      two tables based on the `name' values.
  11547.  
  11548.    * Because the `name' column occurs in both tables, you must be
  11549.      specific about which table you mean when referring to the column.
  11550.      This is done by prepending the table name to the column name.
  11551.  
  11552. You need not have two different tables to perform a join.  Sometimes it
  11553. is useful to join a table to itself, if you want to compare records in
  11554. a table to other records in that same table.  For example, to find
  11555. breeding pairs among your pets, you can join the `pet' table with
  11556. itself to pair up males and females of like species:
  11557.  
  11558.      mysql> SELECT p1.name, p1.sex, p2.name, p2.sex, p1.species
  11559.          -> FROM pet AS p1, pet AS p2
  11560.          -> WHERE p1.species = p2.species AND p1.sex = "f" AND p2.sex = "m";
  11561.      +--------+------+--------+------+---------+
  11562.      | name   | sex  | name   | sex  | species |
  11563.      +--------+------+--------+------+---------+
  11564.      | Fluffy | f    | Claws  | m    | cat     |
  11565.      | Buffy  | f    | Fang   | m    | dog     |
  11566.      | Buffy  | f    | Bowser | m    | dog     |
  11567.      +--------+------+--------+------+---------+
  11568.  
  11569. In this query, we specify aliases for the table name in order to refer
  11570. to the columns and keep straight which instance of the table each
  11571. column reference is associated with.
  11572.  
  11573. 
  11574. File: mysql.info,  Node: Getting information,  Next: Examples,  Prev: Database use,  Up: Tutorial
  11575.  
  11576. Getting Information About Databases and Tables
  11577. ==============================================
  11578.  
  11579. What if you forget the name of a database or table, or what the
  11580. structure of a given table is (for example, what its columns are
  11581. called)?  MySQL addresses this problem through several statements that
  11582. provide information about the databases and tables it supports.
  11583.  
  11584. You have already seen `SHOW DATABASES', which lists the databases
  11585. managed by the server.  To find out which database is currently
  11586. selected, use the `DATABASE()' function:
  11587.  
  11588.      mysql> SELECT DATABASE();
  11589.      +------------+
  11590.      | DATABASE() |
  11591.      +------------+
  11592.      | menagerie  |
  11593.      +------------+
  11594.  
  11595. If you haven't selected any database yet, the result is blank.
  11596.  
  11597. To find out what tables the current database contains (for example, when
  11598. you're not sure about the name of a table), use this command:
  11599.  
  11600.      mysql> SHOW TABLES;
  11601.      +---------------------+
  11602.      | Tables in menagerie |
  11603.      +---------------------+
  11604.      | event               |
  11605.      | pet                 |
  11606.      +---------------------+
  11607.  
  11608. If you want to find out about the structure of a table, the `DESCRIBE'
  11609. command is useful; it displays information about each of a table's
  11610. columns:
  11611.  
  11612.      mysql> DESCRIBE pet;
  11613.      +---------+-------------+------+-----+---------+-------+
  11614.      | Field   | Type        | Null | Key | Default | Extra |
  11615.      +---------+-------------+------+-----+---------+-------+
  11616.      | name    | varchar(20) | YES  |     | NULL    |       |
  11617.      | owner   | varchar(20) | YES  |     | NULL    |       |
  11618.      | species | varchar(20) | YES  |     | NULL    |       |
  11619.      | sex     | char(1)     | YES  |     | NULL    |       |
  11620.      | birth   | date        | YES  |     | NULL    |       |
  11621.      | death   | date        | YES  |     | NULL    |       |
  11622.      +---------+-------------+------+-----+---------+-------+
  11623.  
  11624. `Field' indicates the column name, `Type' is the data type for the
  11625. column, `Null' indicates whether or not the column can contain `NULL'
  11626. values, `Key' indicates whether or not the column is indexed, and
  11627. `Default' specifies the column's default value.
  11628.  
  11629. If you have indexes on a table, `SHOW INDEX FROM tbl_name' produces
  11630. information about them.
  11631.  
  11632. 
  11633. File: mysql.info,  Node: Examples,  Next: Batch mode,  Prev: Getting information,  Up: Tutorial
  11634.  
  11635. Examples of Common Queries
  11636. ==========================
  11637.  
  11638. Here are examples of how to solve some common problems with MySQL.
  11639.  
  11640. Some of the examples use the table `shop' to hold the price of each
  11641. article (item number) for certain traders (dealers).  Supposing that
  11642. each trader has a single fixed price per article, then (`article',
  11643. `dealer') is a primary key for the records.
  11644.  
  11645. Start the command line tool `mysql' and select a database:
  11646.  
  11647.      mysql your-database-name
  11648.  
  11649. (In most MySQL installations, you can use the database-name 'test').
  11650.  
  11651. You can create the example table as:
  11652.  
  11653.      CREATE TABLE shop (
  11654.       article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
  11655.       dealer  CHAR(20)                 DEFAULT ''     NOT NULL,
  11656.       price   DOUBLE(16,2)             DEFAULT '0.00' NOT NULL,
  11657.       PRIMARY KEY(article, dealer));
  11658.      
  11659.      INSERT INTO shop VALUES
  11660.      (1,'A',3.45),(1,'B',3.99),(2,'A',10.99),(3,'B',1.45),(3,'C',1.69),
  11661.      (3,'D',1.25),(4,'D',19.95);
  11662.  
  11663. Okay, so the example data is:
  11664.  
  11665.      mysql> SELECT * FROM shop;
  11666.      
  11667.      +---------+--------+-------+
  11668.      | article | dealer | price |
  11669.      +---------+--------+-------+
  11670.      |    0001 | A      |  3.45 |
  11671.      |    0001 | B      |  3.99 |
  11672.      |    0002 | A      | 10.99 |
  11673.      |    0003 | B      |  1.45 |
  11674.      |    0003 | C      |  1.69 |
  11675.      |    0003 | D      |  1.25 |
  11676.      |    0004 | D      | 19.95 |
  11677.      +---------+--------+-------+
  11678.  
  11679. * Menu:
  11680.  
  11681. * example-Maximum-column::      The maximum value for a column
  11682. * example-Maximum-row::         The row holding the maximum of a certain column
  11683. * example-Maximum-column-group::  Maximum of column per group
  11684. * example-Maximum-column-group-row::  The rows holding the group-wise maximum of a certain field
  11685. * example-user-variables::      Using user variables
  11686. * example-Foreign keys::        Using foreign keys
  11687. * Searching on two keys::       Searching on Two Keys
  11688. * Calculating days::            Calculating visits per day
  11689.  
  11690. 
  11691. File: mysql.info,  Node: example-Maximum-column,  Next: example-Maximum-row,  Prev: Examples,  Up: Examples
  11692.  
  11693. The Maximum Value for a Column
  11694. ------------------------------
  11695.  
  11696. "What's the highest item number?"
  11697.  
  11698.      SELECT MAX(article) AS article FROM shop
  11699.      
  11700.      +---------+
  11701.      | article |
  11702.      +---------+
  11703.      |       4 |
  11704.      +---------+
  11705.  
  11706. 
  11707. File: mysql.info,  Node: example-Maximum-row,  Next: example-Maximum-column-group,  Prev: example-Maximum-column,  Up: Examples
  11708.  
  11709. The Row Holding the Maximum of a Certain Column
  11710. -----------------------------------------------
  11711.  
  11712. "Find number, dealer, and price of the most expensive article."
  11713.  
  11714. In ANSI SQL this is easily done with a sub-query:
  11715.  
  11716.      SELECT article, dealer, price
  11717.      FROM   shop
  11718.      WHERE  price=(SELECT MAX(price) FROM shop)
  11719.  
  11720. In MySQL (which does not yet have sub-selects), just do it in two steps:
  11721.  
  11722.   1. Get the maximum price value from the table with a `SELECT'
  11723.      statement.
  11724.  
  11725.   2. Using this value compile the actual query:
  11726.           SELECT article, dealer, price
  11727.           FROM   shop
  11728.           WHERE  price=19.95
  11729.  
  11730. Another solution is to sort all rows descending by price and only get
  11731. the first row using the MySQL specific `LIMIT' clause:
  11732.  
  11733.      SELECT article, dealer, price
  11734.      FROM   shop
  11735.      ORDER BY price DESC
  11736.      LIMIT 1
  11737.  
  11738. *NOTE*:  If there are several most expensive articles (for example,
  11739. each 19.95) the `LIMIT' solution shows only one of them!
  11740.  
  11741. 
  11742. File: mysql.info,  Node: example-Maximum-column-group,  Next: example-Maximum-column-group-row,  Prev: example-Maximum-row,  Up: Examples
  11743.  
  11744. Maximum of Column per Group
  11745. ---------------------------
  11746.  
  11747. "What's the highest price per article?"
  11748.  
  11749.      SELECT article, MAX(price) AS price
  11750.      FROM   shop
  11751.      GROUP BY article
  11752.      
  11753.      +---------+-------+
  11754.      | article | price |
  11755.      +---------+-------+
  11756.      |    0001 |  3.99 |
  11757.      |    0002 | 10.99 |
  11758.      |    0003 |  1.69 |
  11759.      |    0004 | 19.95 |
  11760.      +---------+-------+
  11761.  
  11762. 
  11763. File: mysql.info,  Node: example-Maximum-column-group-row,  Next: example-user-variables,  Prev: example-Maximum-column-group,  Up: Examples
  11764.  
  11765. The Rows Holding the Group-wise Maximum of a Certain Field
  11766. ----------------------------------------------------------
  11767.  
  11768. "For each article, find the dealer(s) with the most expensive price."
  11769.  
  11770. In ANSI SQL, I'd do it with a sub-query like this:
  11771.  
  11772.      SELECT article, dealer, price
  11773.      FROM   shop s1
  11774.      WHERE  price=(SELECT MAX(s2.price)
  11775.                    FROM shop s2
  11776.                    WHERE s1.article = s2.article);
  11777.  
  11778. In MySQL it's best do it in several steps:
  11779.  
  11780.   1. Get the list of (article,maxprice).
  11781.  
  11782.   2. For each article get the corresponding rows that have the stored
  11783.      maximum price.
  11784.  
  11785. This can easily be done with a temporary table:
  11786.  
  11787.      CREATE TEMPORARY TABLE tmp (
  11788.              article INT(4) UNSIGNED ZEROFILL DEFAULT '0000' NOT NULL,
  11789.              price   DOUBLE(16,2)             DEFAULT '0.00' NOT NULL);
  11790.      
  11791.      LOCK TABLES shop read;
  11792.      
  11793.      INSERT INTO tmp SELECT article, MAX(price) FROM shop GROUP BY article;
  11794.      
  11795.      SELECT shop.article, dealer, shop.price FROM shop, tmp
  11796.      WHERE shop.article=tmp.article AND shop.price=tmp.price;
  11797.      
  11798.      UNLOCK TABLES;
  11799.      
  11800.      DROP TABLE tmp;
  11801.  
  11802. If you don't use a `TEMPORARY' table, you must also lock the 'tmp'
  11803. table.
  11804.  
  11805. "Can it be done with a single query?"
  11806.  
  11807. Yes, but only by using a quite inefficient trick that I call the
  11808. "MAX-CONCAT trick":
  11809.  
  11810.      SELECT article,
  11811.             SUBSTRING( MAX( CONCAT(LPAD(price,6,'0'),dealer) ), 7) AS dealer,
  11812.        0.00+LEFT(      MAX( CONCAT(LPAD(price,6,'0'),dealer) ), 6) AS price
  11813.      FROM   shop
  11814.      GROUP BY article;
  11815.      
  11816.      +---------+--------+-------+
  11817.      | article | dealer | price |
  11818.      +---------+--------+-------+
  11819.      |    0001 | B      |  3.99 |
  11820.      |    0002 | A      | 10.99 |
  11821.      |    0003 | C      |  1.69 |
  11822.      |    0004 | D      | 19.95 |
  11823.      +---------+--------+-------+
  11824.  
  11825. The last example can, of course, be made a bit more efficient by doing
  11826. the splitting of the concatenated column in the client.
  11827.  
  11828. 
  11829. File: mysql.info,  Node: example-user-variables,  Next: example-Foreign keys,  Prev: example-Maximum-column-group-row,  Up: Examples
  11830.  
  11831. Using user variables
  11832. --------------------
  11833.  
  11834. You can use MySQL user variables to remember results without having to
  11835. store them in temporary variables in the client.  *Note Variables::.
  11836.  
  11837. For example, to find the articles with the highest and lowest price you
  11838. can do:
  11839.  
  11840.      select @min_price:=min(price),@max_price:=max(price) from shop;
  11841.      select * from shop where price=@min_price or price=@max_price;
  11842.      
  11843.      +---------+--------+-------+
  11844.      | article | dealer | price |
  11845.      +---------+--------+-------+
  11846.      |    0003 | D      |  1.25 |
  11847.      |    0004 | D      | 19.95 |
  11848.      +---------+--------+-------+
  11849.  
  11850. 
  11851. File: mysql.info,  Node: example-Foreign keys,  Next: Searching on two keys,  Prev: example-user-variables,  Up: Examples
  11852.  
  11853. Using Foreign Keys
  11854. ------------------
  11855.  
  11856. You don't need foreign keys to join 2 tables.
  11857.  
  11858. The only thing MySQL doesn't do is `CHECK' to make sure that the keys
  11859. you use really exist in the table(s) you're referencing and it doesn't
  11860. automatically delete rows from table with a foreign key definition. If
  11861. you use your keys like normal, it'll work just fine:
  11862.  
  11863.      CREATE TABLE persons (
  11864.          id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
  11865.          name CHAR(60) NOT NULL,
  11866.          PRIMARY KEY (id)
  11867.      );
  11868.      
  11869.      CREATE TABLE shirts (
  11870.          id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
  11871.          style ENUM('t-shirt', 'polo', 'dress') NOT NULL,
  11872.          color ENUM('red', 'blue', 'orange', 'white', 'black') NOT NULL,
  11873.          owner SMALLINT UNSIGNED NOT NULL REFERENCES persons,
  11874.          PRIMARY KEY (id)
  11875.      );
  11876.      
  11877.      
  11878.      INSERT INTO persons VALUES (NULL, 'Antonio Paz');
  11879.      
  11880.      INSERT INTO shirts VALUES
  11881.      (NULL, 'polo', 'blue', LAST_INSERT_ID()),
  11882.      (NULL, 'dress', 'white', LAST_INSERT_ID()),
  11883.      (NULL, 't-shirt', 'blue', LAST_INSERT_ID());
  11884.      
  11885.      
  11886.      INSERT INTO persons VALUES (NULL, 'Lilliana Angelovska');
  11887.      
  11888.      INSERT INTO shirts VALUES
  11889.      (NULL, 'dress', 'orange', LAST_INSERT_ID()),
  11890.      (NULL, 'polo', 'red', LAST_INSERT_ID()),
  11891.      (NULL, 'dress', 'blue', LAST_INSERT_ID()),
  11892.      (NULL, 't-shirt', 'white', LAST_INSERT_ID());
  11893.      
  11894.      
  11895.      SELECT * FROM persons;
  11896.      +----+---------------------+
  11897.      | id | name                |
  11898.      +----+---------------------+
  11899.      |  1 | Antonio Paz         |
  11900.      |  2 | Lilliana Angelovska |
  11901.      +----+---------------------+
  11902.      
  11903.      SELECT * FROM shirts;
  11904.      +----+---------+--------+-------+
  11905.      | id | style   | color  | owner |
  11906.      +----+---------+--------+-------+
  11907.      |  1 | polo    | blue   |     1 |
  11908.      |  2 | dress   | white  |     1 |
  11909.      |  3 | t-shirt | blue   |     1 |
  11910.      |  4 | dress   | orange |     2 |
  11911.      |  5 | polo    | red    |     2 |
  11912.      |  6 | dress   | blue   |     2 |
  11913.      |  7 | t-shirt | white  |     2 |
  11914.      +----+---------+--------+-------+
  11915.      
  11916.      
  11917.      SELECT s.* FROM persons p, shirts s
  11918.       WHERE p.name LIKE 'Lilliana%'
  11919.         AND s.owner = p.id
  11920.         AND s.color <> 'white';
  11921.      
  11922.      +----+-------+--------+-------+
  11923.      | id | style | color  | owner |
  11924.      +----+-------+--------+-------+
  11925.      |  4 | dress | orange |     2 |
  11926.      |  5 | polo  | red    |     2 |
  11927.      |  6 | dress | blue   |     2 |
  11928.      +----+-------+--------+-------+
  11929.  
  11930. 
  11931. File: mysql.info,  Node: Searching on two keys,  Next: Calculating days,  Prev: example-Foreign keys,  Up: Examples
  11932.  
  11933. Searching on Two Keys
  11934. ---------------------
  11935.  
  11936. MySQL doesn't yet optimize when you search on two different keys
  11937. combined with `OR' (Searching on one key with different `OR' parts is
  11938. optimized quite good):
  11939.  
  11940.      SELECT field1_index, field2_index FROM test_table WHERE field1_index = '1'
  11941.      OR  field2_index = '1'
  11942.  
  11943. The reason is that we haven't yet had time to come up with an efficient
  11944. way to handle this in the general case. (The `AND' handling is, in
  11945. comparison, now completely general and works very well).
  11946.  
  11947. For the moment you can solve this very efficiently by using a
  11948. `TEMPORARY' table. This type of optimization is also very good if you
  11949. are using very complicated queries where the SQL server does the
  11950. optimizations in the wrong order.
  11951.  
  11952.      CREATE TEMPORARY TABLE tmp
  11953.      SELECT field1_index, field2_index FROM test_table WHERE field1_index = '1';
  11954.      INSERT INTO tmp
  11955.      SELECT field1_index, field2_index FROM test_table WHERE field2_index = '1';
  11956.      SELECT * from tmp;
  11957.      DROP TABLE tmp;
  11958.  
  11959. The above way to solve this query is in effect an `UNION' of two
  11960. queries.
  11961.  
  11962. 
  11963. File: mysql.info,  Node: Calculating days,  Prev: Searching on two keys,  Up: Examples
  11964.  
  11965. Calculating visits per day
  11966. --------------------------
  11967.  
  11968. The following shows an idea of how you can use the bit group functions
  11969. to calculate the number of days per month a user has visited a web page.
  11970.  
  11971.      CREATE TABLE t1 (year YEAR(4), month INT(2) UNSIGNED ZEROFILL, day INT(2) UNSIGNED ZEROFILL);
  11972.      INSERT INTO t1 VALUES(2000,1,1),(2000,1,20),(2000,1,30),(2000,2,2),(2000,2,23),(2000,2,23);
  11973.      
  11974.      SELECT year,month,BIT_COUNT(BIT_OR(1<<day)) AS days FROM t1 GROUP BY year,month;
  11975.      
  11976.      Which returns:
  11977.      
  11978.      +------+-------+------+
  11979.      | year | month | days |
  11980.      +------+-------+------+
  11981.      | 2000 |    01 |    3 |
  11982.      | 2000 |    02 |    2 |
  11983.      +------+-------+------+
  11984.  
  11985. The above calculates how many different days was used for a given
  11986. year/month combination, with automatic removal of duplicate entries.
  11987.  
  11988. 
  11989. File: mysql.info,  Node: Batch mode,  Next: Twin,  Prev: Examples,  Up: Tutorial
  11990.  
  11991. Using `mysql' in Batch Mode
  11992. ===========================
  11993.  
  11994. In the previous sections, you used `mysql' interactively to enter
  11995. queries and view the results.  You can also run `mysql' in batch mode.
  11996. To do this, put the commands you want to run in a file, then tell
  11997. `mysql' to read its input from the file:
  11998.  
  11999.      shell> mysql < batch-file
  12000.  
  12001. If you need to specify connection parameters on the command line, the
  12002. command might look like this:
  12003.  
  12004.      shell> mysql -h host -u user -p < batch-file
  12005.      Enter password: ********
  12006.  
  12007. When you use `mysql' this way, you are creating a script file, then
  12008. executing the script.
  12009.  
  12010. Why use a script?  Here are a few reasons:
  12011.  
  12012.    * If you run a query repeatedly (say, every day or every week),
  12013.      making it a script allows you to avoid retyping it each time you
  12014.      execute it.
  12015.  
  12016.    * You can generate new queries from existing ones that are similar
  12017.      by copying and editing script files.
  12018.  
  12019.    * Batch mode can also be useful while you're developing a query,
  12020.      particularly for multiple-line commands or multiple-statement
  12021.      sequences of commands.  If you make a mistake, you don't have to
  12022.      retype everything.  Just edit your script to correct the error,
  12023.      then tell `mysql' to execute it again.
  12024.  
  12025.    * If you have a query that produces a lot of output, you can run the
  12026.      output through a pager rather than watching it scroll off the top
  12027.      of your screen:
  12028.  
  12029.           shell> mysql < batch-file | more
  12030.  
  12031.    * You can catch the output in a file for further processing:
  12032.  
  12033.           shell> mysql < batch-file > mysql.out
  12034.  
  12035.    * You can distribute your script to other people so they can run the
  12036.      commands, too.
  12037.  
  12038.    * Some situations do not allow for interactive use, for example,
  12039.      when you run a query from a `cron' job.  In this case, you must
  12040.      use batch mode.
  12041.  
  12042. The default output format is different (more concise) when you run
  12043. `mysql' in batch mode than when you use it interactively.  For example,
  12044. the output of `SELECT DISTINCT species FROM pet' looks like this when
  12045. run interactively:
  12046.  
  12047.      +---------+
  12048.      | species |
  12049.      +---------+
  12050.      | bird    |
  12051.      | cat     |
  12052.      | dog     |
  12053.      | hamster |
  12054.      | snake   |
  12055.      +---------+
  12056.  
  12057. But like this when run in batch mode:
  12058.  
  12059.      species
  12060.      bird
  12061.      cat
  12062.      dog
  12063.      hamster
  12064.      snake
  12065.  
  12066. If you want to get the interactive output format in batch mode, use
  12067. `mysql -t'.  To echo to the output the commands that are executed, use
  12068. `mysql -vvv'.
  12069.  
  12070. 
  12071. File: mysql.info,  Node: Twin,  Next: Apache,  Prev: Batch mode,  Up: Tutorial
  12072.  
  12073. Queries from Twin Project
  12074. =========================
  12075.  
  12076. At Analytikerna and Lentus, we have been doing the systems and field
  12077. work for a big research project. This project is a collaboration
  12078. between the Institute of Environmental Medicine at Karolinska
  12079. Institutet Stockholm and the Section on Clinical Research in Aging and
  12080. Psychology at the University of Southern California.
  12081.  
  12082. The project involves a screening part where all twins in Sweden older
  12083. than 65 years are interviewed by telephone. Twins who meet certain
  12084. criteria are passed on to the next stage. In this latter stage, twins
  12085. who want to participate are visited by a doctor/nurse team. Some of the
  12086. examinations include physical and neuropsychological examination,
  12087. laboratory testing, neuroimaging, psychological status assessment, and
  12088. family history collection. In addition, data are collected on medical
  12089. and environmental risk factors.
  12090.  
  12091. More information about Twin studies can be found at:
  12092.  
  12093.      <http://www.imm.ki.se/TWIN/TWINUKW.HTM>
  12094.  
  12095. The latter part of the project is administered with a Web interface
  12096. written using Perl and MySQL.
  12097.  
  12098. Each night all data from the interviews are moved into a MySQL database.
  12099.  
  12100. * Menu:
  12101.  
  12102. * Twin pool::                   Find all non-distributed twins
  12103. * Twin event::                  Show a table on twin pair status
  12104.  
  12105. 
  12106. File: mysql.info,  Node: Twin pool,  Next: Twin event,  Prev: Twin,  Up: Twin
  12107.  
  12108. Find all Non-distributed Twins
  12109. ------------------------------
  12110.  
  12111. The following query is used to determine who goes into the second part
  12112. of the project:
  12113.  
  12114.      select
  12115.              concat(p1.id, p1.tvab) + 0 as tvid,
  12116.              concat(p1.christian_name, " ", p1.surname) as Name,
  12117.              p1.postal_code as Code,
  12118.              p1.city as City,
  12119.              pg.abrev as Area,
  12120.              if(td.participation = "Aborted", "A", " ") as A,
  12121.              p1.dead as dead1,
  12122.              l.event as event1,
  12123.              td.suspect as tsuspect1,
  12124.              id.suspect as isuspect1,
  12125.              td.severe as tsevere1,
  12126.              id.severe as isevere1,
  12127.              p2.dead as dead2,
  12128.              l2.event as event2,
  12129.              h2.nurse as nurse2,
  12130.              h2.doctor as doctor2,
  12131.              td2.suspect as tsuspect2,
  12132.              id2.suspect as isuspect2,
  12133.              td2.severe as tsevere2,
  12134.              id2.severe as isevere2,
  12135.              l.finish_date
  12136.      from
  12137.              twin_project as tp
  12138.              /* For Twin 1 */
  12139.              left join twin_data as td on tp.id = td.id and tp.tvab = td.tvab
  12140.              left join informant_data as id on tp.id = id.id and tp.tvab = id.tvab
  12141.              left join harmony as h on tp.id = h.id and tp.tvab = h.tvab
  12142.              left join lentus as l on tp.id = l.id and tp.tvab = l.tvab
  12143.              /* For Twin 2 */
  12144.              left join twin_data as td2 on p2.id = td2.id and p2.tvab = td2.tvab
  12145.              left join informant_data as id2 on p2.id = id2.id and p2.tvab = id2.tvab
  12146.              left join harmony as h2 on p2.id = h2.id and p2.tvab = h2.tvab
  12147.              left join lentus as l2 on p2.id = l2.id and p2.tvab = l2.tvab,
  12148.              person_data as p1,
  12149.              person_data as p2,
  12150.              postal_groups as pg
  12151.      where
  12152.              /* p1 gets main twin and p2 gets his/her twin. */
  12153.              /* ptvab is a field inverted from tvab */
  12154.              p1.id = tp.id and p1.tvab = tp.tvab and
  12155.              p2.id = p1.id and p2.ptvab = p1.tvab and
  12156.              /* Just the sceening survey */
  12157.              tp.survey_no = 5 and
  12158.              /* Skip if partner died before 65 but allow emigration (dead=9) */
  12159.              (p2.dead = 0 or p2.dead = 9 or
  12160.               (p2.dead = 1 and
  12161.                (p2.death_date = 0 or
  12162.                 (((to_days(p2.death_date) - to_days(p2.birthday)) / 365)
  12163.                  >= 65))))
  12164.              and
  12165.              (
  12166.              /* Twin is suspect */
  12167.              (td.future_contact = 'Yes' and td.suspect = 2) or
  12168.              /* Twin is suspect - Informant is Blessed */
  12169.              (td.future_contact = 'Yes' and td.suspect = 1 and id.suspect = 1) or
  12170.              /* No twin - Informant is Blessed */
  12171.              (ISNULL(td.suspect) and id.suspect = 1 and id.future_contact = 'Yes') or
  12172.              /* Twin broken off - Informant is Blessed */
  12173.              (td.participation = 'Aborted'
  12174.               and id.suspect = 1 and id.future_contact = 'Yes') or
  12175.              /* Twin broken off - No inform - Have partner */
  12176.              (td.participation = 'Aborted' and ISNULL(id.suspect) and p2.dead = 0))
  12177.              and
  12178.              l.event = 'Finished'
  12179.              /* Get at area code */
  12180.              and substring(p1.postal_code, 1, 2) = pg.code
  12181.              /* Not already distributed */
  12182.              and (h.nurse is NULL or h.nurse=00 or h.doctor=00)
  12183.              /* Has not refused or been aborted */
  12184.              and not (h.status = 'Refused' or h.status = 'Aborted'
  12185.              or h.status = 'Died' or h.status = 'Other')
  12186.      order by
  12187.              tvid;
  12188.  
  12189. Some explanations:
  12190. `concat(p1.id, p1.tvab) + 0 as tvid'
  12191.      We want to sort on the concatenated `id' and `tvab' in numerical
  12192.      order. Adding `0' to the result causes MySQL to treat the result
  12193.      as a number.
  12194.  
  12195. column `id'
  12196.      This identifies a pair of twins. It is a key in all tables.
  12197.  
  12198. column `tvab'
  12199.      This identifies a twin in a pair. It has a value of `1' or `2'.
  12200.  
  12201. column `ptvab'
  12202.      This is an inverse of `tvab'. When `tvab' is `1' this is `2', and
  12203.      vice versa. It exists to save typing and to make it easier for
  12204.      MySQL to optimize the query.
  12205.  
  12206. This query demonstrates, among other things, how to do lookups on a
  12207. table from the same table with a join (`p1' and `p2'). In the example,
  12208. this is used to check whether a twin's partner died before the age of
  12209. 65. If so, the row is not returned.
  12210.  
  12211. All of the above exist in all tables with twin-related information. We
  12212. have a key on both `id,tvab' (all tables), and `id,ptvab'
  12213. (`person_data') to make queries faster.
  12214.  
  12215. On our production machine (A 200MHz UltraSPARC), this query returns
  12216. about 150-200 rows and takes less than one second.
  12217.  
  12218. The current number of records in the tables used above:
  12219. *Table*                *Rows*
  12220. `person_data'          71074
  12221. `lentus'               5291
  12222. `twin_project'         5286
  12223. `twin_data'            2012
  12224. `informant_data'       663
  12225. `harmony'              381
  12226. `postal_groups'        100
  12227.  
  12228. 
  12229. File: mysql.info,  Node: Twin event,  Prev: Twin pool,  Up: Twin
  12230.  
  12231. Show a Table on Twin Pair Status
  12232. --------------------------------
  12233.  
  12234. Each interview ends with a status code called `event'. The query shown
  12235. below is used to display a table over all twin pairs combined by event.
  12236. This indicates in how many pairs both twins are finished, in how many
  12237. pairs one twin is finished and the other refused, and so on.
  12238.  
  12239.      select
  12240.              t1.event,
  12241.              t2.event,
  12242.              count(*)
  12243.      from
  12244.              lentus as t1,
  12245.              lentus as t2,
  12246.              twin_project as tp
  12247.      where
  12248.              /* We are looking at one pair at a time */
  12249.              t1.id = tp.id
  12250.              and t1.tvab=tp.tvab
  12251.              and t1.id = t2.id
  12252.              /* Just the sceening survey */
  12253.              and tp.survey_no = 5
  12254.              /* This makes each pair only appear once */
  12255.              and t1.tvab='1' and t2.tvab='2'
  12256.      group by
  12257.              t1.event, t2.event;
  12258.  
  12259. 
  12260. File: mysql.info,  Node: Apache,  Prev: Twin,  Up: Tutorial
  12261.  
  12262. Using MySQL with Apache
  12263. =======================
  12264.  
  12265. The Contrib section includes programs that let you authenticate your
  12266. users from a MySQL database and also let you log your log files into a
  12267. MySQL table. *Note Contrib::.
  12268.  
  12269. You can change the Apache logging format to be easily readable by MySQL
  12270. by putting the following into the Apache configuration file:
  12271.  
  12272.      LogFormat \
  12273.              "\"%h\",%{%Y%m%d%H%M%S}t,%>s,\"%b\",\"%{Content-Type}o\",  \
  12274.              \"%U\",\"%{Referer}i\",\"%{User-Agent}i\""
  12275.  
  12276. In MySQL you can do something like this:
  12277.  
  12278.      LOAD DATA INFILE '/local/access_log' INTO TABLE table_name
  12279.      FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\'
  12280.  
  12281. 
  12282. File: mysql.info,  Node: MySQL Database Administration,  Next: MySQL Optimization,  Prev: Tutorial,  Up: Top
  12283.  
  12284. MySQL Database Administration
  12285. *****************************
  12286.  
  12287. * Menu:
  12288.  
  12289. * Configuring MySQL::           Configuring MySQL
  12290. * Privilege system::            General Security Issues and the MySQL Access Privilege System
  12291. * User Account Management::     MySQL User Account Management
  12292. * Disaster Prevention::         Disaster Prevention and Recovery
  12293. * Database Administration::     Database Administration Language Reference
  12294. * Localization::                MySQL Localization and International Usage
  12295. * Server-Side Scripts::         MySQL Server-Side Scripts and Utilities
  12296. * Client-Side Scripts::         MySQL Client-Side Scripts and Utilities
  12297. * Log Files::                   The MySQL Log Files
  12298. * Replication::                 Replication in MySQL
  12299.  
  12300. 
  12301. File: mysql.info,  Node: Configuring MySQL,  Next: Privilege system,  Prev: MySQL Database Administration,  Up: MySQL Database Administration
  12302.  
  12303. Configuring MySQL
  12304. =================
  12305.  
  12306. * Menu:
  12307.  
  12308. * Command-line options::        mysqld Command-line Options
  12309. * Option files::                my.cnf Option Files
  12310. * Installing many servers::     Installing Many Servers on the Same Machine
  12311. * Multiple servers::            Running Multiple MySQL Servers on the Same Machine
  12312.  
  12313. 
  12314. File: mysql.info,  Node: Command-line options,  Next: Option files,  Prev: Configuring MySQL,  Up: Configuring MySQL
  12315.  
  12316. mysqld Command-line Options
  12317. ---------------------------
  12318.  
  12319. `mysqld' accepts the following command-line options:
  12320.  
  12321. `--ansi'
  12322.      Use ANSI SQL syntax instead of MySQL syntax.  *Note ANSI mode::.
  12323.  
  12324. `-b, --basedir=path'
  12325.      Path to installation directory. All paths are usually resolved
  12326.      relative to this.
  12327.  
  12328. `--big-tables'
  12329.      Allow big result sets by saving all temporary sets on file.  It
  12330.      solves most 'table full' errors, but also slows down the queries
  12331.      where in-memory tables would suffice.  Since Version 3.23.2, MySQL
  12332.      is able to solve it automatically by using memory for small
  12333.      temporary tables and switching to disk tables where necessary.
  12334.  
  12335. `--bind-address=IP'
  12336.      IP address to bind to.
  12337.  
  12338. `--character-sets-dir=path'
  12339.      Directory where character sets are.  *Note Character sets::.
  12340.  
  12341. `--chroot=path'
  12342.      Chroot `mysqld' daemon during startup.  Recommended security
  12343.      measure. It will somewhat limit `LOAD DATA INFILE' and `SELECT ...
  12344.      INTO OUTFILE' though.
  12345.  
  12346. `--core-file'
  12347.      Write a core file if `mysqld' dies.  For some systems you must also
  12348.      specify `--core-file-size' to `safe_mysqld'. *Note `safe_mysqld':
  12349.      safe_mysqld.
  12350.  
  12351. `-h, --datadir=path'
  12352.      Path to the database root.
  12353.  
  12354. `--default-character-set=charset'
  12355.      Set the default character set.  *Note Character sets::.
  12356.  
  12357. `--default-table-type=type'
  12358.      Set the default table type for tables.  *Note Table types::.
  12359.  
  12360. `--debug[...]='
  12361.      If MySQL is configured with `--with-debug', you can use this
  12362.      option to get a trace file of what `mysqld' is doing.  *Note
  12363.      Making trace files::.
  12364.  
  12365. `--delay-key-write-for-all-tables'
  12366.      Don't flush key buffers between writes for any `MyISAM' table.
  12367.      *Note Server parameters::.
  12368.  
  12369. `--enable-locking'
  12370.      Enable system locking.  Note that if you use this option on a
  12371.      system which a not fully working lockd() (as on Linux) you will
  12372.      easily get mysqld to deadlock.
  12373.  
  12374. `--enable-named-pipe'
  12375.      Enable support for named pipes (only on NT/Win2000/XP).
  12376.  
  12377. `-T, --exit-info'
  12378.      This is a bit mask of different flags one can use for debugging the
  12379.      mysqld server;  One should not use this option if one doesn't know
  12380.      exactly what it does!
  12381.  
  12382. `--flush'
  12383.      Flush all changes to disk after each SQL command.  Normally MySQL
  12384.      only does a write of all changes to disk after each SQL command
  12385.      and lets the operating system handle the syncing to disk.  *Note
  12386.      Crashing::.
  12387.  
  12388. `-?, --help'
  12389.      Display short help and exit.
  12390.  
  12391. `--init-file=file'
  12392.      Read SQL commands from this file at startup.
  12393.  
  12394. `-L, --language=...'
  12395.      Client error messages in given language.  May be given as a full
  12396.      path.  *Note Languages::.
  12397.  
  12398. `-l, --log[=file]'
  12399.      Log connections and queries to file. *Note Query log::.
  12400.  
  12401. `--log-isam[=file]'
  12402.      Log all ISAM/MyISAM changes to file (only used when debugging
  12403.      ISAM/MyISAM).
  12404.  
  12405. `--log-slow-queries[=file]'
  12406.      Log all queries that have taken more than `long_query_time'
  12407.      seconds to execute to file.  *Note Slow query log::.
  12408.  
  12409. `--log-update[=file]'
  12410.      Log updates to `file.#' where `#' is a unique number if not given.
  12411.      *Note Update log::.
  12412.  
  12413. `--log-long-format'
  12414.      Log some extra information to update log.  If you are using
  12415.      `--log-slow-queries' then queries that are not using indexes are
  12416.      logged to the slow query log.
  12417.  
  12418. `--low-priority-updates'
  12419.      Table-modifying operations (`INSERT'/`DELETE'/`UPDATE') will have
  12420.      lower priority than selects.  It can also be done via `{INSERT |
  12421.      REPLACE | UPDATE | DELETE} LOW_PRIORITY ...' to lower the priority
  12422.      of only one query, or by `SET OPTION SQL_LOW_PRIORITY_UPDATES=1'
  12423.      to change the priority in one thread.  *Note Table locking::.
  12424.  
  12425. `--memlock'
  12426.      Lock the `mysqld' process in memory.  This works only if your
  12427.      system supports the `mlockall()' system call (like Solaris).  This
  12428.      may help if you have a problem where the operating system is
  12429.      causing `mysqld' to swap on disk.
  12430.  
  12431. `--myisam-recover [=option[,option...]]] where option is any combination'
  12432.      of `DEFAULT', `BACKUP', `FORCE' or `QUICK'.  You can also set this
  12433.      explicitely to `""' if you want to disable this option. If this
  12434.      option is used, `mysqld' will on open check if the table is marked
  12435.      as crashed or if if the table wasn't closed properly.  (The last
  12436.      option only works if you are running with `--skip-locking').  If
  12437.      this is the case `mysqld' will run check on the table. If the
  12438.      table was corrupted, `mysqld' will attempt to repair it.
  12439.  
  12440.      The following options affects how the repair works.
  12441.  
  12442.      DEFAULT              The same as not giving any option to
  12443.                                    `--myisam-recover'.
  12444.      BACKUP               If the data table was changed during recover,
  12445.                           save a                     backup of the
  12446.                           `table_name.MYD' data file as
  12447.                             `table_name-datetime.BAK'.
  12448.      FORCE                Run recover even if we will loose more than
  12449.                           one row                     from the .MYD file.
  12450.      QUICK                Don't check the rows in the table if there
  12451.                           isn't any                     delete blocks.
  12452.  
  12453.      Before a table is automatically repaired, MySQL will add a note
  12454.      about this in the error log.  If you want to be able to recover
  12455.      from most things without user intervention, you should use the
  12456.      options `BACKUP,FORCE'.  This will force a repair of a table even
  12457.      if some rows would be deleted, but it will keep the old data file
  12458.      as a backup so that you can later examine what happened.
  12459.  
  12460. `--pid-file=path'
  12461.      Path to pid file used by `safe_mysqld'.
  12462.  
  12463. `-P, --port=...'
  12464.      Port number to listen for TCP/IP connections.
  12465.  
  12466. `-o, --old-protocol'
  12467.      Use the 3.20 protocol for compatibility with some very old clients.
  12468.      *Note Upgrading-from-3.20::.
  12469.  
  12470. `--one-thread'
  12471.      Only use one thread (for debugging under Linux).  *Note Debugging
  12472.      server::.
  12473.  
  12474. `-O, --set-variable var=option'
  12475.      Give a variable a value. `--help' lists variables.  You can find a
  12476.      full description for all variables in the `SHOW VARIABLES' section
  12477.      in this manual.  *Note SHOW VARIABLES::.  The tuning server
  12478.      parameters section includes information of how to optimize these.
  12479.      *Note Server parameters::.
  12480.  
  12481. `--safe-mode'
  12482.      Skip some optimize stages.  Implies `--skip-delay-key-write'.
  12483.  
  12484. `--safe-show-database'
  12485.      Don't show databases for which the user doesn't have any
  12486.      privileges.
  12487.  
  12488. `--safe-user-create'
  12489.      If this is enabled, a user can't create new users with the GRANT
  12490.      command, if the user doesn't have `INSERT' privilege to the
  12491.      `mysql.user' table or any column in this table.
  12492.  
  12493. `--skip-concurrent-insert'
  12494.      Turn off the ability to select and insert at the same time on
  12495.      `MyISAM' tables. (This is only to be used if you think you have
  12496.      found a bug in this feature).
  12497.  
  12498. `--skip-delay-key-write'
  12499.      Ignore the `delay_key_write' option for all tables.  *Note Server
  12500.      parameters::.
  12501.  
  12502. `--skip-grant-tables'
  12503.      This option causes the server not to use the privilege system at
  12504.      all.  This gives everyone _full access_ to all databases!  (You
  12505.      can tell a running server to start using the grant tables again by
  12506.      executing `mysqladmin flush-privileges' or `mysqladmin reload'.)
  12507.  
  12508. `--skip-host-cache'
  12509.      Never use host name cache for faster name-ip resolution, but query
  12510.      DNS server on every connect instead.  *Note DNS::.
  12511.  
  12512. `--skip-locking'
  12513.      Don't use system locking.  To use `isamchk' or `myisamchk' you must
  12514.      shut down the server.  *Note Stability::.  Note that in MySQL
  12515.      Version 3.23 you can use `REPAIR' and `CHECK' to repair/check
  12516.      `MyISAM' tables.
  12517.  
  12518. `--skip-name-resolve'
  12519.      Hostnames are not resolved.  All `Host' column values in the grant
  12520.      tables must be IP numbers or `localhost'.  *Note DNS::.
  12521.  
  12522. `--skip-networking'
  12523.      Don't listen for TCP/IP connections at all.  All interaction with
  12524.      `mysqld' must be made via Unix sockets.  This option is highly
  12525.      recommended for systems where only local requests are allowed.
  12526.      *Note DNS::.
  12527.  
  12528. `--skip-new'
  12529.      Don't use new, possible wrong routines.  Implies
  12530.      `--skip-delay-key-write'.  This will also set default table type
  12531.      to `ISAM'.  *Note ISAM::.
  12532.  
  12533. `--skip-symlink'
  12534.      Don't delete or rename files that a symlinked file in the data
  12535.      directory points to.
  12536.  
  12537. `--skip-safemalloc'
  12538.      If MySQL is configured with `--with-debug=full', all programs will
  12539.      check the memory for overruns for every memory allocation and
  12540.      memory freeing.  As this checking is very slow, you can avoid
  12541.      this, when you don't need memory checking, by using this option.
  12542.  
  12543. `--skip-show-database'
  12544.      Don't allow 'SHOW DATABASE' commands, unless the user has *process*
  12545.      privilege.
  12546.  
  12547. `--skip-stack-trace'
  12548.      Don't write stack traces.  This option is useful when you are
  12549.      running `mysqld' under a debugger. *Note Debugging server::.
  12550.  
  12551. `--skip-thread-priority'
  12552.      Disable using thread priorities for faster response time.
  12553.  
  12554. `--socket=path'
  12555.      Socket file to use for local connections instead of default
  12556.      `/tmp/mysql.sock'.
  12557.  
  12558. `--sql-mode=option[,option[,option...]]'
  12559.      Option can be any combination of: `REAL_AS_FLOAT',
  12560.      `PIPES_AS_CONCAT', `ANSI_QUOTES', `IGNORE_SPACE', `SERIALIZE',
  12561.      `ONLY_FULL_GROUP_BY'.  It can also be empty (`""') if you want to
  12562.      reset this.
  12563.  
  12564.      By specifying all of the above options is same as using -ansi.
  12565.      With this option one can turn on only needed SQL modes. *Note ANSI
  12566.      mode::.
  12567.  
  12568. `transaction-isolation= { READ-UNCOMMITTED | READ-COMMITTED | REPEATABLE-READ | SERIALIZABLE }'
  12569.      Sets the default transaction isolation level.  *Note SET
  12570.      TRANSACTION::.
  12571.  
  12572. `-t, --tmpdir=path'
  12573.      Path for temporary files. It may be useful if your default `/tmp'
  12574.      directory resides on a partition too small to hold temporary
  12575.      tables.
  12576.  
  12577. `-u, --user=user_name'
  12578.      Run `mysqld' daemon as user `user_name'.  This option is
  12579.      _mandatory_ when starting `mysqld' as root.
  12580.  
  12581. `-V, --version'
  12582.      Output version information and exit.
  12583.  
  12584. `-W, --warnings'
  12585.      Print out warnings like `Aborted connection...' to the `.err' file.
  12586.      *Note Communication errors::.
  12587.  
  12588. 
  12589. File: mysql.info,  Node: Option files,  Next: Installing many servers,  Prev: Command-line options,  Up: Configuring MySQL
  12590.  
  12591. my.cnf Option Files
  12592. -------------------
  12593.  
  12594. MySQL can, since Version 3.22, read default startup options for the
  12595. server and for clients from option files.
  12596.  
  12597. MySQL reads default options from the following files on Unix:
  12598.  
  12599. *Filename*             *Purpose*
  12600. `/etc/my.cnf'          Global options
  12601. `DATADIR/my.cnf'       Server-specific options
  12602. `defaults-extra-file'  The file specified with -defaults-extra-file=#
  12603. `~/.my.cnf'            User-specific options
  12604.  
  12605. `DATADIR' is the MySQL data directory (typically
  12606. `/usr/local/mysql/data' for a binary installation or `/usr/local/var'
  12607. for a source installation).  Note that this is the directory that was
  12608. specified at configuration time, not the one specified with `--datadir'
  12609. when `mysqld' starts up!  (`--datadir' has no effect on where the
  12610. server looks for option files, because it looks for them before it
  12611. processes any command-line arguments.)
  12612.  
  12613. MySQL reads default options from the following files on Windows:
  12614.  
  12615. *Filename*             *Purpose*
  12616. `windows-system-directory\my.ini'Global options
  12617. `C:\my.cnf'            Global options
  12618. `C:\mysql\data\my.cnf' Server-specific options
  12619.  
  12620. Note that on Windows, you should specify all paths with `/' instead of
  12621. `\'. If you use `\', you need to specify this twice, as `\' is the
  12622. escape character in MySQL.
  12623.  
  12624. MySQL tries to read option files in the order listed above.  If
  12625. multiple option files exist, an option specified in a file read later
  12626. takes precedence over the same option specified in a file read earlier.
  12627. Options specified on the command line take precedence over options
  12628. specified in any option file.  Some options can be specified using
  12629. environment variables.  Options specified on the command line or in
  12630. option files take precedence over environment variable values. *Note
  12631. Environment variables::.
  12632.  
  12633. The following programs support option files:  `mysql', `mysqladmin',
  12634. `mysqld', `mysqldump', `mysqlimport', `mysql.server', `myisamchk', and
  12635. `myisampack'.
  12636.  
  12637. You can use option files to specify any long option that a program
  12638. supports!  Run the program with `--help' to get a list of available
  12639. options.
  12640.  
  12641. An option file can contain lines of the following forms:
  12642.  
  12643. `#comment'
  12644.      Comment lines start with `#' or `;'. Empty lines are ignored.
  12645.  
  12646. `[group]'
  12647.      `group' is the name of the program or group for which you want to
  12648.      set options.  After a group line, any `option' or `set-variable'
  12649.      lines apply to the named group until the end of the option file or
  12650.      another group line is given.
  12651.  
  12652. `option'
  12653.      This is equivalent to `--option' on the command line.
  12654.  
  12655. `option=value'
  12656.      This is equivalent to `--option=value' on the command line.
  12657.  
  12658. `set-variable = variable=value'
  12659.      This is equivalent to `--set-variable variable=value' on the
  12660.      command line.  This syntax must be used to set a `mysqld' variable.
  12661.  
  12662. The `client' group allows you to specify options that apply to all
  12663. MySQL clients (not `mysqld'). This is the perfect group to use to
  12664. specify the password you use to connect to the server.  (But make sure
  12665. the option file is readable and writable only by yourself.)
  12666.  
  12667. Note that for options and values, all leading and trailing blanks are
  12668. automatically deleted.  You may use the escape sequences `\b', `\t',
  12669. `\n', `\r', `\\', and `\s' in your value string (`\s' == blank).
  12670.  
  12671. Here is a typical global option file:
  12672.  
  12673.      [client]
  12674.      port=3306
  12675.      socket=/tmp/mysql.sock
  12676.      
  12677.      [mysqld]
  12678.      port=3306
  12679.      socket=/tmp/mysql.sock
  12680.      set-variable = key_buffer_size=16M
  12681.      set-variable = max_allowed_packet=1M
  12682.      
  12683.      [mysqldump]
  12684.      quick
  12685.  
  12686. Here is typical user option file:
  12687.  
  12688.      [client]
  12689.      # The following password will be sent to all standard MySQL clients
  12690.      password=my_password
  12691.      
  12692.      [mysql]
  12693.      no-auto-rehash
  12694.      set-variable = connect_timeout=2
  12695.      
  12696.      [mysqlhotcopy]
  12697.      interactive-timeout
  12698.  
  12699. If you have a source distribution, you will find sample configuration
  12700. files named `my-xxxx.cnf' in the `support-files' directory.  If you
  12701. have a binary distribution, look in the `DIR/support-files' directory,
  12702. where `DIR' is the pathname to the MySQL installation directory
  12703. (typically `/usr/local/mysql').  Currently there are sample
  12704. configuration files for small, medium, large, and very large systems.
  12705. You can copy `my-xxxx.cnf' to your home directory (rename the copy to
  12706. `.my.cnf') to experiment with this.
  12707.  
  12708. All MySQL clients that support option files support the following
  12709. options:
  12710.  
  12711. -no-defaults                  Don't read any option files.
  12712. -print-defaults               Print the program name and all options
  12713.                               that it will get.
  12714. -defaults-file=full-path-to-default-fileOnly use the given configuration file.
  12715. -defaults-extra-file=full-path-to-default-fileRead this configuration file after the
  12716.                               global configuration file but before the
  12717.                               user configuration file.
  12718.  
  12719. Note that the above options must be first on the command line to work!
  12720. `--print-defaults' may however be used directly after the
  12721. `--defaults-xxx-file' commands.
  12722.  
  12723. Note for developers:  Option file handling is implemented simply by
  12724. processing all matching options (that is, options in the appropriate
  12725. group) before any command-line arguments. This works nicely for
  12726. programs that use the last instance of an option that is specified
  12727. multiple times. If you have an old program that handles
  12728. multiply-specified options this way but doesn't read option files, you
  12729. need add only two lines to give it that capability.  Check the source
  12730. code of any of the standard MySQL clients to see how to do this.
  12731.  
  12732. In shell scripts you can use the `my_print_defaults' command to parse
  12733. the config files:
  12734.  
  12735.  
  12736.      shell> my_print_defaults client mysql
  12737.      --port=3306
  12738.      --socket=/tmp/mysql.sock
  12739.      --no-auto-rehash
  12740.  
  12741. The above output contains all options for the groups 'client' and
  12742. 'mysql'.
  12743.  
  12744. 
  12745. File: mysql.info,  Node: Installing many servers,  Next: Multiple servers,  Prev: Option files,  Up: Configuring MySQL
  12746.  
  12747. Installing Many Servers on the Same Machine
  12748. -------------------------------------------
  12749.  
  12750. In some cases you may want to have many different `mysqld' daemons
  12751. (servers) running on the same machine.  You may for example want to run
  12752. a new version of MySQL for testing together with an old version that is
  12753. in production.  Another case is when you want to give different users
  12754. access to different `mysqld' servers that they manage themselves.
  12755.  
  12756. One way to get a new server running is by starting it with a different
  12757. socket and port as follows:
  12758.  
  12759.      shell> MYSQL_UNIX_PORT=/tmp/mysqld-new.sock
  12760.      shell> MYSQL_TCP_PORT=3307
  12761.      shell> export MYSQL_UNIX_PORT MYSQL_TCP_PORT
  12762.      shell> scripts/mysql_install_db
  12763.      shell> bin/safe_mysqld &
  12764.  
  12765. The environment variables appendix includes a list of other environment
  12766. variables you can use to affect `mysqld'. *Note Environment variables::.
  12767.  
  12768. The above is the quick and dirty way that one commonly uses for testing.
  12769. The nice thing with this is that all connections you do in the above
  12770. shell will automatically be directed to the new running server!
  12771.  
  12772. If you need to do this more permanently, you should create an option
  12773. file for each server. *Note Option files::.  In your startup script that
  12774. is executed at boot time (mysql.server?) you should specify for both
  12775. servers:
  12776.  
  12777. `safe_mysqld --default-file=path-to-option-file'
  12778.  
  12779. At least the following options should be different per server:
  12780.  
  12781. `port=#'
  12782.  
  12783. `socket=path'
  12784.  
  12785. `pid-file=path'
  12786. The following options should be different, if they are used:
  12787.  
  12788. `log=path'
  12789.  
  12790. `log-bin=path'
  12791.  
  12792. `log-update=path'
  12793.  
  12794. `log-isam=path'
  12795.  
  12796. `bdb-logdir=path'
  12797. If you want more performance, you can also specify the following
  12798. differently:
  12799.  
  12800. `tmpdir=path'
  12801.  
  12802. `bdb-tmpdir=path'
  12803. *Note Command-line options::.
  12804.  
  12805. If you are installing binary MySQL versions (.tar files) and start them
  12806. with `./bin/safe_mysqld' then in most cases the only option you need to
  12807. add/change is the `socket' and `port' argument to `safe_mysqld'.
  12808.  
  12809. * Menu:
  12810.  
  12811. * Multiple servers::            Running Multiple MySQL Servers on the Same Machine
  12812.  
  12813. 
  12814. File: mysql.info,  Node: Multiple servers,  Prev: Installing many servers,  Up: Configuring MySQL
  12815.  
  12816. Running Multiple MySQL Servers on the Same Machine
  12817. --------------------------------------------------
  12818.  
  12819. There are circumstances when you might want to run multiple servers on
  12820. the same machine.  For example, you might want to test a new MySQL
  12821. release while leaving your existing production setup undisturbed.  Or
  12822. you might be an Internet service provider that wants to provide
  12823. independent MySQL installations for different customers.
  12824.  
  12825. If you want to run multiple servers, the easiest way is to compile the
  12826. servers with different TCP/IP ports and socket files so they are not
  12827. both listening to the same TCP/IP port or socket file. *Note
  12828. `mysqld_multi': mysqld_multi.
  12829.  
  12830. Assume an existing server is configured for the default port number and
  12831. socket file.  Then configure the new server with a `configure' command
  12832. something like this:
  12833.  
  12834.      shell> ./configure  --with-tcp-port=port_number \
  12835.                   --with-unix-socket-path=file_name \
  12836.                   --prefix=/usr/local/mysql-3.22.9
  12837.  
  12838. Here `port_number' and `file_name' should be different than the default
  12839. port number and socket file pathname, and the `--prefix' value should
  12840. specify an installation directory different than the one under which
  12841. the existing MySQL installation is located.
  12842.  
  12843. You can check the socket used by any currently executing MySQL server
  12844. with this command:
  12845.  
  12846.      shell> mysqladmin -h hostname --port=port_number variables
  12847.  
  12848. Note that if you specify "`localhost'" as a hostname, `mysqladmin' will
  12849. default to using Unix sockets instead of TCP/IP.
  12850.  
  12851. If you have a MySQL server running on the port you used, you will get a
  12852. list of some of the most important configurable variables in MySQL,
  12853. including the socket name.
  12854.  
  12855. You don't have to recompile a new MySQL server just to start with a
  12856. different port and socket.  You can change the port and socket to be
  12857. used by specifying them at run time as options to `safe_mysqld':
  12858.  
  12859.      shell> /path/to/safe_mysqld --socket=file_name --port=port_number
  12860.  
  12861. `mysqld_multi' can also take `safe_mysqld' (or `mysqld') as an argument
  12862. and pass the options from a configuration file to `safe_mysqld' and
  12863. further to `mysqld'.
  12864.  
  12865. If you run the new server on the same database directory as another
  12866. server with logging enabled, you should also specify the name of the log
  12867. files to `safe_mysqld' with `--log', `--log-update', or
  12868. `--log-slow-queries'.  Otherwise, both servers may be trying to write
  12869. to the same log file.
  12870.  
  12871. *WARNING*: Normally you should never have two servers that update data
  12872. in the same database!  If your OS doesn't support fault-free system
  12873. locking, this may lead to unpleasant surprises!
  12874.  
  12875. If you want to use another database directory for the second server, you
  12876. can use the `--datadir=path' option to `safe_mysqld'.
  12877.  
  12878. *NOTE* also that starting several MySQL servers (`mysqlds') in
  12879. different machines and letting them access one data directory over
  12880. `NFS' is generally a *BAD IDEA*! The problem is that the `NFS' will
  12881. become the bottleneck with the speed. It is not meant for such use. And
  12882. last but not least, you would still have to come up with a solution how
  12883. to make sure that two or more `mysqlds' are not interfering with each
  12884. other. At the moment there is no platform that would 100% reliable do
  12885. the file locking (`lockd' daemon usually) in every situation. Yet there
  12886. would be one more possible risk with `NFS'; it would make the work even
  12887. more complicated for `lockd' daemon to handle. So make it easy for your
  12888. self and forget about the idea. The working solution is to have one
  12889. computer with an operating system that efficiently handles threads and
  12890. have several CPUs in it.
  12891.  
  12892. When you want to connect to a MySQL server that is running with a
  12893. different port than the port that is compiled into your client, you can
  12894. use one of the following methods:
  12895.  
  12896.    * Start the client with `--host 'hostname' --port=port_number' to
  12897.      connect with TCP/IP, or `[--host localhost] --socket=file_name' to
  12898.      connect via a Unix socket.
  12899.  
  12900.    * In your C or Perl programs, you can give the port or socket
  12901.      arguments when connecting to the MySQL server.
  12902.  
  12903.    * If your are using the Perl `DBD::mysql' module you can read the
  12904.      options from the MySQL option files.  *Note Option files::.
  12905.  
  12906.           $dsn = "DBI:mysql:test;mysql_read_default_group=client;mysql_read_default_file=/usr/local/mysql/data/my.cnf"
  12907.           $dbh = DBI->connect($dsn, $user, $password);
  12908.  
  12909.    * Set the `MYSQL_UNIX_PORT' and `MYSQL_TCP_PORT' environment
  12910.      variables to point to the Unix socket and TCP/IP port before you
  12911.      start your clients.  If you normally use a specific socket or
  12912.      port, you should place commands to set these environment variables
  12913.      in your `.login' file.  *Note Environment variables::.
  12914.  
  12915.    * Specify the default socket and TCP/IP port in the `.my.cnf' file
  12916.      in your home directory. *Note Option files::.
  12917.  
  12918. 
  12919. File: mysql.info,  Node: Privilege system,  Next: User Account Management,  Prev: Configuring MySQL,  Up: MySQL Database Administration
  12920.  
  12921. General Security Issues and the MySQL Access Privilege System
  12922. =============================================================
  12923.  
  12924. MySQL has an advanced but non-standard security/privilege system.  This
  12925. section describes how it works.
  12926.  
  12927. * Menu:
  12928.  
  12929. * General security::            General security
  12930. * Security::                    How to make MySQL secure against crackers
  12931. * Privileges options::          Startup Options for `mysqld' Concerning Security
  12932. * What Privileges::             What the privilege system does
  12933. * Privileges::                  How the privilege system works
  12934. * Privileges provided::         Privileges provided by MySQL
  12935. * Connecting::                  Connecting to the MySQL server
  12936. * Connection access::           Access control, stage 1: Connection verification
  12937. * Request access::              Access control, stage 2: Request verification
  12938. * Access denied::               Causes of `Access denied' errors
  12939.  
  12940. 
  12941. File: mysql.info,  Node: General security,  Next: Security,  Prev: Privilege system,  Up: Privilege system
  12942.  
  12943. General Security Guidelines
  12944. ---------------------------
  12945.  
  12946. Anyone using MySQL on a computer connected to the Internet should read
  12947. this section to avoid the most common security mistakes.
  12948.  
  12949. In discussing security, we emphasize the necessity of fully protecting
  12950. the entire server host (not simply the MySQL server) against all types
  12951. of applicable attacks: eavesdropping, altering, playback, and denial of
  12952. service. We do not cover all aspects of availability and fault tolerance
  12953. here.
  12954.  
  12955. MySQL uses security based on Access Control Lists (ACLs) for all
  12956. connections, queries, and other operations that a user may attempt to
  12957. perform. There is also some support for SSL-encrypted connections
  12958. between MySQL clients and servers. Many of the concepts discussed here
  12959. are not specific to MySQL at all; the same general ideas apply to
  12960. almost all applications.
  12961.  
  12962. When running MySQL, follow these guidelines whenever possible:
  12963.  
  12964.    * DON'T EVER GIVE ANYONE (EXCEPT THE MySQL ROOT USER) ACCESS TO THE
  12965.      `user' TABLE IN THE `mysql' DATABASE!  The encrypted password is
  12966.      the real password in MySQL. If you know the password listed in the
  12967.      `user' table for a given user, you can easily log in as that user
  12968.      if you have access to the host listed for that account.
  12969.  
  12970.    * Learn the MySQL access privilege system. The `GRANT' and `REVOKE'
  12971.      commands are used for controlling access to MySQL. Do not grant
  12972.      any more privileges than necessary. Never grant privileges to all
  12973.      hosts.
  12974.  
  12975.      Checklist:
  12976.         - Try `mysql -u root'. If you are able to connect successfully
  12977.           to the server without being asked for a password, you have
  12978.           problems. Anyone can connect to your MySQL server as the MySQL
  12979.           `root' user with full privileges!  Review the MySQL
  12980.           installation instructions, paying particular attention to the
  12981.           item about setting a `root' password.
  12982.  
  12983.         - Use the command `SHOW GRANTS' and check to see who has access
  12984.           to what. Remove those privileges that are not necessary using
  12985.           the `REVOKE' command.
  12986.  
  12987.    * Do not keep any plain-text passwords in your database. When your
  12988.      computer becomes compromised, the intruder can take the full list
  12989.      of passwords and use them. Instead use `MD5()' or another one-way
  12990.      hashing function.
  12991.  
  12992.    * Do not choose passwords from dictionaries. There are special
  12993.      programs to break them. Even passwords like "xfish98" are very
  12994.      bad.  Much better is "duag98" which contains the same word "fish"
  12995.      but typed one key to the left on a standard QWERTY keyboard.
  12996.      Another method is to use "Mhall" which is taken from the first
  12997.      characters of each word in the sentence "Mary had a little lamb."
  12998.      This is easy to remember and type, but difficult to guess for
  12999.      someone who does not know it.
  13000.  
  13001.    * Invest in a firewall. This protects you from at least 50% of all
  13002.      types of exploits in any software. Put MySQL behind the firewall
  13003.      or in a demilitarized zone (DMZ).
  13004.  
  13005.      Checklist:
  13006.         - Try to scan your ports from the Internet using a tool such as
  13007.           `nmap'. MySQL uses port 3306 by default. This port should be
  13008.           inaccessible from untrusted hosts. Another simple way to
  13009.           check whether or not your MySQL port is open is to try the
  13010.           following command from some remote machine, where
  13011.           `server_host' is the hostname of your MySQL server:
  13012.  
  13013.                shell> telnet server_host 3306
  13014.  
  13015.           If you get a connection and some garbage characters, the port
  13016.           is open, and should be closed on your firewall or router,
  13017.           unless you really have a good reason to keep it open. If
  13018.           `telnet' just hangs or the connection is refused, everything
  13019.           is OK; the port is blocked.
  13020.  
  13021.    * Do not trust any data entered by your users. They can try to trick
  13022.      your code by entering special or escaped character sequences in
  13023.      Web forms, URLs, or whatever application you have built. Be sure
  13024.      that your application remains secure if a user enters something
  13025.      like "`; DROP DATABASE mysql;'". This is an extreme example, but
  13026.      large security leaks and data loss may occur as a result of
  13027.      hackers using similar techniques, if you do not prepare for them.
  13028.  
  13029.      Also remember to check numeric data. A common mistake is to
  13030.      protect only strings. Sometimes people think that if a database
  13031.      contains only publicly available data that it need not be
  13032.      protected. This is incorrect. At least denial-of-service type
  13033.      attacks can be performed on such databases. The simplest way to
  13034.      protect from this type of attack is to use apostrophes around the
  13035.      numeric constants: `SELECT * FROM table WHERE ID='234'' rather
  13036.      than `SELECT * FROM table WHERE ID=234'.  MySQL automatically
  13037.      converts this string to a number and strips all non-numeric
  13038.      symbols from it.
  13039.  
  13040.      Checklist:
  13041.         - All Web applications:
  13042.              * Try to enter `'' and `"' in all your Web forms. If you
  13043.                get any kind of MySQL error, investigate the problem
  13044.                right away.
  13045.  
  13046.              * Try to modify any dynamic URLs by adding `%22' (`"'),
  13047.                `%23' (`#'), and `%27' (`'') in the URL.
  13048.  
  13049.              * Try to modify datatypes in dynamic URLs from numeric
  13050.                ones to character ones containing characters from
  13051.                previous examples. Your application should be safe
  13052.                against this and similar attacks.
  13053.  
  13054.              * Try to enter characters, spaces, and special symbols
  13055.                instead of numbers in numeric fields. Your application
  13056.                should remove them before passing them to MySQL or your
  13057.                application should generate an error. Passing unchecked
  13058.                values to MySQL is very dangerous!
  13059.  
  13060.              * Check data sizes before passing them to MySQL.
  13061.  
  13062.              * Consider having your application connect to the database
  13063.                using a different user name than the one you use for
  13064.                administrative purposes. Do not give your applications
  13065.                any more access privileges than they need.
  13066.  
  13067.         - Users of PHP:
  13068.              * Check out the `addslashes()' function.  As of PHP 4.0.3,
  13069.                a `mysql_escape_string()' function is available that is
  13070.                based on the function of the same name in the MySQL C
  13071.                API.
  13072.  
  13073.         - Users of MySQL C API:
  13074.              * Check out the `mysql_escape_string()' API call.
  13075.  
  13076.         - Users of MySQL++:
  13077.              * Check out the `escape' and `quote' modifiers for query
  13078.                streams.
  13079.  
  13080.         - Users of Perl DBI:
  13081.              * Check out the `quote()' method or use placeholders.
  13082.  
  13083.         - Users of Java JDBC:
  13084.              * Use a `PreparedStatement' object and placeholders.
  13085.  
  13086.    * Do not transmit plain (unencrypted) data over the Internet. These
  13087.      data are accessible to everyone who has the time and ability to
  13088.      intercept it and use it for their own purposes. Instead, use an
  13089.      encrypted protocol such as SSL or SSH. MySQL supports internal SSL
  13090.      connections as of Version 3.23.9.  SSH port-forwarding can be used
  13091.      to create an encrypted (and compressed) tunnel for the
  13092.      communication.
  13093.  
  13094.    * Learn to use the `tcpdump' and `strings' utilities. For most cases,
  13095.      you can check whether or not MySQL data streams are unencrypted by
  13096.      issuing a command like the following:
  13097.  
  13098.           shell> tcpdump -l -i eth0 -w - src or dst port 3306 | strings
  13099.  
  13100.      (This works under Linux and should work with small modifications
  13101.      under other systems).  Warning: If you do not see data this
  13102.      doesn't always actually mean that it is encrypted. If you need
  13103.      high security, you should consult with a security expert.
  13104.  
  13105. 
  13106. File: mysql.info,  Node: Security,  Next: Privileges options,  Prev: General security,  Up: Privilege system
  13107.  
  13108. How to Make MySQL Secure Against Crackers
  13109. -----------------------------------------
  13110.  
  13111. When you connect to a MySQL server, you normally should use a password.
  13112. The password is not transmitted in clear text over the connection,
  13113. however the encryption algorithm is not very strong, and with some
  13114. effort a clever attacker can crack the password if he is able to sniff
  13115. the traffic between the client and the server. If the connection
  13116. between the client and the server goes through an untrusted network,
  13117. you should use an SSH tunnel to encrypt the communication.
  13118.  
  13119. All other information is transferred as text that can be read by anyone
  13120. who is able to watch the connection.  If you are concerned about this,
  13121. you can use the compressed protocol (in MySQL Version 3.22 and above)
  13122. to make things much harder.  To make things even more secure you should
  13123. use `ssh'.  You can find an open source `ssh' client at
  13124. `http://www.openssh.org', and a commercial `ssh' client at
  13125. `http://www.ssh.com'.  With this, you can get an encrypted TCP/IP
  13126. connection between a MySQL server and a MySQL client.
  13127.  
  13128. To make a MySQL system secure, you should strongly consider the
  13129. following suggestions:
  13130.  
  13131.    * Use passwords for all MySQL users. Remember that anyone can log in
  13132.      as any other person as simply as `mysql -u other_user db_name' if
  13133.      `other_user' has no password.  It is common behavior with
  13134.      client/server applications that the client may specify any user
  13135.      name.  You can change the password of all users by editing the
  13136.      `mysql_install_db' script before you run it, or only the password
  13137.      for the MySQL `root' user like this:
  13138.  
  13139.           shell> mysql -u root mysql
  13140.           mysql> UPDATE user SET Password=PASSWORD('new_password')
  13141.                      WHERE user='root';
  13142.           mysql> FLUSH PRIVILEGES;
  13143.  
  13144.    * Don't run the MySQL daemon as the Unix `root' user.  This is very
  13145.      dangerous, because any user with `FILE' privileges will be able to
  13146.      create files as `root' (for example, `~root/.bashrc'). To prevent
  13147.      this, `mysqld' will refuse to run as `root' unless it is specified
  13148.      directly using a `--user=root' option.
  13149.  
  13150.      `mysqld' can be run as an ordinary unprivileged user instead.  You
  13151.      can also create a new Unix user `mysql' to make everything even
  13152.      more secure.  If you run `mysqld' as another Unix user, you don't
  13153.      need to change the `root' user name in the `user' table, because
  13154.      MySQL user names have nothing to do with Unix user names.  To
  13155.      start `mysqld' as another Unix user, add a `user' line that
  13156.      specifies the user name to the `[mysqld]' group of the
  13157.      `/etc/my.cnf' option file or the `my.cnf' option file in the
  13158.      server's data directory. For example:
  13159.  
  13160.           [mysqld]
  13161.           user=mysql
  13162.  
  13163.      This will cause the server to start as the designated user whether
  13164.      you start it manually or by using `safe_mysqld' or `mysql.server'.
  13165.      For more details, see *Note Changing MySQL user: Changing MySQL
  13166.      user.
  13167.  
  13168.    * Don't support symlinks to tables (This can be disabled with the
  13169.      `--skip-symlink' option. This is especially important if you run
  13170.      `mysqld' as root as anyone that has write access to the mysqld data
  13171.      directories could then delete any file in the system!  *Note
  13172.      Symbolic links to tables::.
  13173.  
  13174.    * Check that the Unix user that `mysqld' runs as is the only user
  13175.      with read/write privileges in the database directories.
  13176.  
  13177.    * Don't give the *process* privilege to all users.  The output of
  13178.      `mysqladmin processlist' shows the text of the currently executing
  13179.      queries, so any user who is allowed to execute that command might
  13180.      be able to see if another user issues an `UPDATE user SET
  13181.      password=PASSWORD('not_secure')' query.
  13182.  
  13183.      `mysqld' reserves an extra connection for users who have the
  13184.      *process* privilege, so that a MySQL `root' user can log in and
  13185.      check things even if all normal connections are in use.
  13186.  
  13187.    * Don't give the *file* privilege to all users.  Any user that has
  13188.      this privilege can write a file anywhere in the file system with
  13189.      the privileges of the `mysqld' daemon!  To make this a bit safer,
  13190.      all files generated with `SELECT ... INTO OUTFILE' are readable to
  13191.      everyone, and you cannot overwrite existing files.
  13192.  
  13193.      The *file* privilege may also be used to read any file accessible
  13194.      to the Unix user that the server runs as.  This could be abused,
  13195.      for example, by using `LOAD DATA' to load `/etc/passwd' into a
  13196.      table, which can then be read with `SELECT'.
  13197.  
  13198.    * If you don't trust your DNS, you should use IP numbers instead of
  13199.      hostnames in the grant tables. In any case, you should be very
  13200.      careful about creating grant table entries using hostname values
  13201.      that contain wild cards!
  13202.  
  13203.    * If you want to restrict the number of connections for a single
  13204.      user, you can do this by setting the `max_user_connections'
  13205.      variable in `mysqld'.
  13206.  
  13207. 
  13208. File: mysql.info,  Node: Privileges options,  Next: What Privileges,  Prev: Security,  Up: Privilege system
  13209.  
  13210. Startup Options for `mysqld' Concerning Security
  13211. ------------------------------------------------
  13212.  
  13213. The following `mysqld' options affect security:
  13214.  
  13215. `--safe-show-database'
  13216.      With this option, `SHOW DATABASES' returns only those databases
  13217.      for which the user has some kind of privilege.
  13218.  
  13219. `--safe-user-create'
  13220.      If this is enabled, an user can't create new users with the `GRANT'
  13221.      command, if the user doesn't have `INSERT' privilege to the
  13222.      `mysql.user' table.  If you want to give a user access to just
  13223.      create new users with those privileges that the user has right to
  13224.      grant, you should give the user the following privilege:
  13225.  
  13226.           GRANT INSERT(user) on mysql.user to 'user'h'ostname';
  13227.  
  13228.      This will ensure that the user can't change any privilege columns
  13229.      directly, but has to use the `GRANT' command to give privileges to
  13230.      other users.
  13231.  
  13232. `--skip-grant-tables'
  13233.      This option causes the server not to use the privilege system at
  13234.      all. This gives everyone _full access_ to all databases!  (You can
  13235.      tell a running server to start using the grant tables again by
  13236.      executing `mysqladmin flush-privileges' or `mysqladmin reload'.)
  13237.  
  13238. `--skip-name-resolve'
  13239.      Hostnames are not resolved.  All `Host' column values in the grant
  13240.      tables must be IP numbers or `localhost'.
  13241.  
  13242. `--skip-networking'
  13243.      Don't allow TCP/IP connections over the network.  All connections
  13244.      to `mysqld' must be made via Unix sockets. This option is
  13245.      unsuitable for systems that use MIT-pthreads, because the
  13246.      MIT-pthreads package doesn't support Unix sockets.
  13247.  
  13248. `--skip-show-database'
  13249.      With this option, the `SHOW DATABASES' statement doesn't return
  13250.      anything.
  13251.  
  13252. 
  13253. File: mysql.info,  Node: What Privileges,  Next: Privileges,  Prev: Privileges options,  Up: Privilege system
  13254.  
  13255. What the Privilege System Does
  13256. ------------------------------
  13257.  
  13258. The primary function of the MySQL privilege system is to authenticate a
  13259. user connecting from a given host, and to associate that user with
  13260. privileges on a database such as *select*, *insert*, *update* and
  13261. *delete*.
  13262.  
  13263. Additional functionality includes the ability to have an anonymous user
  13264. and to grant privileges for MySQL-specific functions such as `LOAD DATA
  13265. INFILE' and administrative operations.
  13266.  
  13267. 
  13268. File: mysql.info,  Node: Privileges,  Next: Privileges provided,  Prev: What Privileges,  Up: Privilege system
  13269.  
  13270. How the Privilege System Works
  13271. ------------------------------
  13272.  
  13273. The MySQL privilege system ensures that all users may do exactly the
  13274. things that they are supposed to be allowed to do.  When you connect to
  13275. a MySQL server, your identity is determined by *the host from which you
  13276. connect* and *the user name you specify*.  The system grants privileges
  13277. according to your identity and *what you want to do*.
  13278.  
  13279. MySQL considers both your hostname and user name in identifying you
  13280. because there is little reason to assume that a given user name belongs
  13281. to the same person everywhere on the Internet.  For example, the user
  13282. `bill' who connects from `whitehouse.gov' need not be the same person
  13283. as the user `bill' who connects from `microsoft.com'.  MySQL handles
  13284. this by allowing you to distinguish users on different hosts that
  13285. happen to have the same name:  you can grant `bill' one set of
  13286. privileges for connections from `whitehouse.gov', and a different set
  13287. of privileges for connections from `microsoft.com'.
  13288.  
  13289. MySQL access control involves two stages:
  13290.  
  13291.    * Stage 1: The server checks whether or not you are even allowed to
  13292.      connect.
  13293.  
  13294.    * Stage 2: Assuming you can connect, the server checks each request
  13295.      you issue to see whether or not you have sufficient privileges to
  13296.      perform it.  For example, if you try to select rows from a table
  13297.      in a database or drop a table from the database, the server makes
  13298.      sure you have the *select* privilege for the table or the *drop*
  13299.      privilege for the database.
  13300.  
  13301. The server uses the `user', `db', and `host' tables in the `mysql'
  13302. database at both stages of access control.  The fields in these grant
  13303. tables are shown below:
  13304.  
  13305. *Table name*   `user'             `db'               `host'
  13306. *Scope         `Host'             `Host'             `Host'
  13307. fields*                                              
  13308.                `User'             `Db'               `Db'
  13309.                `Password'         `User'             
  13310. *Privilege     `Select_priv'      `Select_priv'      `Select_priv'
  13311. fields*                                              
  13312.                `Insert_priv'      `Insert_priv'      `Insert_priv'
  13313.                `Update_priv'      `Update_priv'      `Update_priv'
  13314.                `Delete_priv'      `Delete_priv'      `Delete_priv'
  13315.                `Index_priv'       `Index_priv'       `Index_priv'
  13316.                `Alter_priv'       `Alter_priv'       `Alter_priv'
  13317.                `Create_priv'      `Create_priv'      `Create_priv'
  13318.                `Drop_priv'        `Drop_priv'        `Drop_priv'
  13319.                `Grant_priv'       `Grant_priv'       `Grant_priv'
  13320.                `References_priv'                     
  13321.                `Reload_priv'                         
  13322.                `Shutdown_priv'                       
  13323.                `Process_priv'                        
  13324.                `File_priv'                           
  13325.  
  13326. For the second stage of access control (request verification), the
  13327. server may, if the request involves tables, additionally consult the
  13328. `tables_priv' and `columns_priv' tables.  The fields in these tables
  13329. are shown below:
  13330.  
  13331. *Table name*   `tables_priv'      `columns_priv'
  13332. *Scope         `Host'             `Host'
  13333. fields*                           
  13334.                `Db'               `Db'
  13335.                `User'             `User'
  13336.                `Table_name'       `Table_name'
  13337.                                   `Column_name'
  13338. *Privilege     `Table_priv'       `Column_priv'
  13339. fields*                           
  13340.                `Column_priv'      
  13341. *Other         `Timestamp'        `Timestamp'
  13342. fields*                           
  13343.                `Grantor'          
  13344.  
  13345. Each grant table contains scope fields and privilege fields.
  13346.  
  13347. Scope fields determine the scope of each entry in the tables, that is,
  13348. the context in which the entry applies.  For example, a `user' table
  13349. entry with `Host' and `User' values of `'thomas.loc.gov'' and `'bob''
  13350. would be used for authenticating connections made to the server by
  13351. `bob' from the host `thomas.loc.gov'.  Similarly, a `db' table entry
  13352. with `Host', `User', and `Db' fields of `'thomas.loc.gov'', `'bob'' and
  13353. `'reports'' would be used when `bob' connects from the host
  13354. `thomas.loc.gov' to access the `reports' database.  The `tables_priv'
  13355. and `columns_priv' tables contain scope fields indicating tables or
  13356. table/column combinations to which each entry applies.
  13357.  
  13358. For access-checking purposes, comparisons of `Host' values are case
  13359. insensitive.  `User', `Password', `Db', and `Table_name' values are
  13360. case sensitive.  `Column_name' values are case insensitive in MySQL
  13361. Version 3.22.12 or later.
  13362.  
  13363. Privilege fields indicate the privileges granted by a table entry, that
  13364. is, what operations can be performed.  The server combines the
  13365. information in the various grant tables to form a complete description
  13366. of a user's privileges.  The rules used to do this are described in
  13367. *Note Request access::.
  13368.  
  13369. Scope fields are strings, declared as shown below; the default value for
  13370. each is the empty string:
  13371.  
  13372. *Field      *Type*      
  13373. name*                   
  13374. `Host'      `CHAR(60)'  
  13375. `User'      `CHAR(16)'  
  13376. `Password'  `CHAR(16)'  
  13377. `Db'        `CHAR(64)'  (`CHAR(60)' for the `tables_priv' and
  13378.                         `columns_priv' tables)
  13379. `Table_name'`CHAR(60)'  
  13380. `Column_name'`CHAR(60)'  
  13381.  
  13382. In the `user', `db' and `host' tables, all privilege fields are
  13383. declared as `ENUM('N','Y')' -- each can have a value of `'N'' or `'Y'',
  13384. and the default value is `'N''.
  13385.  
  13386. In the `tables_priv' and `columns_priv' tables, the privilege fields
  13387. are declared as `SET' fields:
  13388.  
  13389. *Table name*   *Field name*   *Possible set elements*
  13390. `tables_priv'  `Table_priv'   `'Select', 'Insert', 'Update', 'Delete',
  13391.                               'Create', 'Drop', 'Grant', 'References',
  13392.                               'Index', 'Alter''
  13393. `tables_priv'  `Column_priv'  `'Select', 'Insert', 'Update',
  13394.                               'References''
  13395. `columns_priv' `Column_priv'  `'Select', 'Insert', 'Update',
  13396.                               'References''
  13397.  
  13398. Briefly, the server uses the grant tables like this:
  13399.  
  13400.    * The `user' table scope fields determine whether to allow or reject
  13401.      incoming connections.  For allowed connections, any privileges
  13402.      granted in the `user' table indicate the user's global (superuser)
  13403.      privileges.  These privileges apply to *all* databases on the
  13404.      server.
  13405.  
  13406.    * The `db' and `host' tables are used together:
  13407.  
  13408.         - The `db' table scope fields determine which users can access
  13409.           which databases from which hosts.  The privilege fields
  13410.           determine which operations are allowed.
  13411.  
  13412.         - The `host' table is used as an extension of the `db' table
  13413.           when you want a given `db' table entry to apply to several
  13414.           hosts.  For example, if you want a user to be able to use a
  13415.           database from several hosts in your network, leave the `Host'
  13416.           value empty in the user's `db' table entry, then populate the
  13417.           `host' table with an entry for each of those hosts.  This
  13418.           mechanism is described more detail in *Note Request access::.
  13419.  
  13420.    * The `tables_priv' and `columns_priv' tables are similar to the
  13421.      `db' table, but are more fine-grained: they apply at the table and
  13422.      column levels rather than at the database level.
  13423.  
  13424. Note that administrative privileges (*reload*, *shutdown*, etc.) are
  13425. specified only in the `user' table.  This is because administrative
  13426. operations are operations on the server itself and are not
  13427. database-specific, so there is no reason to list such privileges in the
  13428. other grant tables.  In fact, only the `user' table need be consulted
  13429. to determine whether or not you can perform an administrative operation.
  13430.  
  13431. The *file* privilege is specified only in the `user' table, too.  It is
  13432. not an administrative privilege as such, but your ability to read or
  13433. write files on the server host is independent of the database you are
  13434. accessing.
  13435.  
  13436. The `mysqld' server reads the contents of the grant tables once, when it
  13437. starts up.  Changes to the grant tables take effect as indicated in
  13438. *Note Privilege changes::.
  13439.  
  13440. When you modify the contents of the grant tables, it is a good idea to
  13441. make sure that your changes set up privileges the way you want.  For
  13442. help in diagnosing problems, see *Note Access denied::.  For advice on
  13443. security issues, *note Security::.
  13444.  
  13445. A useful diagnostic tool is the `mysqlaccess' script, which Yves
  13446. Carlier has provided for the MySQL distribution.  Invoke `mysqlaccess'
  13447. with the `--help' option to find out how it works.  Note that
  13448. `mysqlaccess' checks access using only the `user', `db' and `host'
  13449. tables.  It does not check table- or column-level privileges.
  13450.  
  13451. 
  13452. File: mysql.info,  Node: Privileges provided,  Next: Connecting,  Prev: Privileges,  Up: Privilege system
  13453.  
  13454. Privileges Provided by MySQL
  13455. ----------------------------
  13456.  
  13457. Information about user privileges is stored in the `user', `db',
  13458. `host', `tables_priv', and `columns_priv' tables in the `mysql'
  13459. database (that is, in the database named `mysql').  The MySQL server
  13460. reads the contents of these tables when it starts up and under the
  13461. circumstances indicated in *Note Privilege changes::.
  13462.  
  13463. The names used in this manual to refer to the privileges provided by
  13464. MySQL are shown below, along with the table column name associated with
  13465. each privilege in the grant tables and the context in which the
  13466. privilege applies:
  13467.  
  13468. *Privilege* *Column*           *Context*
  13469. *select*    `Select_priv'      tables
  13470. *insert*    `Insert_priv'      tables
  13471. *update*    `Update_priv'      tables
  13472. *delete*    `Delete_priv'      tables
  13473. *index*     `Index_priv'       tables
  13474. *alter*     `Alter_priv'       tables
  13475. *create*    `Create_priv'      databases, tables, or indexes
  13476. *drop*      `Drop_priv'        databases or tables
  13477. *grant*     `Grant_priv'       databases or tables
  13478. *references*`References_priv'  databases or tables
  13479. *reload*    `Reload_priv'      server administration
  13480. *shutdown*  `Shutdown_priv'    server administration
  13481. *process*   `Process_priv'     server administration
  13482. *file*      `File_priv'        file access on server
  13483.  
  13484. The *select*, *insert*, *update*, and *delete* privileges allow you to
  13485. perform operations on rows in existing tables in a database.
  13486.  
  13487. `SELECT' statements require the *select* privilege only if they
  13488. actually retrieve rows from a table.  You can execute certain `SELECT'
  13489. statements even without permission to access any of the databases on the
  13490. server.  For example, you could use the `mysql' client as a simple
  13491. calculator:
  13492.  
  13493.      mysql> SELECT 1+1;
  13494.      mysql> SELECT PI()*2;
  13495.  
  13496. The *index* privilege allows you to create or drop (remove) indexes.
  13497.  
  13498. The *alter* privilege allows you to use `ALTER TABLE'.
  13499.  
  13500. The *create* and *drop* privileges allow you to create new databases
  13501. and tables, or to drop (remove) existing databases and tables.
  13502.  
  13503. Note that if you grant the *drop* privilege for the `mysql' database to
  13504. a user, that user can drop the database in which the MySQL access
  13505. privileges are stored!
  13506.  
  13507. The *grant* privilege allows you to give to other users those
  13508. privileges you yourself possess.
  13509.  
  13510. The *file* privilege gives you permission to read and write files on
  13511. the server using the `LOAD DATA INFILE' and `SELECT ... INTO OUTFILE'
  13512. statements.  Any user to whom this privilege is granted can read or
  13513. write any file that the MySQL server can read or write.
  13514.  
  13515. The remaining privileges are used for administrative operations, which
  13516. are performed using the `mysqladmin' program.  The table below shows
  13517. which `mysqladmin' commands each administrative privilege allows you to
  13518. execute:
  13519.  
  13520. *Privilege* *Commands permitted to privilege holders*
  13521. *reload*    `reload', `refresh', `flush-privileges', `flush-hosts',
  13522.             `flush-logs', and `flush-tables'
  13523. *shutdown*  `shutdown'
  13524. *process*   `processlist', `kill'
  13525.  
  13526. The `reload' command tells the server to re-read the grant tables.  The
  13527. `refresh' command flushes all tables and opens and closes the log
  13528. files.  `flush-privileges' is a synonym for `reload'.  The other
  13529. `flush-*' commands perform functions similar to `refresh' but are more
  13530. limited in scope, and may be preferable in some instances.  For example,
  13531. if you want to flush just the log files, `flush-logs' is a better choice
  13532. than `refresh'.
  13533.  
  13534. The `shutdown' command shuts down the server.
  13535.  
  13536. The `processlist' command displays information about the threads
  13537. executing within the server.  The `kill' command kills server threads.
  13538. You can always display or kill your own threads, but you need the
  13539. *process* privilege to display or kill threads initiated by other
  13540. users. *Note KILL::.
  13541.  
  13542. It is a good idea in general to grant privileges only to those users
  13543. who need them, but you should exercise particular caution in granting
  13544. certain privileges:
  13545.  
  13546.    * The *grant* privilege allows users to give away their privileges to
  13547.      other users.  Two users with different privileges and with the
  13548.      *grant* privilege are able to combine privileges.
  13549.  
  13550.    * The *alter* privilege may be used to subvert the privilege system
  13551.      by renaming tables.
  13552.  
  13553.    * The *file* privilege can be abused to read any world-readable file
  13554.      on the server into a database table, the contents of which can
  13555.      then be accessed using `SELECT'. This includes the contents of all
  13556.      databases hosted by the server!
  13557.  
  13558.    * The *shutdown* privilege can be abused to deny service to other
  13559.      users entirely, by terminating the server.
  13560.  
  13561.    * The *process* privilege can be used to view the plain text of
  13562.      currently executing queries, including queries that set or change
  13563.      passwords.
  13564.  
  13565.    * Privileges on the `mysql' database can be used to change passwords
  13566.      and other access privilege information.  (Passwords are stored
  13567.      encrypted, so a malicious user cannot simply read them to know the
  13568.      plain text password).  If they can access the `mysql.user' password
  13569.      column, they can use it to log into the MySQL server for the given
  13570.      user.  (With sufficient privileges, the same user can replace a
  13571.      password with a different one.)
  13572.  
  13573. There are some things that you cannot do with the MySQL privilege
  13574. system:
  13575.  
  13576.    * You cannot explicitly specify that a given user should be denied
  13577.      access.  That is, you cannot explicitly match a user and then
  13578.      refuse the connection.
  13579.  
  13580.    * You cannot specify that a user has privileges to create or drop
  13581.      tables in a database but not to create or drop the database itself.
  13582.  
  13583. 
  13584. File: mysql.info,  Node: Connecting,  Next: Connection access,  Prev: Privileges provided,  Up: Privilege system
  13585.  
  13586. Connecting to the MySQL Server
  13587. ------------------------------
  13588.  
  13589. MySQL client programs generally require that you specify connection
  13590. parameters when you want to access a MySQL server: the host you want to
  13591. connect to, your user name, and your password.  For example, the
  13592. `mysql' client can be started like this (optional arguments are enclosed
  13593. between `[' and `]'):
  13594.  
  13595.      shell> mysql [-h host_name] [-u user_name] [-pyour_pass]
  13596.  
  13597. Alternate forms of the `-h', `-u', and `-p' options are
  13598. `--host=host_name', `--user=user_name', and `--password=your_pass'.
  13599. Note that there is _no space_ between `-p' or `--password=' and the
  13600. password following it.
  13601.  
  13602. *NOTE:* Specifying a password on the command line is not secure!  Any
  13603. user on your system may then find out your password by typing a command
  13604. like: `ps auxww'.  *Note Option files::.
  13605.  
  13606. `mysql' uses default values for connection parameters that are missing
  13607. from the command line:
  13608.  
  13609.    * The default hostname is `localhost'.
  13610.  
  13611.    * The default user name is your Unix login name.
  13612.  
  13613.    * No password is supplied if `-p' is missing.
  13614.  
  13615. Thus, for a Unix user `joe', the following commands are equivalent:
  13616.  
  13617.      shell> mysql -h localhost -u joe
  13618.      shell> mysql -h localhost
  13619.      shell> mysql -u joe
  13620.      shell> mysql
  13621.  
  13622. Other MySQL clients behave similarly.
  13623.  
  13624. On Unix systems, you can specify different default values to be used
  13625. when you make a connection, so that you need not enter them on the
  13626. command line each time you invoke a client program.  This can be done
  13627. in a couple of ways:
  13628.  
  13629.    * You can specify connection parameters in the `[client]' section of
  13630.      the `.my.cnf' configuration file in your home directory.  The
  13631.      relevant section of the file might look like this:
  13632.  
  13633.           [client]
  13634.           host=host_name
  13635.           user=user_name
  13636.           password=your_pass
  13637.  
  13638.      *Note Option files::.
  13639.  
  13640.    * You can specify connection parameters using environment variables.
  13641.      The host can be specified for `mysql' using `MYSQL_HOST'.  The
  13642.      MySQL user name can be specified using `USER' (this is for Windows
  13643.      only).  The password can be specified using `MYSQL_PWD' (but this
  13644.      is insecure; see the next section).  *Note Environment variables::.
  13645.  
  13646. 
  13647. File: mysql.info,  Node: Connection access,  Next: Request access,  Prev: Connecting,  Up: Privilege system
  13648.  
  13649. Access Control, Stage 1: Connection Verification
  13650. ------------------------------------------------
  13651.  
  13652. When you attempt to connect to a MySQL server, the server accepts or
  13653. rejects the connection based on your identity and whether or not you can
  13654. verify your identity by supplying the correct password.  If not, the
  13655. server denies access to you completely.  Otherwise, the server accepts
  13656. the connection, then enters Stage 2 and waits for requests.
  13657.  
  13658. Your identity is based on two pieces of information:
  13659.  
  13660.    * The host from which you connect
  13661.  
  13662.    * Your MySQL user name
  13663.  
  13664. Identity checking is performed using the three `user' table scope fields
  13665. (`Host', `User', and `Password').  The server accepts the connection
  13666. only if a `user' table entry matches your hostname and user name, and
  13667. you supply the correct password.
  13668.  
  13669. Values in the `user' table scope fields may be specified as follows:
  13670.  
  13671.    * A `Host' value may be a hostname or an IP number, or `'localhost''
  13672.      to indicate the local host.
  13673.  
  13674.    * You can use the wild-card characters `%' and `_' in the `Host'
  13675.      field.
  13676.  
  13677.    * A `Host' value of `'%'' matches any hostname.
  13678.  
  13679.    * A blank `Host' value means that the privilege should be anded with
  13680.      the entry in the `host' table that matches the given host name.
  13681.      You can find more information about this in the next chapter.
  13682.  
  13683.    * As of MySQL Version 3.23, for `Host' values specified as IP
  13684.      numbers, you can specify a netmask indicating how many address
  13685.      bits to use for the network number. For example:
  13686.  
  13687.           GRANT ALL PRIVILEGES on db.* to david@'192.58.197.0/255.255.255.0';
  13688.  
  13689.      This will allow everyone to connect from an IP where the following
  13690.      is true:
  13691.  
  13692.           user_ip & netmask = host_ip.
  13693.  
  13694.      In the above example all IP:s in the interval 192.58.197.0 -
  13695.      192.58.197.255 can connect to the MySQL server.
  13696.  
  13697.    * Wild-card characters are not allowed in the `User' field, but you
  13698.      can specify a blank value, which matches any name.  If the `user'
  13699.      table entry that matches an incoming connection has a blank user
  13700.      name, the user is considered to be the anonymous user (the user
  13701.      with no name), rather than the name that the client actually
  13702.      specified.  This means that a blank user name is used for all
  13703.      further access checking for the duration of the connection (that
  13704.      is, during Stage 2).
  13705.  
  13706.    * The `Password' field can be blank.  This does not mean that any
  13707.      password matches, it means the user must connect without
  13708.      specifying a password.
  13709.  
  13710. Non-blank `Password' values represent encrypted passwords.  MySQL does
  13711. not store passwords in plaintext form for anyone to see.  Rather, the
  13712. password supplied by a user who is attempting to connect is encrypted
  13713. (using the `PASSWORD()' function). The encrypted password is then used
  13714. when the client/server is checking if the password is correct (This is
  13715. done without the encrypted password ever traveling over the
  13716. connection.)  Note that from MySQL's point of view the encrypted
  13717. password is the REAL password, so you should not give anyone access to
  13718. it!  In particular, don't give normal users read access to the tables
  13719. in the `mysql' database!
  13720.  
  13721. The examples below show how various combinations of `Host' and `User'
  13722. values in `user' table entries apply to incoming connections:
  13723.  
  13724. `Host' *value*     `User'      *Connections matched by entry*
  13725.                    *value*     
  13726. `'thomas.loc.gov'' `'fred''    `fred', connecting from `thomas.loc.gov'
  13727. `'thomas.loc.gov'' `'''        Any user, connecting from `thomas.loc.gov'
  13728. `'%''              `'fred''    `fred', connecting from any host
  13729. `'%''              `'''        Any user, connecting from any host
  13730. `'%.loc.gov''      `'fred''    `fred', connecting from any host in the
  13731.                                `loc.gov' domain
  13732. `'x.y.%''          `'fred''    `fred', connecting from `x.y.net',
  13733.                                `x.y.com',`x.y.edu', etc. (this is
  13734.                                probably not useful)
  13735. `'144.155.166.177''`'fred''    `fred', connecting from the host with IP
  13736.                                address `144.155.166.177'
  13737. `'144.155.166.%''  `'fred''    `fred', connecting from any host in the
  13738.                                `144.155.166' class C subnet
  13739. `'144.155.166.0/255.255.255.0''`'fred''    Same as previous example
  13740.  
  13741. Because you can use IP wild-card values in the `Host' field (for
  13742. example, `'144.155.166.%'' to match every host on a subnet), there is
  13743. the possibility that someone might try to exploit this capability by
  13744. naming a host `144.155.166.somewhere.com'.  To foil such attempts, MySQL
  13745. disallows matching on hostnames that start with digits and a dot. Thus,
  13746. if you have a host named something like `1.2.foo.com', its name will
  13747. never match the `Host' column of the grant tables.  Only an IP number
  13748. can match an IP wild-card value.
  13749.  
  13750. An incoming connection may be matched by more than one entry in the
  13751. `user' table.  For example, a connection from `thomas.loc.gov' by
  13752. `fred' would be matched by several of the entries just shown above.  How
  13753. does the server choose which entry to use if more than one matches?  The
  13754. server resolves this question by sorting the `user' table after reading
  13755. it at startup time, then looking through the entries in sorted order
  13756. when a user attempts to connect.  The first matching entry is the one
  13757. that is used.
  13758.  
  13759. `user' table sorting works as follows.  Suppose the `user' table looks
  13760. like this:
  13761.  
  13762.      +-----------+----------+-
  13763.      | Host      | User     | ...
  13764.      +-----------+----------+-
  13765.      | %         | root     | ...
  13766.      | %         | jeffrey  | ...
  13767.      | localhost | root     | ...
  13768.      | localhost |          | ...
  13769.      +-----------+----------+-
  13770.  
  13771. When the server reads in the table, it orders the entries with the
  13772. most-specific `Host' values first (`'%'' in the `Host' column means
  13773. "any host" and is least specific).  Entries with the same `Host' value
  13774. are ordered with the most-specific `User' values first (a blank `User'
  13775. value means "any user" and is least specific).  The resulting sorted
  13776. `user' table looks like this:
  13777.  
  13778.      +-----------+----------+-
  13779.      | Host      | User     | ...
  13780.      +-----------+----------+-
  13781.      | localhost | root     | ...
  13782.      | localhost |          | ...
  13783.      | %         | jeffrey  | ...
  13784.      | %         | root     | ...
  13785.      +-----------+----------+-
  13786.  
  13787. When a connection is attempted, the server looks through the sorted
  13788. entries and uses the first match found.  For a connection from
  13789. `localhost' by `jeffrey', the entries with `'localhost'' in the `Host'
  13790. column match first.  Of those, the entry with the blank user name
  13791. matches both the connecting hostname and user name.  (The
  13792. `'%'/'jeffrey'' entry would have matched, too, but it is not the first
  13793. match in the table.)
  13794.  
  13795. Here is another example.  Suppose the `user' table looks like this:
  13796.  
  13797.      +----------------+----------+-
  13798.      | Host           | User     | ...
  13799.      +----------------+----------+-
  13800.      | %              | jeffrey  | ...
  13801.      | thomas.loc.gov |          | ...
  13802.      +----------------+----------+-
  13803.  
  13804. The sorted table looks like this:
  13805.  
  13806.      +----------------+----------+-
  13807.      | Host           | User     | ...
  13808.      +----------------+----------+-
  13809.      | thomas.loc.gov |          | ...
  13810.      | %              | jeffrey  | ...
  13811.      +----------------+----------+-
  13812.  
  13813. A connection from `thomas.loc.gov' by `jeffrey' is matched by the first
  13814. entry, whereas a connection from `whitehouse.gov' by `jeffrey' is
  13815. matched by the second.
  13816.  
  13817. A common misconception is to think that for a given user name, all
  13818. entries that explicitly name that user will be used first when the
  13819. server attempts to find a match for the connection.  This is simply not
  13820. true.  The previous example illustrates this, where a connection from
  13821. `thomas.loc.gov' by `jeffrey' is first matched not by the entry
  13822. containing `'jeffrey'' as the `User' field value, but by the entry with
  13823. no user name!
  13824.  
  13825. If you have problems connecting to the server, print out the `user'
  13826. table and sort it by hand to see where the first match is being made.
  13827.  
  13828. 
  13829. File: mysql.info,  Node: Request access,  Next: Access denied,  Prev: Connection access,  Up: Privilege system
  13830.  
  13831. Access Control, Stage 2: Request Verification
  13832. ---------------------------------------------
  13833.  
  13834. Once you establish a connection, the server enters Stage 2.  For each
  13835. request that comes in on the connection, the server checks whether you
  13836. have sufficient privileges to perform it, based on the type of
  13837. operation you wish to perform.  This is where the privilege fields in
  13838. the grant tables come into play.  These privileges can come from any of
  13839. the `user', `db', `host', `tables_priv', or `columns_priv' tables.  The
  13840. grant tables are manipulated with `GRANT' and `REVOKE' commands.  *Note
  13841. `GRANT': GRANT.  (You may find it helpful to refer to *Note
  13842. Privileges::, which lists the fields present in each of the grant
  13843. tables.)
  13844.  
  13845. The `user' table grants privileges that are assigned to you on a global
  13846. basis and that apply no matter what the current database is.  For
  13847. example, if the `user' table grants you the *delete* privilege, you can
  13848. delete rows from any database on the server host!  In other words,
  13849. `user' table privileges are superuser privileges.  It is wise to grant
  13850. privileges in the `user' table only to superusers such as server or
  13851. database administrators.  For other users, you should leave the
  13852. privileges in the `user' table set to `'N'' and grant privileges on a
  13853. database-specific basis only, using the `db' and `host' tables.
  13854.  
  13855. The `db' and `host' tables grant database-specific privileges.  Values
  13856. in the scope fields may be specified as follows:
  13857.  
  13858.    * The wild-card characters `%' and `_' can be used in the `Host' and
  13859.      `Db' fields of either table.
  13860.  
  13861.    * A `'%'' `Host' value in the `db' table means "any host." A blank
  13862.      `Host' value in the `db' table means "consult the `host' table for
  13863.      further information."
  13864.  
  13865.    * A `'%'' or blank `Host' value in the `host' table means "any host."
  13866.  
  13867.    * A `'%'' or blank `Db' value in either table means "any database."
  13868.  
  13869.    * A blank `User' value in either table matches the anonymous user.
  13870.  
  13871. The `db' and `host' tables are read in and sorted when the server
  13872. starts up (at the same time that it reads the `user' table).  The `db'
  13873. table is sorted on the `Host', `Db', and `User' scope fields, and the
  13874. `host' table is sorted on the `Host' and `Db' scope fields.  As with
  13875. the `user' table, sorting puts the most-specific values first and
  13876. least-specific values last, and when the server looks for matching
  13877. entries, it uses the first match that it finds.
  13878.  
  13879. The `tables_priv' and `columns_priv' tables grant table- and
  13880. column-specific privileges.  Values in the scope fields may be
  13881. specified as follows:
  13882.  
  13883.    * The wild-card characters `%' and `_' can be used in the `Host'
  13884.      field of either table.
  13885.  
  13886.    * A `'%'' or blank `Host' value in either table means "any host."
  13887.  
  13888.    * The `Db', `Table_name' and `Column_name' fields cannot contain
  13889.      wild cards or be blank in either table.
  13890.  
  13891. The `tables_priv' and `columns_priv' tables are sorted on the `Host',
  13892. `Db', and `User' fields.  This is similar to `db' table sorting,
  13893. although the sorting is simpler because only the `Host' field may
  13894. contain wild cards.
  13895.  
  13896. The request verification process is described below.  (If you are
  13897. familiar with the access-checking source code, you will notice that the
  13898. description here differs slightly from the algorithm used in the code.
  13899. The description is equivalent to what the code actually does; it
  13900. differs only to make the explanation simpler.)
  13901.  
  13902. For administrative requests (*shutdown*, *reload*, etc.), the server
  13903. checks only the `user' table entry, because that is the only table that
  13904. specifies administrative privileges.  Access is granted if the entry
  13905. allows the requested operation and denied otherwise.  For example, if
  13906. you want to execute `mysqladmin shutdown' but your `user' table entry
  13907. doesn't grant the *shutdown* privilege to you, access is denied without
  13908. even checking the `db' or `host' tables.  (They contain no
  13909. `Shutdown_priv' column, so there is no need to do so.)
  13910.  
  13911. For database-related requests (*insert*, *update*, etc.), the server
  13912. first checks the user's global (superuser) privileges by looking in the
  13913. `user' table entry.  If the entry allows the requested operation,
  13914. access is granted.  If the global privileges in the `user' table are
  13915. insufficient, the server determines the user's database-specific
  13916. privileges by checking the `db' and `host' tables:
  13917.  
  13918.   1. The server looks in the `db' table for a match on the `Host',
  13919.      `Db', and `User' fields.  The `Host' and `User' fields are matched
  13920.      to the connecting user's hostname and MySQL user name.  The `Db'
  13921.      field is matched to the database the user wants to access.  If
  13922.      there is no entry for the `Host' and `User', access is denied.
  13923.  
  13924.   2. If there is a matching `db' table entry and its `Host' field is
  13925.      not blank, that entry defines the user's database-specific
  13926.      privileges.
  13927.  
  13928.   3. If the matching `db' table entry's `Host' field is blank, it
  13929.      signifies that the `host' table enumerates which hosts should be
  13930.      allowed access to the database.  In this case, a further lookup is
  13931.      done in the `host' table to find a match on the `Host' and `Db'
  13932.      fields.  If no `host' table entry matches, access is denied.  If
  13933.      there is a match, the user's database-specific privileges are
  13934.      computed as the intersection (_not_ the union!) of the privileges
  13935.      in the `db' and `host' table entries, that is, the privileges that
  13936.      are `'Y'' in both entries.  (This way you can grant general
  13937.      privileges in the `db' table entry and then selectively restrict
  13938.      them on a host-by-host basis using the `host' table entries.)
  13939.  
  13940. After determining the database-specific privileges granted by the `db'
  13941. and `host' table entries, the server adds them to the global privileges
  13942. granted by the `user' table.  If the result allows the requested
  13943. operation, access is granted.  Otherwise, the server checks the user's
  13944. table and column privileges in the `tables_priv' and `columns_priv'
  13945. tables and adds those to the user's privileges.  Access is allowed or
  13946. denied based on the result.
  13947.  
  13948. Expressed in boolean terms, the preceding description of how a user's
  13949. privileges are calculated may be summarized like this:
  13950.  
  13951.      global privileges
  13952.      OR (database privileges AND host privileges)
  13953.      OR table privileges
  13954.      OR column privileges
  13955.  
  13956. It may not be apparent why, if the global `user' entry privileges are
  13957. initially found to be insufficient for the requested operation, the
  13958. server adds those privileges to the database-, table-, and
  13959. column-specific privileges later. The reason is that a request might
  13960. require more than one type of privilege.  For example, if you execute
  13961. an `INSERT ...  SELECT' statement, you need both *insert* and *select*
  13962. privileges.  Your privileges might be such that the `user' table entry
  13963. grants one privilege and the `db' table entry grants the other.  In
  13964. this case, you have the necessary privileges to perform the request,
  13965. but the server cannot tell that from either table by itself; the
  13966. privileges granted by the entries in both tables must be combined.
  13967.  
  13968. The `host' table can be used to maintain a list of secure servers.
  13969.  
  13970. At TcX, the `host' table contains a list of all machines on the local
  13971. network. These are granted all privileges.
  13972.  
  13973. You can also use the `host' table to indicate hosts that are _not_
  13974. secure.  Suppose you have a machine `public.your.domain' that is located
  13975. in a public area that you do not consider secure.  You can allow access
  13976. to all hosts on your network except that machine by using `host' table
  13977. entries like this:
  13978.  
  13979.      +--------------------+----+-
  13980.      | Host               | Db | ...
  13981.      +--------------------+----+-
  13982.      | public.your.domain | %  | ... (all privileges set to 'N')
  13983.      | %.your.domain      | %  | ... (all privileges set to 'Y')
  13984.      +--------------------+----+-
  13985.  
  13986. Naturally, you should always test your entries in the grant tables (for
  13987. example, using `mysqlaccess') to make sure your access privileges are
  13988. actually set up the way you think they are.
  13989.  
  13990. 
  13991. File: mysql.info,  Node: Access denied,  Prev: Request access,  Up: Privilege system
  13992.  
  13993. Causes of `Access denied' Errors
  13994. --------------------------------
  13995.  
  13996. If you encounter `Access denied' errors when you try to connect to the
  13997. MySQL server, the list below indicates some courses of action you can
  13998. take to correct the problem:
  13999.  
  14000.    * After installing MySQL, did you run the `mysql_install_db' script
  14001.      to set up the initial grant table contents?  If not, do so.  *Note
  14002.      Default privileges::.  Test the initial privileges by executing
  14003.      this command:
  14004.  
  14005.           shell> mysql -u root test
  14006.  
  14007.      The server should let you connect without error.  You should also
  14008.      make sure you have a file `user.MYD' in the MySQL database
  14009.      directory.  Ordinarily, this is `PATH/var/mysql/user.MYD', where
  14010.      `PATH' is the pathname to the MySQL installation root.
  14011.  
  14012.    * After a fresh installation, you should connect to the server and
  14013.      set up your users and their access permissions:
  14014.  
  14015.           shell> mysql -u root mysql
  14016.  
  14017.      The server should let you connect because the MySQL `root' user
  14018.      has no password initially.  That is also a security risk, so
  14019.      setting the `root' password is something you should do while
  14020.      you're setting up your other MySQL users.
  14021.  
  14022.      If you try to connect as `root' and get this error:
  14023.  
  14024.           Access denied for user: '@unknown' to database mysql
  14025.  
  14026.      this means that you don't have an entry in the `user' table with a
  14027.      `User' column value of `'root'' and that `mysqld' cannot resolve
  14028.      the hostname for your client.  In this case, you must restart the
  14029.      server with the `--skip-grant-tables' option and edit your
  14030.      `/etc/hosts' or `\windows\hosts' file to add an entry for your
  14031.      host.
  14032.  
  14033.    * If you get an error like the following:
  14034.  
  14035.           shell> mysqladmin -u root -pxxxx ver
  14036.           Access denied for user: 'root@localhost' (Using password: YES)
  14037.  
  14038.      It means that you are using a wrong password. *Note Passwords::.
  14039.  
  14040.      If you have forgot the root password, you can restart `mysqld' with
  14041.      `--skip-grant-tables' to change the password. You can find more
  14042.      about this option later on in this manual section.
  14043.  
  14044.      If you get the above error even if you haven't specified a
  14045.      password, this means that you a wrong password in some `my.ini'
  14046.      file. *Note Option files::.  You can avoid using option files with
  14047.      the `--no-defaults' option, as follows:
  14048.  
  14049.           shell> mysqladmin --no-defaults -u root ver
  14050.  
  14051.    * If you updated an existing MySQL installation from a version
  14052.      earlier than Version 3.22.11 to Version 3.22.11 or later, did you
  14053.      run the `mysql_fix_privilege_tables' script?  If not, do so.  The
  14054.      structure of the grant tables changed with MySQL Version 3.22.11
  14055.      when the `GRANT' statement became functional.
  14056.  
  14057.    * If your privileges seem to have changed in the middle of a
  14058.      session, it may be that a superuser has changed them.  Reloading
  14059.      the grant tables affects new client connections, but it also
  14060.      affects existing connections as indicated in *Note Privilege
  14061.      changes::.
  14062.  
  14063.    * If you can't get your password to work, remember that you must use
  14064.      the `PASSWORD()' function if you set the password with the
  14065.      `INSERT', `UPDATE', or `SET PASSWORD' statements.  The
  14066.      `PASSWORD()' function is unnecessary if you specify the password
  14067.      using the `GRANT ... INDENTIFIED BY' statement or the `mysqladmin
  14068.      password' command.  *Note Passwords::.
  14069.  
  14070.    * `localhost' is a synonym for your local hostname, and is also the
  14071.      default host to which clients try to connect if you specify no host
  14072.      explicitly.  However, connections to `localhost' do not work if
  14073.      you are running on a system that uses MIT-pthreads (`localhost'
  14074.      connections are made using Unix sockets, which are not supported
  14075.      by MIT-pthreads).  To avoid this problem on such systems, you
  14076.      should use the `--host' option to name the server host explicitly.
  14077.      This will make a TCP/IP connection to the `mysqld' server.  In
  14078.      this case, you must have your real hostname in `user' table
  14079.      entries on the server host.  (This is true even if you are running
  14080.      a client program on the same host as the server.)
  14081.  
  14082.    * If you get an `Access denied' error when trying to connect to the
  14083.      database with `mysql -u user_name db_name', you may have a problem
  14084.      with the `user' table. Check this by executing `mysql -u root
  14085.      mysql' and issuing this SQL statement:
  14086.  
  14087.           mysql> SELECT * FROM user;
  14088.  
  14089.      The result should include an entry with the `Host' and `User'
  14090.      columns matching your computer's hostname and your MySQL user name.
  14091.  
  14092.    * The `Access denied' error message will tell you who you are trying
  14093.      to log in as, the host from which you are trying to connect, and
  14094.      whether or not you were using a password. Normally, you should
  14095.      have one entry in the `user' table that exactly matches the
  14096.      hostname and user name that were given in the error message. For
  14097.      example if you get an error message that contains `Using password:
  14098.      NO', this means that you tried to login without an password.
  14099.  
  14100.    * If you get the following error when you try to connect from a
  14101.      different host than the one on which the MySQL server is running,
  14102.      then there is no row in the `user' table that matches that host:
  14103.  
  14104.           Host ... is not allowed to connect to this MySQL server
  14105.  
  14106.      You can fix this by using the command-line tool `mysql' (on the
  14107.      server host!) to add a row to the `user', `db', or `host' table
  14108.      for the user/hostname combination from which you are trying to
  14109.      connect and then execute `mysqladmin flush-privileges'.  If you are
  14110.      not running MySQL Version 3.22 and you don't know the IP number or
  14111.      hostname of the machine from which you are connecting, you should
  14112.      put an entry with `'%'' as the `Host' column value in the `user'
  14113.      table and restart `mysqld' with the `--log' option on the server
  14114.      machine.  After trying to connect from the client machine, the
  14115.      information in the MySQL log will indicate how you really did
  14116.      connect.  (Then replace the `'%'' in the `user' table entry with
  14117.      the actual hostname that shows up in the log.  Otherwise, you'll
  14118.      have a system that is insecure.)
  14119.  
  14120.      Another reason for this error on Linux is that you are using a
  14121.      binary MySQL version that is compiled with a different glibc
  14122.      version than the one you are using.  In this case you should
  14123.      either upgrade your OS/glibc or download the source MySQL version
  14124.      and compile this yourself.  A source RPM is normally trivial to
  14125.      compile and install, so this isn't a big problem.
  14126.  
  14127.    * If you get an error message where the hostname is not shown or
  14128.      where the hostname is an IP, even if you try to connect with a
  14129.      hostname:
  14130.  
  14131.           shell> mysqladmin -u root -pxxxx -h some-hostname ver
  14132.           Access denied for user: 'root('Using password: YES)
  14133.  
  14134.      This means that MySQL got some error when trying to resolve the IP
  14135.      to a hostname.  In this case you can execute `mysqladmin
  14136.      flush-hosts' to reset the internal DNS cache. *Note DNS::.
  14137.  
  14138.      Some permanent solutions are:
  14139.  
  14140.         - Try to find out what is wrong with your DNS server and fix
  14141.           this.
  14142.  
  14143.         - Specify IPs instead of hostnames in the MySQL privilege
  14144.           tables.
  14145.  
  14146.         - Start `mysqld' with `--skip-name-resolve'.
  14147.  
  14148.         - Start `mysqld' with `--skip-host-cache'.
  14149.  
  14150.         - Connect to `localhost' if you are running the server and the
  14151.           client on the same machine.
  14152.  
  14153.         - Put the client machine names in `/etc/hosts'.
  14154.  
  14155.    * If `mysql -u root test' works but `mysql -h your_hostname -u root
  14156.      test' results in `Access denied', then you may not have the
  14157.      correct name for your host in the `user' table.  A common problem
  14158.      here is that the `Host' value in the user table entry specifies an
  14159.      unqualified hostname, but your system's name resolution routines
  14160.      return a fully qualified domain name (or vice-versa).  For
  14161.      example, if you have an entry with host `'tcx'' in the `user'
  14162.      table, but your DNS tells MySQL that your hostname is
  14163.      `'tcx.subnet.se'', the entry will not work. Try adding an entry to
  14164.      the `user' table that contains the IP number of your host as the
  14165.      `Host' column value.  (Alternatively, you could add an entry to the
  14166.      `user' table with a `Host' value that contains a wild card--for
  14167.      example, `'tcx.%''.  However, use of hostnames ending with `%' is
  14168.      _insecure_ and is _not_ recommended!)
  14169.  
  14170.    * If `mysql -u user_name test' works but `mysql -u user_name
  14171.      other_db_name' doesn't work, you don't have an entry for
  14172.      `other_db_name' listed in the `db' table.
  14173.  
  14174.    * If `mysql -u user_name db_name' works when executed on the server
  14175.      machine, but `mysql -u host_name -u user_name db_name' doesn't
  14176.      work when executed on another client machine, you don't have the
  14177.      client machine listed in the `user' table or the `db' table.
  14178.  
  14179.    * If you can't figure out why you get `Access denied', remove from
  14180.      the `user' table all entries that have `Host' values containing
  14181.      wild cards (entries that contain `%' or `_').  A very common error
  14182.      is to insert a new entry with `Host'=`'%'' and `User'=`'some
  14183.      user'', thinking that this will allow you to specify `localhost'
  14184.      to connect from the same machine.  The reason that this doesn't
  14185.      work is that the default privileges include an entry with
  14186.      `Host'=`'localhost'' and `User'=`'''.  Because that entry has a
  14187.      `Host' value `'localhost'' that is more specific than `'%'', it is
  14188.      used in preference to the new entry when connecting from
  14189.      `localhost'!  The correct procedure is to insert a second entry
  14190.      with `Host'=`'localhost'' and `User'=`'some_user'', or to remove
  14191.      the entry with `Host'=`'localhost'' and `User'=`'''.
  14192.  
  14193.    * If you get the following error, you may have a problem with the
  14194.      `db' or `host' table:
  14195.  
  14196.           Access to database denied
  14197.  
  14198.      If the entry selected from the `db' table has an empty value in the
  14199.      `Host' column, make sure there are one or more corresponding
  14200.      entries in the `host' table specifying which hosts the `db' table
  14201.      entry applies to.
  14202.  
  14203.      If you get the error when using the SQL commands `SELECT ...  INTO
  14204.      OUTFILE' or `LOAD DATA INFILE', your entry in the `user' table
  14205.      probably doesn't have the *file* privilege enabled.
  14206.  
  14207.    * Remember that client programs will use connection parameters
  14208.      specified in configuration files or environment variables.  *Note
  14209.      Environment variables::.  If a client seems to be sending the
  14210.      wrong default connection parameters when you don't specify them on
  14211.      the command line, check your environment and the `.my.cnf' file in
  14212.      your home directory.  You might also check the system-wide MySQL
  14213.      configuration files, though it is far less likely that client
  14214.      connection parameters will be specified there. *Note Option
  14215.      files::.  If you get `Access denied' when you run a client without
  14216.      any options, make sure you haven't specified an old password in
  14217.      any of your option files!  *Note Option files::.
  14218.  
  14219.    * If you make changes to the grant tables directly (using an
  14220.      `INSERT' or `UPDATE' statement) and your changes seem to be
  14221.      ignored, remember that you must issue a `FLUSH PRIVILEGES'
  14222.      statement or execute a `mysqladmin flush-privileges' command to
  14223.      cause the server to re-read the privilege tables.  Otherwise your
  14224.      changes have no effect until the next time the server is
  14225.      restarted.  Remember that after you set the `root' password with
  14226.      an `UPDATE' command, you won't need to specify it until after you
  14227.      flush the privileges, because the server won't know you've changed
  14228.      the password yet!
  14229.  
  14230.    * If you have access problems with a Perl, PHP, Python, or ODBC
  14231.      program, try to connect to the server with `mysql -u user_name
  14232.      db_name' or `mysql -u user_name -pyour_pass db_name'.  If you are
  14233.      able to connect using the `mysql' client, there is a problem with
  14234.      your program and not with the access privileges.  (Note that there
  14235.      is no space between `-p' and the password; you can also use the
  14236.      `--password=your_pass' syntax to specify the password. If you use
  14237.      the `-p' option alone, MySQL will prompt you for the password.)
  14238.  
  14239.    * For testing, start the `mysqld' daemon with the
  14240.      `--skip-grant-tables' option.  Then you can change the MySQL grant
  14241.      tables and use the `mysqlaccess' script to check whether or not
  14242.      your modifications have the desired effect.  When you are
  14243.      satisfied with your changes, execute `mysqladmin flush-privileges'
  14244.      to tell the `mysqld' server to start using the new grant tables.
  14245.      *Note:* Reloading the grant tables overrides the
  14246.      `--skip-grant-tables' option.  This allows you to tell the server
  14247.      to begin using the grant tables again without bringing it down and
  14248.      restarting it.
  14249.  
  14250.    * If everything else fails, start the `mysqld' daemon with a
  14251.      debugging option (for example, `--debug=d,general,query'). This
  14252.      will print host and user information about attempted connections,
  14253.      as well as information about each command issued. *Note Making
  14254.      trace files::.
  14255.  
  14256.    * If you have any other problems with the MySQL grant tables and
  14257.      feel you must post the problem to the mailing list, always provide
  14258.      a dump of the MySQL grant tables. You can dump the tables with the
  14259.      `mysqldump mysql' command. As always, post your problem using the
  14260.      `mysqlbug' script.  *Note Bug reports::.  In some cases you may
  14261.      need to restart `mysqld' with `--skip-grant-tables' to run
  14262.      `mysqldump'.
  14263.  
  14264. 
  14265. File: mysql.info,  Node: User Account Management,  Next: Disaster Prevention,  Prev: Privilege system,  Up: MySQL Database Administration
  14266.  
  14267. MySQL User Account Management
  14268. =============================
  14269.  
  14270. * Menu:
  14271.  
  14272. * GRANT::                       `GRANT' and `REVOKE' Syntax
  14273. * User names::                  MySQL User Names and Passwords
  14274. * Privilege changes::           When Privilege Changes Take Effect
  14275. * Default privileges::          Setting Up the Initial MySQL Privileges
  14276. * Adding users::                Adding New Users to MySQL
  14277. * Passwords::                   Setting Up Passwords
  14278. * Password security::           Keeping Your Password Secure
  14279.  
  14280. 
  14281. File: mysql.info,  Node: GRANT,  Next: User names,  Prev: User Account Management,  Up: User Account Management
  14282.  
  14283. `GRANT' and `REVOKE' Syntax
  14284. ---------------------------
  14285.  
  14286.      GRANT priv_type [(column_list)] [, priv_type [(column_list)] ...]
  14287.          ON {tbl_name | * | *.* | db_name.*}
  14288.          TO user_name [IDENTIFIED BY 'password']
  14289.              [, user_name [IDENTIFIED BY 'password'] ...]
  14290.          [WITH GRANT OPTION]
  14291.      
  14292.      REVOKE priv_type [(column_list)] [, priv_type [(column_list)] ...]
  14293.          ON {tbl_name | * | *.* | db_name.*}
  14294.          FROM user_name [, user_name ...]
  14295.  
  14296. `GRANT' is implemented in MySQL Version 3.22.11 or later. For earlier
  14297. MySQL versions, the `GRANT' statement does nothing.
  14298.  
  14299. The `GRANT' and `REVOKE' commands allow system administrators to create
  14300. users and grant and revoke rights to MySQL users at four privilege
  14301. levels:
  14302.  
  14303. *Global level*
  14304.      Global privileges apply to all databases on a given server. These
  14305.      privileges are stored in the `mysql.user' table.
  14306.  
  14307. *Database level*
  14308.      Database privileges apply to all tables in a given database. These
  14309.      privileges are stored in the `mysql.db' and `mysql.host' tables.
  14310.  
  14311. *Table level*
  14312.      Table privileges apply to all columns in a given table. These
  14313.      privileges are stored in the `mysql.tables_priv' table.
  14314.  
  14315. *Column level*
  14316.      Column privileges apply to single columns in a given table. These
  14317.      privileges are stored in the `mysql.columns_priv' table.
  14318.  
  14319. If you give a grant for a users that doesn't exists, that user is
  14320. created.  For examples of how `GRANT' works, see *Note Adding users::.
  14321.  
  14322. For the `GRANT' and `REVOKE' statements, `priv_type' may be specified
  14323. as any of the following:
  14324.  
  14325.      ALL PRIVILEGES      FILE                RELOAD
  14326.      ALTER               INDEX               SELECT
  14327.      CREATE              INSERT              SHUTDOWN
  14328.      DELETE              PROCESS             UPDATE
  14329.      DROP                REFERENCES          USAGE
  14330.  
  14331. `ALL' is a synonym for `ALL PRIVILEGES'.  `REFERENCES' is not yet
  14332. implemented.  `USAGE' is currently a synonym for "no privileges."  It
  14333. can be used when you want to create a user that has no privileges.
  14334.  
  14335. To revoke the *grant* privilege from a user, use a `priv_type' value of
  14336. `GRANT OPTION':
  14337.  
  14338.      REVOKE GRANT OPTION ON ... FROM ...;
  14339.  
  14340. The only `priv_type' values you can specify for a table are `SELECT',
  14341. `INSERT', `UPDATE', `DELETE', `CREATE', `DROP', `GRANT', `INDEX', and
  14342. `ALTER'.
  14343.  
  14344. The only `priv_type' values you can specify for a column (that is, when
  14345. you use a `column_list' clause) are `SELECT', `INSERT', and `UPDATE'.
  14346.  
  14347. You can set global privileges by using `ON *.*' syntax.  You can set
  14348. database privileges by using `ON db_name.*' syntax. If you specify `ON
  14349. *' and you have a current database, you will set the privileges for
  14350. that database.  (*WARNING:* If you specify `ON *' and you _don't_ have
  14351. a current database, you will affect the global privileges!)
  14352.  
  14353. In order to accommodate granting rights to users from arbitrary hosts,
  14354. MySQL supports specifying the `user_name' value in the form
  14355. `user@host'.  If you want to specify a `user' string containing special
  14356. characters (such as `-'), or a `host' string containing special
  14357. characters or wild-card characters (such as `%'), you can quote the
  14358. user or host name (for example, `'test-user'@'test-hostname'').
  14359.  
  14360. You can specify wild cards in the hostname.  For example,
  14361. `user@"%.loc.gov"' applies to `user' for any host in the `loc.gov'
  14362. domain, and `user@"144.155.166.%"' applies to `user' for any host in
  14363. the `144.155.166' class C subnet.
  14364.  
  14365. The simple form `user' is a synonym for `user@"%"'.  *NOTE:* If you
  14366. allow anonymous users to connect to the MySQL server (which is the
  14367. default), you should also add all local users as `user@localhost'
  14368. because otherwise the anonymous user entry for the local host in the
  14369. `mysql.user' table will be used when the user tries to log into the
  14370. MySQL server from the local machine!  Anonymous users are defined by
  14371. inserting entries with `User=''' into the `mysql.user' table. You can
  14372. verify if this applies to you by executing this query:
  14373.  
  14374.      mysql> SELECT Host,User FROM mysql.user WHERE User='';
  14375.  
  14376. For the moment, `GRANT' only supports host, table, database, and column
  14377. names up to 60 characters long. A user name can be up to 16 characters.
  14378.  
  14379. The privileges for a table or column are formed from the logical OR of
  14380. the privileges at each of the four privilege levels.  For example, if
  14381. the `mysql.user' table specifies that a user has a global *select*
  14382. privilege, this can't be denied by an entry at the database, table, or
  14383. column level.
  14384.  
  14385. The privileges for a column can be calculated as follows:
  14386.  
  14387.      global privileges
  14388.      OR (database privileges AND host privileges)
  14389.      OR table privileges
  14390.      OR column privileges
  14391.  
  14392. In most cases, you grant rights to a user at only one of the privilege
  14393. levels, so life isn't normally as complicated as above. The details of
  14394. the privilege-checking procedure are presented in *Note Privilege
  14395. system::.
  14396.  
  14397. If you grant privileges for a user/hostname combination that does not
  14398. exist in the `mysql.user' table, an entry is added and remains there
  14399. until deleted with a `DELETE' command.  In other words, `GRANT' may
  14400. create `user' table entries, but `REVOKE' will not remove them; you
  14401. must do that explicitly using `DELETE'.
  14402.  
  14403. In MySQL Version 3.22.12 or later, if a new user is created or if you
  14404. have global grant privileges, the user's password will be set to the
  14405. password specified by the `IDENTIFIED BY' clause, if one is given.  If
  14406. the user already had a password, it is replaced by the new one.
  14407.  
  14408. *WARNING:* If you create a new user but do not specify an `IDENTIFIED
  14409. BY' clause, the user has no password.  This is insecure.
  14410.  
  14411. Passwords can also be set with the `SET PASSWORD' command.  *Note `SET
  14412. OPTION': SET OPTION.
  14413.  
  14414. If you grant privileges for a database, an entry in the `mysql.db'
  14415. table is created if needed. When all privileges for the database have
  14416. been removed with `REVOKE', this entry is deleted.
  14417.  
  14418. If a user doesn't have any privileges on a table, the table is not
  14419. displayed when the user requests a list of tables (for example, with a
  14420. `SHOW TABLES' statement).
  14421.  
  14422. The `WITH GRANT OPTION' clause gives the user the ability to give to
  14423. other users any privileges the user has at the specified privilege
  14424. level.  You should be careful to whom you give the *grant* privilege,
  14425. as two users with different privileges may be able to join privileges!
  14426.  
  14427. You cannot grant another user a privilege you don't have yourself; the
  14428. *grant* privilege allows you to give away only those privileges you
  14429. possess.
  14430.  
  14431. Be aware that when you grant a user the *grant* privilege at a
  14432. particular privilege level, any privileges the user already possesses
  14433. (or is given in the future!) at that level are also grantable by that
  14434. user.  Suppose you grant a user the *insert* privilege on a database.
  14435. If you then grant the *select* privilege on the database and specify
  14436. `WITH GRANT OPTION', the user can give away not only the *select*
  14437. privilege, but also *insert*.  If you then grant the *update* privilege
  14438. to the user on the database, the user can give away the *insert*,
  14439. *select* and *update*.
  14440.  
  14441. You should not grant *alter* privileges to a normal user.  If you do
  14442. that, the user can try to subvert the privilege system by renaming
  14443. tables!
  14444.  
  14445. Note that if you are using table or column privileges for even one
  14446. user, the server examines table and column privileges for all users and
  14447. this will slow down MySQL a bit.
  14448.  
  14449. When `mysqld' starts, all privileges are read into memory.  Database,
  14450. table, and column privileges take effect at once, and user-level
  14451. privileges take effect the next time the user connects.  Modifications
  14452. to the grant tables that you perform using `GRANT' or `REVOKE' are
  14453. noticed by the server immediately.  If you modify the grant tables
  14454. manually (using `INSERT', `UPDATE', etc.), you should execute a `FLUSH
  14455. PRIVILEGES' statement or run `mysqladmin flush-privileges' to tell the
  14456. server to reload the grant tables.  *Note Privilege changes::.
  14457.  
  14458. The biggest differences between the ANSI SQL and MySQL versions of
  14459. `GRANT' are:
  14460.  
  14461.    * In MySQL privileges are given for an username + hostname
  14462.      combination and not only for an username.
  14463.  
  14464.    * ANSI SQL doesn't have global or database-level privileges, and
  14465.      ANSI SQL doesn't support all privilege types that MySQL supports.
  14466.      MySQL doesn't support the ANSI SQL `TRIGGER', `EXECUTE' or `UNDER'
  14467.      privileges.
  14468.  
  14469.    * ANSI SQL privileges are structured in a hierarchal manner. If you
  14470.      remove an user, all privileges the user has granted are revoked. In
  14471.      MySQL the granted privileges are not automatically revoked, but
  14472.      you have to revoke these yourself if needed.
  14473.  
  14474.    * If you in MySQL have the `INSERT' grant on only part of the
  14475.      columns in a table, you can execute `INSERT' statements on the
  14476.      table; The columns for which you don't have the `INSERT' privilege
  14477.      will set to their default values. ANSI SQL requires you to have the
  14478.      `INSERT' privilege on all columns.
  14479.  
  14480.    * When you drop a table in ANSI SQL, all privileges for the table
  14481.      are revoked.  If you revoke a privilege in ANSI SQL, all
  14482.      privileges that were granted based on this privilege are also
  14483.      revoked. In MySQL, privileges can be dropped only with explicit
  14484.      `REVOKE' commands or by manipulating the MySQL grant tables.
  14485.  
  14486. 
  14487. File: mysql.info,  Node: User names,  Next: Privilege changes,  Prev: GRANT,  Up: User Account Management
  14488.  
  14489. MySQL User Names and Passwords
  14490. ------------------------------
  14491.  
  14492. There are several distinctions between the way user names and passwords
  14493. are used by MySQL and the way they are used by Unix or Windows:
  14494.  
  14495.    * User names, as used by MySQL for authentication purposes, have
  14496.      nothing to do with Unix user names (login names) or Windows user
  14497.      names.  Most MySQL clients by default try to log in using the
  14498.      current Unix user name as the MySQL user name, but that is for
  14499.      convenience only.  Client programs allow a different name to be
  14500.      specified with the `-u' or `--user' options. This means that you
  14501.      can't make a database secure in any way unless all MySQL user
  14502.      names have passwords.  Anyone may attempt to connect to the server
  14503.      using any name, and they will succeed if they specify any name
  14504.      that doesn't have a password.
  14505.  
  14506.    * MySQL user names can be up to 16 characters long; Unix user names
  14507.      typically are limited to 8 characters.
  14508.  
  14509.    * MySQL passwords have nothing to do with Unix passwords.  There is
  14510.      no necessary connection between the password you use to log in to
  14511.      a Unix machine and the password you use to access a database on
  14512.      that machine.
  14513.  
  14514.    * MySQL encrypts passwords using a different algorithm than the one
  14515.      used during the Unix login process.  See the descriptions of the
  14516.      `PASSWORD()' and `ENCRYPT()' functions in *Note Miscellaneous
  14517.      functions::.  Note that even if the password is stored
  14518.      'scrambled', and knowing your 'scrambled' password is enough to be
  14519.      able to connect to the MySQL server!
  14520.  
  14521. MySQL users and their privileges are normally created with the `GRANT'
  14522. command. *Note GRANT::.
  14523.  
  14524. When you login to a MySQL server with a command line client you should
  14525. specify the password with `--password=your-password'.  *Note
  14526. Connecting::.
  14527.  
  14528.      mysql --user=monty --password=guess database_name
  14529.  
  14530. If you want the client to prompt for a password, you should use
  14531. `--password' without any argument
  14532.  
  14533.      mysql --user=monty --password database_name
  14534.  
  14535. or the short form:
  14536.  
  14537.      mysql -u monty -p database_name
  14538.  
  14539. Note that in the last example the password is *NOT* 'database_name'.
  14540.  
  14541. If you want to use the `-p' option to supply a password you should do so
  14542. like this:
  14543.  
  14544.      mysql -u monty -pguess database_name
  14545.  
  14546. On some systems, the library call that MySQL uses to prompt for a
  14547. password will automatically cut the password to 8 characters. Internally
  14548. MySQL doesn't have any limit for the length of the password.
  14549.  
  14550. 
  14551. File: mysql.info,  Node: Privilege changes,  Next: Default privileges,  Prev: User names,  Up: User Account Management
  14552.  
  14553. When Privilege Changes Take Effect
  14554. ----------------------------------
  14555.  
  14556. When `mysqld' starts, all grant table contents are read into memory and
  14557. become effective at that point.
  14558.  
  14559. Modifications to the grant tables that you perform using `GRANT',
  14560. `REVOKE', or `SET PASSWORD' are noticed by the server immediately.
  14561.  
  14562. If you modify the grant tables manually (using `INSERT', `UPDATE',
  14563. etc.), you should execute a `FLUSH PRIVILEGES' statement or run
  14564. `mysqladmin flush-privileges' or `mysqladmin reload' to tell the server
  14565. to reload the grant tables.  Otherwise your changes will have _no
  14566. effect_ until you restart the server. If you change the grant tables
  14567. manually but forget to reload the privileges, you will be wondering why
  14568. your changes don't seem to make any difference!
  14569.  
  14570. When the server notices that the grant tables have been changed,
  14571. existing client connections are affected as follows:
  14572.  
  14573.    * Table and column privilege changes take effect with the client's
  14574.      next request.
  14575.  
  14576.    * Database privilege changes take effect at the next `USE db_name'
  14577.      command.
  14578.  
  14579. Global privilege changes and password changes take effect the next time
  14580. the client connects.
  14581.  
  14582. 
  14583. File: mysql.info,  Node: Default privileges,  Next: Adding users,  Prev: Privilege changes,  Up: User Account Management
  14584.  
  14585. Setting Up the Initial MySQL Privileges
  14586. ---------------------------------------
  14587.  
  14588. After installing MySQL, you set up the initial access privileges by
  14589. running `scripts/mysql_install_db'.  *Note Quick install::.  The
  14590. `mysql_install_db' script starts up the `mysqld' server, then
  14591. initializes the grant tables to contain the following set of privileges:
  14592.  
  14593.    * The MySQL `root' user is created as a superuser who can do
  14594.      anything.  Connections must be made from the local host.
  14595.  
  14596.      *NOTE:* The initial `root' password is empty, so anyone can
  14597.      connect as `root' _without a password_ and be granted all
  14598.      privileges.
  14599.  
  14600.    * An anonymous user is created that can do anything with databases
  14601.      that have a name of `'test'' or starting with `'test_''.
  14602.      Connections must be made from the local host.  This means any
  14603.      local user can connect without a password and be treated as the
  14604.      anonymous user.
  14605.  
  14606.    * Other privileges are denied.  For example, normal users can't use
  14607.      `mysqladmin shutdown' or `mysqladmin processlist'.
  14608.  
  14609. *NOTE:* The default privileges are different for Windows.  *Note
  14610. Windows running::.
  14611.  
  14612. Because your installation is initially wide open, one of the first
  14613. things you should do is specify a password for the MySQL `root' user.
  14614. You can do this as follows (note that you specify the password using
  14615. the `PASSWORD()' function):
  14616.  
  14617.      shell> mysql -u root mysql
  14618.      mysql> UPDATE user SET Password=PASSWORD('new_password')
  14619.                 WHERE user='root';
  14620.      mysql> FLUSH PRIVILEGES;
  14621.  
  14622. You can, in MySQL Version 3.22 and above, use the `SET PASSWORD'
  14623. statement:
  14624.  
  14625.      shell> mysql -u root mysql
  14626.      mysql> SET PASSWORD FOR root=PASSWORD('new_password');
  14627.  
  14628. Another way to set the password is by using the `mysqladmin' command:
  14629.  
  14630.      shell> mysqladmin -u root password new_password
  14631.  
  14632. Only users with write/update access to the `mysql' database can change
  14633. the password for others users.  All normal users (not anonymous ones)
  14634. can only change their own password with either of the above commands or
  14635. with `SET PASSWORD=PASSWORD('new password')'.
  14636.  
  14637. Note that if you update the password in the `user' table directly using
  14638. the first method, you must tell the server to re-read the grant tables
  14639. (with `FLUSH PRIVILEGES'), because the change will go unnoticed
  14640. otherwise.
  14641.  
  14642. Once the `root' password has been set, thereafter you must supply that
  14643. password when you connect to the server as `root'.
  14644.  
  14645. You may wish to leave the `root' password blank so that you don't need
  14646. to specify it while you perform additional setup or testing. However,
  14647. be sure to set it before using your installation for any real
  14648. production work.
  14649.  
  14650. See the `scripts/mysql_install_db' script to see how it sets up the
  14651. default privileges.  You can use this as a basis to see how to add
  14652. other users.
  14653.  
  14654. If you want the initial privileges to be different than those just
  14655. described above, you can modify `mysql_install_db' before you run it.
  14656.  
  14657. To re-create the grant tables completely, remove all the `.frm',
  14658. `.MYI', and `.MYD' files in the directory containing the `mysql'
  14659. database.  (This is the directory named `mysql' under the database
  14660. directory, which is listed when you run `mysqld --help'.) Then run the
  14661. `mysql_install_db' script, possibly after editing it first to have the
  14662. privileges you want.
  14663.  
  14664. *NOTE:* For MySQL versions older than Version 3.22.10, you should NOT
  14665. delete the `.frm' files.  If you accidentally do this, you should copy
  14666. them back from your MySQL distribution before running
  14667. `mysql_install_db'.
  14668.  
  14669. 
  14670. File: mysql.info,  Node: Adding users,  Next: Passwords,  Prev: Default privileges,  Up: User Account Management
  14671.  
  14672. Adding New Users to MySQL
  14673. -------------------------
  14674.  
  14675. You can add users two different ways: by using `GRANT' statements or by
  14676. manipulating the MySQL grant tables directly.  The preferred method is
  14677. to use `GRANT' statements, because they are more concise and less
  14678. error-prone. *Note GRANT::.
  14679.  
  14680. There is also a lot of contributed programs like `phpmyadmin' that can
  14681. be used to create and administrate users. *Note Contrib::.
  14682.  
  14683. The examples below show how to use the `mysql' client to set up new
  14684. users.  These examples assume that privileges are set up according to
  14685. the defaults described in the previous section.  This means that to
  14686. make changes, you must be on the same machine where `mysqld' is
  14687. running, you must connect as the MySQL `root' user, and the `root' user
  14688. must have the *insert* privilege for the `mysql' database and the
  14689. *reload* administrative privilege.  Also, if you have changed the
  14690. `root' user password, you must specify it for the `mysql' commands
  14691. below.
  14692.  
  14693. You can add new users by issuing `GRANT' statements:
  14694.  
  14695.      shell> mysql --user=root mysql
  14696.      mysql> GRANT ALL PRIVILEGES ON *.* TO monty@localhost
  14697.                 IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
  14698.      mysql> GRANT ALL PRIVILEGES ON *.* TO monty@"%"
  14699.                 IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
  14700.      mysql> GRANT RELOAD,PROCESS ON *.* TO admin@localhost;
  14701.      mysql> GRANT USAGE ON *.* TO dummy@localhost;
  14702.  
  14703. These `GRANT' statements set up three new users:
  14704.  
  14705. `monty'
  14706.      A full superuser who can connect to the server from anywhere, but
  14707.      who must use a password `'some_pass'' to do so.  Note that we must
  14708.      issue `GRANT' statements for both `monty@localhost' and
  14709.      `monty@"%"'.  If we don't add the entry with `localhost', the
  14710.      anonymous user entry for `localhost' that is created by
  14711.      `mysql_install_db' will take precedence when we connect from the
  14712.      local host, because it has a more specific `Host' field value and
  14713.      thus comes earlier in the `user' table sort order.
  14714.  
  14715. `admin'
  14716.      A user who can connect from `localhost' without a password and who
  14717.      is granted the *reload* and *process* administrative privileges.
  14718.      This allows the user to execute the `mysqladmin reload',
  14719.      `mysqladmin refresh', and `mysqladmin flush-*' commands, as well as
  14720.      `mysqladmin processlist' .  No database-related privileges are
  14721.      granted.  (They can be granted later by issuing additional `GRANT'
  14722.      statements.)
  14723.  
  14724. `dummy'
  14725.      A user who can connect without a password, but only from the local
  14726.      host.  The global privileges are all set to `'N'' -- the `USAGE'
  14727.      privilege type allows you to create a user with no privileges.  It
  14728.      is assumed that you will grant database-specific privileges later.
  14729.  
  14730. You can also add the same user access information directly by issuing
  14731. `INSERT' statements and then telling the server to reload the grant
  14732. tables:
  14733.  
  14734.      shell> mysql --user=root mysql
  14735.      mysql> INSERT INTO user VALUES('localhost','monty',PASSWORD('some_pass'),
  14736.                      'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
  14737.      mysql> INSERT INTO user VALUES('%','monty',PASSWORD('some_pass'),
  14738.                      'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
  14739.      mysql> INSERT INTO user SET Host='localhost',User='admin',
  14740.                       Reload_priv='Y', Process_priv='Y';
  14741.      mysql> INSERT INTO user (Host,User,Password)
  14742.                              VALUES('localhost','dummy','');
  14743.      mysql> FLUSH PRIVILEGES;
  14744.  
  14745. Depending on your MySQL version, you may have to use a different number
  14746. of `'Y'' values above (versions prior to Version 3.22.11 had fewer
  14747. privilege columns).  For the `admin' user, the more readable extended
  14748. `INSERT' syntax that is available starting with Version 3.22.11 is used.
  14749.  
  14750. Note that to set up a superuser, you need only create a `user' table
  14751. entry with the privilege fields set to `'Y''.  No `db' or `host' table
  14752. entries are necessary.
  14753.  
  14754. The privilege columns in the `user' table were not set explicitly in the
  14755. last `INSERT' statement (for the `dummy' user), so those columns are
  14756. assigned the default value of `'N''.  This is the same thing that
  14757. `GRANT USAGE' does.
  14758.  
  14759. The following example adds a user `custom' who can connect from hosts
  14760. `localhost', `server.domain', and `whitehouse.gov'.  He wants to access
  14761. the `bankaccount' database only from `localhost', the `expenses'
  14762. database only from `whitehouse.gov', and the `customer' database from
  14763. all three hosts.  He wants to use the password `stupid' from all three
  14764. hosts.
  14765.  
  14766. To set up this user's privileges using `GRANT' statements, run these
  14767. commands:
  14768.  
  14769.      shell> mysql --user=root mysql
  14770.      mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
  14771.                 ON bankaccount.*
  14772.                 TO custom@localhost
  14773.                 IDENTIFIED BY 'stupid';
  14774.      mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
  14775.                 ON expenses.*
  14776.                 TO custom@whitehouse.gov
  14777.                 IDENTIFIED BY 'stupid';
  14778.      mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
  14779.                 ON customer.*
  14780.                 TO custom@'%'
  14781.                 IDENTIFIED BY 'stupid';
  14782.  
  14783. The reason that we do to grant statements for the user 'custom' is that
  14784. we want the give the user access to MySQL both from the local machine
  14785. with Unix sockets and from the remote machine 'whitehouse.gov' over
  14786. TCP/IP.
  14787.  
  14788. To set up the user's privileges by modifying the grant tables directly,
  14789. run these commands (note the `FLUSH PRIVILEGES' at the end):
  14790.  
  14791.      shell> mysql --user=root mysql
  14792.      mysql> INSERT INTO user (Host,User,Password)
  14793.             VALUES('localhost','custom',PASSWORD('stupid'));
  14794.      mysql> INSERT INTO user (Host,User,Password)
  14795.             VALUES('server.domain','custom',PASSWORD('stupid'));
  14796.      mysql> INSERT INTO user (Host,User,Password)
  14797.             VALUES('whitehouse.gov','custom',PASSWORD('stupid'));
  14798.      mysql> INSERT INTO db
  14799.             (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,
  14800.              Create_priv,Drop_priv)
  14801.             VALUES
  14802.             ('localhost','bankaccount','custom','Y','Y','Y','Y','Y','Y');
  14803.      mysql> INSERT INTO db
  14804.             (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,
  14805.              Create_priv,Drop_priv)
  14806.             VALUES
  14807.             ('whitehouse.gov','expenses','custom','Y','Y','Y','Y','Y','Y');
  14808.      mysql> INSERT INTO db
  14809.             (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,
  14810.              Create_priv,Drop_priv)
  14811.             VALUES('%','customer','custom','Y','Y','Y','Y','Y','Y');
  14812.      mysql> FLUSH PRIVILEGES;
  14813.  
  14814. The first three `INSERT' statements add `user' table entries that allow
  14815. user `custom' to connect from the various hosts with the given
  14816. password, but grant no permissions to him (all privileges are set to the
  14817. default value of `'N'').  The next three `INSERT' statements add `db'
  14818. table entries that grant privileges to `custom' for the `bankaccount',
  14819. `expenses', and `customer' databases, but only when accessed from the
  14820. proper hosts.  As usual, when the grant tables are modified directly,
  14821. the server must be told to reload them (with `FLUSH PRIVILEGES') so
  14822. that the privilege changes take effect.
  14823.  
  14824. If you want to give a specific user access from any machine in a given
  14825. domain, you can issue a `GRANT' statement like the following:
  14826.  
  14827.      mysql> GRANT ...
  14828.                 ON *.*
  14829.                 TO myusername@"%.mydomainname.com"
  14830.                 IDENTIFIED BY 'mypassword';
  14831.  
  14832. To do the same thing by modifying the grant tables directly, do this:
  14833.  
  14834.      mysql> INSERT INTO user VALUES ('%.mydomainname.com', 'myusername',
  14835.                 PASSWORD('mypassword'),...);
  14836.      mysql> FLUSH PRIVILEGES;
  14837.  
  14838. You can also use `xmysqladmin', `mysql_webadmin', and even `xmysql' to
  14839. insert, change, and update values in the grant tables.  You can find
  14840. these utilities in the Contrib directory of the MySQL Website
  14841. (http://www.mysql.com/Downloads/Contrib/).
  14842.  
  14843. 
  14844. File: mysql.info,  Node: Passwords,  Next: Password security,  Prev: Adding users,  Up: User Account Management
  14845.  
  14846. Setting Up Passwords
  14847. --------------------
  14848.  
  14849. In most cases you should use `GRANT' to set up your users/passwords, so
  14850. the following only applies for advanced users. *Note `GRANT': GRANT.
  14851.  
  14852. The examples in the preceding sections illustrate an important
  14853. principle: when you store a non-empty password using `INSERT' or
  14854. `UPDATE' statements, you must use the `PASSWORD()' function to encrypt
  14855. it.  This is because the `user' table stores passwords in encrypted
  14856. form, not as plaintext.  If you forget that fact, you are likely to
  14857. attempt to set passwords like this:
  14858.  
  14859.      shell> mysql -u root mysql
  14860.      mysql> INSERT INTO user (Host,User,Password)
  14861.             VALUES('%','jeffrey','biscuit');
  14862.      mysql> FLUSH PRIVILEGES;
  14863.  
  14864. The result is that the plaintext value `'biscuit'' is stored as the
  14865. password in the `user' table.  When the user `jeffrey' attempts to
  14866. connect to the server using this password, the `mysql' client encrypts
  14867. it with `PASSWORD()', generates an authentification vector based on
  14868. *encrypted* password and a random number, obtained from server, and
  14869. sends the result to the server.  The server uses the `password' value
  14870. in the `user' table (that is *not encrypted* value `'biscuit'') to
  14871. perform the same calculations, and compares results.  The comparison
  14872. fails and the server rejects the connection:
  14873.  
  14874.      shell> mysql -u jeffrey -pbiscuit test
  14875.      Access denied
  14876.  
  14877. Passwords must be encrypted when they are inserted in the `user' table,
  14878. so the `INSERT' statement should have been specified like this instead:
  14879.  
  14880.      mysql> INSERT INTO user (Host,User,Password)
  14881.             VALUES('%','jeffrey',PASSWORD('biscuit'));
  14882.  
  14883. You must also use the `PASSWORD()' function when you use `SET PASSWORD'
  14884. statements:
  14885.  
  14886.      mysql> SET PASSWORD FOR jeffrey@"%" = PASSWORD('biscuit');
  14887.  
  14888. If you set passwords using the `GRANT ... IDENTIFIED BY' statement or
  14889. the `mysqladmin password' command, the `PASSWORD()' function is
  14890. unnecessary.  They both take care of encrypting the password for you,
  14891. so you would specify a password of `'biscuit'' like this:
  14892.  
  14893.      mysql> GRANT USAGE ON *.* TO jeffrey@"%" IDENTIFIED BY 'biscuit';
  14894.  
  14895. or
  14896.  
  14897.      shell> mysqladmin -u jeffrey password biscuit
  14898.  
  14899. *NOTE:* `PASSWORD()' does not perform password encryption in the same
  14900. way that Unix passwords are encrypted.  You should not assume that if
  14901. your Unix password and your MySQL password are the same, that
  14902. `PASSWORD()' will result in the same encrypted value as is stored in the
  14903. Unix password file. *Note User names::.
  14904.  
  14905. 
  14906. File: mysql.info,  Node: Password security,  Prev: Passwords,  Up: User Account Management
  14907.  
  14908. Keeping Your Password Secure
  14909. ----------------------------
  14910.  
  14911. It is inadvisable to specify your password in a way that exposes it to
  14912. discovery by other users.  The methods you can use to specify your
  14913. password when you run client programs are listed below, along with an
  14914. assessment of the risks of each method:
  14915.  
  14916.    * Never give a normal user access to the `mysql.user' table. Knowing
  14917.      the encrypted password for a user makes it possible to login as
  14918.      this user.  The passwords are only scrambled so that one shouldn't
  14919.      be able to see the real password you used (if you happen to use a
  14920.      similar password with your other applications).
  14921.  
  14922.    * Use a `-pyour_pass' or `--password=your_pass' option on the command
  14923.      line.  This is convenient but insecure, because your password
  14924.      becomes visible to system status programs (such as `ps') that may
  14925.      be invoked by other users to display command lines.  (MySQL
  14926.      clients typically overwrite the command-line argument with zeroes
  14927.      during their initialization sequence, but there is still a brief
  14928.      interval during which the value is visible.)
  14929.  
  14930.    * Use a `-p' or `--password' option (with no `your_pass' value
  14931.      specified).  In this case, the client program solicits the
  14932.      password from the terminal:
  14933.  
  14934.           shell> mysql -u user_name -p
  14935.           Enter password: ********
  14936.  
  14937.      The `*' characters represent your password.
  14938.  
  14939.      It is more secure to enter your password this way than to specify
  14940.      it on the command line because it is not visible to other users.
  14941.      However, this method of entering a password is suitable only for
  14942.      programs that you run interactively.  If you want to invoke a
  14943.      client from a script that runs non-interactively, there is no
  14944.      opportunity to enter the password from the terminal. On some
  14945.      systems, you may even find that the first line of your script is
  14946.      read and interpreted (incorrectly) as your password!
  14947.  
  14948.    * Store your password in a configuration file.  For example, you can
  14949.      list your password in the `[client]' section of the `.my.cnf' file
  14950.      in your home directory:
  14951.  
  14952.           [client]
  14953.           password=your_pass
  14954.  
  14955.      If you store your password in `.my.cnf', the file should not be
  14956.      group or world readable or writable.  Make sure the file's access
  14957.      mode is `400' or `600'.
  14958.  
  14959.      *Note Option files::.
  14960.  
  14961.    * You can store your password in the `MYSQL_PWD' environment
  14962.      variable, but this method must be considered extremely insecure
  14963.      and should not be used.  Some versions of `ps' include an option
  14964.      to display the environment of running processes; your password
  14965.      will be in plain sight for all to see if you set `MYSQL_PWD'.
  14966.      Even on systems without such a version of `ps', it is unwise to
  14967.      assume there is no other method to observe process environments.
  14968.      *Note Environment variables::.
  14969.  
  14970. All in all, the safest methods are to have the client program prompt
  14971. for the password or to specify the password in a properly protected
  14972. `.my.cnf' file.
  14973.  
  14974. 
  14975. File: mysql.info,  Node: Disaster Prevention,  Next: Database Administration,  Prev: User Account Management,  Up: MySQL Database Administration
  14976.  
  14977. Disaster Prevention and Recovery
  14978. ================================
  14979.  
  14980. * Menu:
  14981.  
  14982. * Backup::                      Database Backups
  14983. * BACKUP TABLE::                `BACKUP TABLE' Syntax
  14984. * RESTORE TABLE::               `RESTORE TABLE' Syntax
  14985. * CHECK TABLE::                 `CHECK TABLE' Syntax
  14986. * REPAIR TABLE::                `REPAIR TABLE' Syntax
  14987. * Table maintenance::           Using `myisamchk' for Table Maintenance and Crash Recovery
  14988. * Maintenance regimen::         Setting Up a Table Maintenance Regimen
  14989. * Table-info::                  Getting Information About a Table
  14990.  
  14991. 
  14992. File: mysql.info,  Node: Backup,  Next: BACKUP TABLE,  Prev: Disaster Prevention,  Up: Disaster Prevention
  14993.  
  14994. Database Backups
  14995. ----------------
  14996.  
  14997. Because MySQL tables are stored as files, it is easy to do a backup. To
  14998. get a consistent backup, do a `LOCK TABLES' on the relevant tables
  14999. followed by `FLUSH TABLES' for the tables.  *Note `LOCK TABLES': LOCK
  15000. TABLES.  *Note `FLUSH': FLUSH.  You only need a read lock; this allows
  15001. other threads to continue to query the tables while you are making a
  15002. copy of the files in the database directory.  The `FLUSH TABLE' is
  15003. needed to ensure that the all active index pages is written to disk
  15004. before you start the backup.
  15005.  
  15006. If you want to make a SQL level backup of a table, you can use `SELECT
  15007. INTO OUTFILE' or `BACKUP TABLE'. *Note SELECT::.  *Note BACKUP TABLE::.
  15008.  
  15009. Another way to back up a database is to use the `mysqldump' program or
  15010. the `mysqlhotcopy script'. *Note `mysqldump': mysqldump.  *Note
  15011. `mysqlhotcopy': mysqlhotcopy.
  15012.  
  15013.   1. Do a full backup of your databases:
  15014.  
  15015.           shell> mysqldump --tab=/path/to/some/dir --opt --full
  15016.           
  15017.           or
  15018.           
  15019.           shell> mysqlhotcopy database /path/to/some/dir
  15020.  
  15021.      You can also simply copy all table files (`*.frm', `*.MYD', and
  15022.      `*.MYI' files) as long as the server isn't updating anything.  The
  15023.      script `mysqlhotcopy' does use this method.
  15024.  
  15025.   2. Stop `mysqld' if it's running, then start it with the
  15026.      `--log-update[=file_name]' option.  *Note Update log::. The update
  15027.      log file(s) provide you with the information you need to replicate
  15028.      changes to the database that are made subsequent to the point at
  15029.      which you executed `mysqldump'.
  15030.  
  15031. If you have to restore something, try to recover your tables using
  15032. `REPAIR TABLE' or `myisamchk -r' first.  That should work in 99.9% of
  15033. all cases.  If `myisamchk' fails, try the following procedure: (This
  15034. will only work if you have started MySQL with `--log-update'. *Note
  15035. Update log::.):
  15036.  
  15037.   1. Restore the original `mysqldump' backup.
  15038.  
  15039.   2. Execute the following command to re-run the updates in the binary
  15040.      log:
  15041.  
  15042.           shell> mysqlbinlog hostname-bin.[0-9]* | mysql
  15043.  
  15044.      If you are using the update log you can use:
  15045.  
  15046.           shell> ls -1 -t -r hostname.[0-9]* | xargs cat | mysql
  15047.  
  15048. `ls' is used to get all the update log files in the right order.
  15049.  
  15050. You can also do selective backups with `SELECT * INTO OUTFILE
  15051. 'file_name' FROM tbl_name' and restore with `LOAD DATA INFILE
  15052. 'file_name' REPLACE ...' To avoid duplicate records, you need a
  15053. `PRIMARY KEY' or a `UNIQUE' key in the table. The `REPLACE' keyword
  15054. causes old records to be replaced with new ones when a new record
  15055. duplicates an old record on a unique key value.
  15056.  
  15057. If you get performance problems in making backups on your system, you
  15058. can solve this by setting up replication and do the backups on the slave
  15059. instead of on the master. *Note Replication Intro::.
  15060.  
  15061. If you are using a Veritas file system, you can do:
  15062.  
  15063.   1. Execute in a client (perl ?) `FLUSH TABLES WITH READ LOCK'
  15064.  
  15065.   2. Fork a shell or execute in another client `mount vxfs snapshot'.
  15066.  
  15067.   3. Execute in the first client `UNLOCK TABLES'
  15068.  
  15069.   4. Copy files from snapshot
  15070.  
  15071.   5. Unmount snapshot
  15072.  
  15073. 
  15074. File: mysql.info,  Node: BACKUP TABLE,  Next: RESTORE TABLE,  Prev: Backup,  Up: Disaster Prevention
  15075.  
  15076. `BACKUP TABLE' Syntax
  15077. ---------------------
  15078.  
  15079.      BACKUP TABLE tbl_name[,tbl_name...] TO '/path/to/backup/directory'
  15080.  
  15081. Make a copy of all the table files to the backup directory that are the
  15082. minimum needed to restore it. Currenlty only works for `MyISAM' tables.
  15083. For `MyISAM' table, copies `.frm' (definition)  and `.MYD' (data)
  15084. files. The index file can be rebuilt from those two.
  15085.  
  15086. Before using this command, please see *Note Backup::.
  15087.  
  15088. During the backup, read lock will be held for each table, one at time,
  15089. as they are being backed up. If you want to backup several tables as a
  15090. snapshot, you must first issue `LOCK TABLES' obtaining a read lock for
  15091. each table in the group.
  15092.  
  15093. The command returns a table with the following columns:
  15094.  
  15095. *Column*                  *Value*
  15096. Table                     Table name
  15097. Op                        Always "backup"
  15098. Msg_type                  One of `status', `error', `info' or `warning'.
  15099. Msg_text                  The message.
  15100.  
  15101. Note that `BACKUP TABLE' is only available in MySQL version 3.23.25 and
  15102. later.
  15103.  
  15104. 
  15105. File: mysql.info,  Node: RESTORE TABLE,  Next: CHECK TABLE,  Prev: BACKUP TABLE,  Up: Disaster Prevention
  15106.  
  15107. `RESTORE TABLE' Syntax
  15108. ----------------------
  15109.  
  15110.      RESTORE TABLE tbl_name[,tbl_name...] FROM '/path/to/backup/directory'
  15111.  
  15112. Restores the table(s) from the backup that was made with `BACKUP
  15113. TABLE'. Existing tables will not be overwritten - if you try to restore
  15114. over an existing table, you will get an error. Restore will take
  15115. longer than BACKUP due to the need to rebuilt the index. The more keys
  15116. you have, the longer it is going to take. Just as `BACKUP TABLE',
  15117. currently only works of `MyISAM' tables.
  15118.  
  15119. The command returns a table with the following columns:
  15120.  
  15121. *Column*                  *Value*
  15122. Table                     Table name
  15123. Op                        Always "restore"
  15124. Msg_type                  One of `status', `error', `info' or `warning'.
  15125. Msg_text                  The message.
  15126.  
  15127. 
  15128. File: mysql.info,  Node: CHECK TABLE,  Next: REPAIR TABLE,  Prev: RESTORE TABLE,  Up: Disaster Prevention
  15129.  
  15130. `CHECK TABLE' Syntax
  15131. --------------------
  15132.  
  15133.      CHECK TABLE tbl_name[,tbl_name...] [option [option...]]
  15134.      
  15135.      option = QUICK | FAST | MEDIUM | EXTENDED | CHANGED
  15136.  
  15137. `CHECK TABLE' only works on `MyISAM' tables. On `MyISAM' tables it's
  15138. the same thing as running `myisamchk -m table_name' on the table.
  15139.  
  15140. If you don't specify any option `MEDIUM' is used.
  15141.  
  15142. Checks the table(s) for errors. For `MyISAM' tables the key statistics
  15143. is updated. The command returns a table with the following columns:
  15144.  
  15145. *Column*                  *Value*
  15146. Table                     Table name.
  15147. Op                        Always "check".
  15148. Msg_type                  One of `status', `error', `info', or `warning'.
  15149. Msg_text                  The message.
  15150.  
  15151. Note that you can get many rows of information for each checked table.
  15152. The last row will be of `Msg_type status' and should normally be `OK'.
  15153. If you don't get `OK', or `Not checked' you should normally run a
  15154. repair of the table. *Note Table maintenance::. `Not checked' means
  15155. that the table the given `TYPE' told MySQL that there wasn't any need
  15156. to check the table.
  15157.  
  15158. The different check types stand for the following:
  15159.  
  15160. *Type*         *Meaning*
  15161. `QUICK'        Don't scan the rows to check for wrong links.
  15162. `FAST'         Only check tables which haven't been closed properly.
  15163. `CHANGED'      Only check tables which have been changed since last
  15164.                check or haven't been closed properly.
  15165. `MEDIUM'       Scan rows to verify that deleted links are ok. This also
  15166.                calculates a key checksum for the rows and verifies this
  15167.                with a calcualted checksum for the keys.
  15168. `EXTENDED'     Do a full key lookup for all keys for each row.  This
  15169.                ensures that the table is 100 % consistent, but will take
  15170.                a long time!
  15171.  
  15172. For dynamic sized `MyISAM' tables a started check will always do a
  15173. `MEDIUM' check. For static size rows we skip the row scan for `QUICK'
  15174. and `FAST' as the rows are very seldom corrupted.
  15175.  
  15176. You can combine check options as in:
  15177.  
  15178.      CHECK TABLE test_table FAST QUICK;
  15179.  
  15180. Which only would do a quick check on the table if it wasn't closed
  15181. properly.
  15182.  
  15183. *NOTE:* that in some case `CHECK TABLE' will change the table!  This
  15184. happens if the table is marked as 'corrupted' or 'not closed properly'
  15185. but `CHECK TABLE' didn't find any problems in the table.  In this case
  15186. `CHECK TABLE' will mark the table as ok.
  15187.  
  15188. If a table is corrupted, then it's most likely that the problem is in
  15189. the indexes and not in the data part.  All of the above check types
  15190. checks the indexes throughly and should thus find most errors.
  15191.  
  15192. If you just want to check a table that you assume is ok, you should use
  15193. no check options or the `QUICK' option. The later should be used when
  15194. you are in a hurry and can take the very small risk that `QUICK' didn't
  15195. find an error in the data file (In most cases MySQL should find, under
  15196. normal usage, any error in the data file. If this happens then the
  15197. table will be marked as 'corrupted', in which case the table can't be
  15198. used until it's repaired).
  15199.  
  15200. `FAST' and `CHANGED' are mostly intended to be used from a script (for
  15201. example to be executed from cron) if you want to check your table from
  15202. time to time. In most cases you `FAST' is to be prefered over
  15203. `CHANGED'.  (The only case when it isn't is when you suspect a bug you
  15204. have found a bug in the `MyISAM' code.).
  15205.  
  15206. `EXTENDED' is only to be used after you have run a normal check but
  15207. still get strange errors from a table when MySQL tries to update a row
  15208. or find a row by key (this is VERY unlikely to happen if a normal check
  15209. has succeeded!).
  15210.  
  15211. Some things reported by check table, can't be corrected automatically:
  15212.  
  15213.    * `Found row where the auto_increment column has the value 0'.
  15214.  
  15215.      This means that you have in the table a row where the
  15216.      `auto_increment' index column contains the value 0.  (It's
  15217.      possible to create a row where the auto_increment column is 0 by
  15218.      explicitely setting the column to 0 with an `UPDATE' statement)
  15219.  
  15220.      This isn't an error in itself, but could cause trouble if you
  15221.      decide to dump the table and restore it or do an `ALTER TABLE' on
  15222.      the table. In this case the auto_increment column will change
  15223.      value, according to the rules of auto_increment columns, which
  15224.      could cause problems like a duplicate key error.
  15225.  
  15226.      To get rid of the warning, just execute an `UPDATE' statement to
  15227.      set the column to some other value than 0.
  15228.  
  15229. 
  15230. File: mysql.info,  Node: REPAIR TABLE,  Next: Table maintenance,  Prev: CHECK TABLE,  Up: Disaster Prevention
  15231.  
  15232. `REPAIR TABLE' Syntax
  15233. ---------------------
  15234.  
  15235.      REPAIR TABLE tbl_name[,tbl_name...] [QUICK] [EXTENDED]
  15236.  
  15237. `REPAIR TABLE' only works on `MyISAM' tables and is the same as running
  15238. `myisamchk -r table_name' on the table.
  15239.  
  15240. Normally you should never have to run this command, but if disaster
  15241. strikes you are very likely to get back all your data from a MyISAM
  15242. table with `REPAIR TABLE'. If your tables get corrupted a lot you should
  15243. try to find the reason for this! *Note Crashing::. *Note MyISAM table
  15244. problems::.
  15245.  
  15246. `REPAIR TABLE' repairs a possible corrupted table. The command returns a
  15247. table with the following columns:
  15248.  
  15249. *Column*                  *Value*
  15250. Table                     Table name
  15251. Op                        Always "repair"
  15252. Msg_type                  One of `status', `error', `info' or `warning'.
  15253. Msg_text                  The message.
  15254.  
  15255. Note that you can get many rows of information for each repaired table.
  15256. The last one row will be of `Msg_type status' and should normally be
  15257. `OK'.  If you don't get `OK', you should try repairing the table with
  15258. `myisamchk -o', as `REPAIR TABLE' does not yet implement all the
  15259. options of `myisamchk'. In the near future, we will make it more
  15260. flexible.
  15261.  
  15262. If `QUICK' is given then MySQL will try to do a `REPAIR' of only the
  15263. index tree.
  15264.  
  15265. If you use `EXTENDED' then MySQL will create the index row by row
  15266. instead of creating one index at a time with sorting;  This may be
  15267. better than sorting on fixed-length keys if you have long `char()' keys
  15268. that compress very good.
  15269.  
  15270. 
  15271. File: mysql.info,  Node: Table maintenance,  Next: Maintenance regimen,  Prev: REPAIR TABLE,  Up: Disaster Prevention
  15272.  
  15273. Using `myisamchk' for Table Maintenance and Crash Recovery
  15274. ----------------------------------------------------------
  15275.  
  15276. Starting with MySQL Version 3.23.13, you can check MyISAM tables with
  15277. the `CHECK TABLE' command. *Note CHECK TABLE::.  You can repair tables
  15278. with the `REPAIR TABLE' command. *Note REPAIR TABLE::.
  15279.  
  15280. To check/repair MyISAM tables (`.MYI' and `.MYD') you should use the
  15281. `myisamchk' utility. To check/repair ISAM tables (`.ISM' and `.ISD')
  15282. you should use the `isamchk' utility. *Note Table types::.
  15283.  
  15284. In the following text we will talk about `myisamchk', but everything
  15285. also applies to the old `isamchk'.
  15286.  
  15287. You can use the `myisamchk' utility to get information about your
  15288. database tables, check and repair them, or optimize them.  The following
  15289. sections describe how to invoke `myisamchk' (including a description of
  15290. its options), how to set up a table maintenance schedule, and how to
  15291. use `myisamchk' to perform its various functions.
  15292.  
  15293. You can, in most cases, also use the command `OPTIMIZE TABLES' to
  15294. optimize and repair tables, but this is not as fast or reliable (in case
  15295. of real fatal errors) as `myisamchk'.  On the other hand, `OPTIMIZE
  15296. TABLE' is easier to use and you don't have to worry about flushing
  15297. tables.  *Note `OPTIMIZE TABLE': OPTIMIZE TABLE.
  15298.  
  15299. Even that the repair in `myisamchk' is quite secure, it's always a good
  15300. idea to make a backup BEFORE doing a repair (or anything that could
  15301. make a lot of changes to a table)
  15302.  
  15303. * Menu:
  15304.  
  15305. * myisamchk syntax::            `myisamchk' Invocation Syntax
  15306. * myisamchk general options::   General Options for `myisamchk'
  15307. * myisamchk check options::     Check Options for `myisamchk'
  15308. * myisamchk repair options::    Repair Options for myisamchk
  15309. * myisamchk other options::     Other Options for `myisamchk'
  15310. * myisamchk memory::            `myisamchk' Memory Usage
  15311. * Crash recovery::              Using `myisamchk' for Crash Recovery
  15312. * Check::                       How to Check Tables for Errors
  15313. * Repair::                      How to Repair Tables
  15314. * Optimization::                Table Optimization
  15315.  
  15316. 
  15317. File: mysql.info,  Node: myisamchk syntax,  Next: myisamchk general options,  Prev: Table maintenance,  Up: Table maintenance
  15318.  
  15319. `myisamchk' Invocation Syntax
  15320. .............................
  15321.  
  15322. `myisamchk' is invoked like this:
  15323.  
  15324.      shell> myisamchk [options] tbl_name
  15325.  
  15326. The `options' specify what you want `myisamchk' to do.  They are
  15327. described below.  (You can also get a list of options by invoking
  15328. `myisamchk --help'.)  With no options, `myisamchk' simply checks your
  15329. table.  To get more information or to tell `myisamchk' to take
  15330. corrective action, specify options as described below and in the
  15331. following sections.
  15332.  
  15333. `tbl_name' is the database table you want to check/repair.  If you run
  15334. `myisamchk' somewhere other than in the database directory, you must
  15335. specify the path to the file, because `myisamchk' has no idea where your
  15336. database is located.  Actually, `myisamchk' doesn't care whether or not
  15337. the files you are working on are located in a database directory; you
  15338. can copy the files that correspond to a database table into another
  15339. location and perform recovery operations on them there.
  15340.  
  15341. You can name several tables on the `myisamchk' command line if you
  15342. wish.  You can also specify a name as an index file name (with the
  15343. `.MYI' suffix), which allows you to specify all tables in a directory
  15344. by using the pattern `*.MYI'.  For example, if you are in a database
  15345. directory, you can check all the tables in the directory like this:
  15346.  
  15347.      shell> myisamchk *.MYI
  15348.  
  15349. If you are not in the database directory, you can check all the tables
  15350. there by specifying the path to the directory:
  15351.  
  15352.      shell> myisamchk /path/to/database_dir/*.MYI
  15353.  
  15354. You can even check all tables in all databases by specifying a wild card
  15355. with the path to the MySQL data directory:
  15356.  
  15357.      shell> myisamchk /path/to/datadir/*/*.MYI
  15358.  
  15359. The recommended way to quickly check all tables is:
  15360.  
  15361.      myisamchk --silent --fast /path/to/datadir/*/*.MYI
  15362.      isamchk --silent /path/to/datadir/*/*.ISM
  15363.  
  15364. If you want to check all tables and repair all tables that are
  15365. corrupted, you can use the following line:
  15366.  
  15367.      myisamchk --silent --force --fast --update-state -O key_buffer=64M -O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M /path/to/datadir/*/*.MYI
  15368.      isamchk --silent --force -O key_buffer=64M -O sort_buffer=64M -O read_buffer=1M -O write_buffer=1M /path/to/datadir/*/*.ISM
  15369.  
  15370. The above assumes that you have more than 64 M free.
  15371.  
  15372. Note that if you get an error like:
  15373.  
  15374.      myisamchk: warning: 1 clients is using or hasn't closed the table properly
  15375.  
  15376. This means that you are trying to check a table that has been updated by
  15377. the another program (like the `mysqld' server) that hasn't yet closed
  15378. the file or that has died without closing the file properly.
  15379.  
  15380. If you `mysqld' is running, you must force a sync/close of all tables
  15381. with `FLUSH TABLES' and ensure that no one is using the tables while
  15382. you are running `myisamchk'.  In MySQL Version 3.23 the easiest way to
  15383. avoid this problem is to use `CHECK TABLE' instead of `myisamchk' to
  15384. check tables.
  15385.  
  15386. * Menu:
  15387.  
  15388. * myisamchk general options::   General Options for `myisamchk'
  15389. * myisamchk check options::     Check Options for `myisamchk'
  15390. * myisamchk repair options::    Repair Options for myisamchk
  15391. * myisamchk other options::     Other Options for `myisamchk'
  15392.  
  15393. 
  15394. File: mysql.info,  Node: myisamchk general options,  Next: myisamchk check options,  Prev: myisamchk syntax,  Up: Table maintenance
  15395.  
  15396. General Options for `myisamchk'
  15397. ...............................
  15398.  
  15399. `myisamchk' supports the following options.
  15400.  
  15401. `-# or --debug=debug_options'
  15402.      Output debug log. The `debug_options' string often is
  15403.      `'d:t:o,filename''.
  15404.  
  15405. `-? or --help'
  15406.      Display a help message and exit.
  15407.  
  15408. `-O var=option, --set-variable var=option'
  15409.      Set the value of a variable.  The possible variables and their
  15410.      default values for myisamchk can be examined with `myisamchk
  15411.      --help':
  15412.      key_buffer_size      523264
  15413.      read_buffer_size     262136
  15414.      write_buffer_size    262136
  15415.      sort_buffer_size     2097144
  15416.      sort_key_blocks      16
  15417.      decode_bits          9
  15418.  
  15419.      `sort_buffer_size' is used when the keys are repaired by sorting
  15420.      keys, which is the normal case when you use `--recover'.
  15421.  
  15422.      `key_buffer_size' is used when you are checking the table with
  15423.      `--extended-check' or when the keys are repaired by inserting key
  15424.      row by row in to the table (like when doing normal inserts).
  15425.      Repairing through the key buffer is used in the following cases:
  15426.  
  15427.         * If you use `--safe-recover'.
  15428.  
  15429.         * If you are using a `FULLTEXT' index.
  15430.  
  15431.         * If the temporary files needed to sort the keys would be more
  15432.           than twice as big as when creating the key file directly.
  15433.           This is often the case when you have big `CHAR', `VARCHAR' or
  15434.           `TEXT' keys as the sort needs to store the whole keys during
  15435.           sorting. If you have lots of temporary space and you can
  15436.           force `myisamchk' to repair by sorting you can use the
  15437.           `--sort-recover' option.
  15438.  
  15439.      Reparing through the key buffer takes much less disk space than
  15440.      using sorting, but is also much slower.
  15441.  
  15442.      If you want a faster repair, set the above variables to about 1/4
  15443.      of your available memory.  You can set both variables to big
  15444.      values, as only one of the above buffers will be used at a time.
  15445.  
  15446. `-s or --silent'
  15447.      Silent mode.  Write output only when errors occur. You can use `-s'
  15448.      twice (`-ss') to make `myisamchk' very silent.
  15449.  
  15450. `-v or --verbose'
  15451.      Verbose mode.  Print more information. This can be used with `-d'
  15452.      and `-e'. Use `-v' multiple times (`-vv', `-vvv') for more
  15453.      verbosity!
  15454.  
  15455. `-V or --version'
  15456.      Print the `myisamchk' version and exit.
  15457.  
  15458. `-w or, --wait'
  15459.      Instead of giving an error if the table is locked, wait until the
  15460.      table is unlocked before continuing.  Note that if you are running
  15461.      `mysqld' on the table with `--skip-locking', the table can only be
  15462.      locked by another `myisamchk' command.
  15463.  
  15464. 
  15465. File: mysql.info,  Node: myisamchk check options,  Next: myisamchk repair options,  Prev: myisamchk general options,  Up: Table maintenance
  15466.  
  15467. Check Options for `myisamchk'
  15468. .............................
  15469.  
  15470. `-c or --check'
  15471.      Check table for errors. This is the default operation if you are
  15472.      not giving `myisamchk' any options that override this.
  15473.  
  15474. `-e or --extend-check'
  15475.      Check the table VERY thoroughly (which is quite slow if you have
  15476.      many indexes).  This option should only be used in extreme cases.
  15477.      Normally, `myisamchk' or `myisamchk --medium-check' should, in most
  15478.      cases, be able to find out if there are any errors in the table.
  15479.  
  15480.      If you are using `--extended-check' and have much memory, you
  15481.      should increase the value of `key_buffer_size' a lot!
  15482.  
  15483. `-F or --fast'
  15484.      Check only tables that haven't been closed properly.
  15485.  
  15486. `-C or --check-only-changed'
  15487.      Check only tables that have changed since the last check.
  15488.  
  15489. `-f or --force'
  15490.      Restart `myisamchk' with `-r' (repair) on the table, if
  15491.      `myisamchk' finds any errors in the table.
  15492.  
  15493. `-i or --information'
  15494.      Print informational statistics about the table that is checked.
  15495.  
  15496. `-m or --medium-check'
  15497.      Faster than extended-check, but only finds 99.99% of all errors.
  15498.      Should, however, be good enough for most cases.
  15499.  
  15500. `-U or --update-state'
  15501.      Store in the `.MYI' file when the table was checked and if the
  15502.      table crashed.  This should be used to get full benefit of the
  15503.      `--check-only-changed' option, but you shouldn't use this option
  15504.      if the `mysqld' server is using the table and you are running
  15505.      `mysqld' with `--skip-locking'.
  15506.  
  15507. `-T or --read-only'
  15508.      Don't mark table as checked. This is useful if you use `myisamchk'
  15509.      to check a table that is in use by some other application that
  15510.      doesn't use locking (like `mysqld --skip-locking').
  15511.  
  15512. 
  15513. File: mysql.info,  Node: myisamchk repair options,  Next: myisamchk other options,  Prev: myisamchk check options,  Up: Table maintenance
  15514.  
  15515. Repair Options for myisamchk
  15516. ............................
  15517.  
  15518. The following options are used if you start `myisamchk' with `-r' or
  15519. `-o':
  15520.  
  15521. `-D # or --data-file-length=#'
  15522.      Max length of data file (when re-creating data file when it's
  15523.      'full').
  15524.  
  15525. `-e or --extend-check'
  15526.      Try to recover every possible row from the data file.  Normally
  15527.      this will also find a lot of garbage rows. Don't use this option
  15528.      if you are not totally desperate.
  15529.  
  15530. `-f or --force'
  15531.      Overwrite old temporary files (`table_name.TMD') instead of
  15532.      aborting.
  15533.  
  15534. `-k # or keys-used=#'
  15535.      If you are using ISAM, tells the ISAM table handler to update only
  15536.      the first `#' indexes.  If you are using `MyISAM', tells which keys
  15537.      to use, where each binary bit stands for one key (first key is bit
  15538.      0).  This can be used to get faster inserts!  Deactivated indexes
  15539.      can be reactivated by using `myisamchk -r'.  keys.
  15540.  
  15541. `-l or --no-symlinks'
  15542.      Do not follow symbolic links. Normally `myisamchk' repairs the
  15543.      table a symlink points at.  This option doesn't exist in MySQL 4.0,
  15544.      as MySQL 4.0 will not remove symlinks during repair.
  15545.  
  15546. `-r or --recover'
  15547.      Can fix almost anything except unique keys that aren't unique
  15548.      (which is an extremely unlikely error with ISAM/MyISAM tables).
  15549.      If you want to recover a table, this is the option to try first.
  15550.      Only if myisamchk reports that the table can't be recovered by
  15551.      `-r', you should then try `-o'.  (Note that in the unlikely case
  15552.      that `-r' fails, the data file is still intact.)  If you have lots
  15553.      of memory, you should increase the size of `sort_buffer_size'!
  15554.  
  15555. `-o or --safe-recover'
  15556.      Uses an old recovery method (reads through all rows in order and
  15557.      updates all index trees based on the found rows); this is a
  15558.      magnitude slower than `-r', but can handle a couple of very
  15559.      unlikely cases that `-r' cannot handle.  This recovery method also
  15560.      uses much less disk space than `-r'. Normally one should always
  15561.      first repair with `-r', and only if this fails use `-o'.
  15562.  
  15563.      If you have lots of memory, you should increase the size of
  15564.      `key_buffer_size'!
  15565.  
  15566. `-n or --sort-recover'
  15567.      Force `myisamchk' to use sorting to resolve the keys even if the
  15568.      temporary files should be very big.  This will not have any effect
  15569.      if you have fulltext keys in the table.
  15570.  
  15571. `--character-sets-dir=...'
  15572.      Directory where character sets are stored.
  15573.  
  15574. `--set-character-set=name'
  15575.      Change the character set used by the index
  15576.  
  15577. `.t or --tmpdir=path'
  15578.      Path for storing temporary files. If this is not set, `myisamchk'
  15579.      will use the environment variable `TMPDIR' for this.
  15580.  
  15581. `-q or --quick'
  15582.      Faster repair by not modifying the data file. One can give a second
  15583.      `-q' to force `myisamchk' to modify the original datafile in case
  15584.      of duplicate keys
  15585.  
  15586. `-u or --unpack'
  15587.      Unpack file packed with myisampack.
  15588.  
  15589. 
  15590. File: mysql.info,  Node: myisamchk other options,  Next: myisamchk memory,  Prev: myisamchk repair options,  Up: Table maintenance
  15591.  
  15592. Other Options for `myisamchk'
  15593. .............................
  15594.  
  15595. Other actions that `myisamchk' can do, besides repair and check tables:
  15596.  
  15597. `-a or --analyze'
  15598.      Analyze the distribution of keys. This improves join performance by
  15599.      enabling the join optimizer to better choose in which order it
  15600.      should join the tables and which keys it should use: `myisamchk
  15601.      --describe --verbose table_name'' or using `SHOW KEYS' in MySQL.
  15602.  
  15603. `-d or --description'
  15604.      Prints some information about table.
  15605.  
  15606. `-A or --set-auto-increment[=value]'
  15607.      Force auto_increment to start at this or higher value. If no value
  15608.      is given, then sets the next auto_increment value to the highest
  15609.      used value for the auto key + 1.
  15610.  
  15611. `-S or --sort-index'
  15612.      Sort the index tree blocks in high-low order.  This will optimize
  15613.      seeks and will make table scanning by key faster.
  15614.  
  15615. `-R or --sort-records=#'
  15616.      Sorts records according to an index.  This makes your data much
  15617.      more localized and may speed up ranged `SELECT' and `ORDER BY'
  15618.      operations on this index. (It may be VERY slow to do a sort the
  15619.      first time!)  To find out a table's index numbers, use `SHOW
  15620.      INDEX', which shows a table's indexes in the same order that
  15621.      `myisamchk' sees them.  Indexes are numbered beginning with 1.
  15622.  
  15623. 
  15624. File: mysql.info,  Node: myisamchk memory,  Next: Crash recovery,  Prev: myisamchk other options,  Up: Table maintenance
  15625.  
  15626. `myisamchk' Memory Usage
  15627. ........................
  15628.  
  15629. Memory allocation is important when you run `myisamchk'.  `myisamchk'
  15630. uses no more memory than you specify with the `-O' options.  If you are
  15631. going to use `myisamchk' on very large files, you should first decide
  15632. how much memory you want it to use.  The default is to use only about
  15633. 3M to fix things.  By using larger values, you can get `myisamchk' to
  15634. operate faster.  For example, if you have more than 32M RAM, you could
  15635. use options such as these (in addition to any other options you might
  15636. specify):
  15637.  
  15638.      shell> myisamchk -O sort=16M -O key=16M -O read=1M -O write=1M ...
  15639.  
  15640. Using `-O sort=16M' should probably be enough for most cases.
  15641.  
  15642. Be aware that `myisamchk' uses temporary files in `TMPDIR'. If `TMPDIR'
  15643. points to a memory file system, you may easily get out of memory
  15644. errors. If this happens, set `TMPDIR' to point at some directory with
  15645. more space and restart `myisamchk'.
  15646.  
  15647. When repairing, `myisamchk' will also need a lot of disk space:
  15648.  
  15649.    * Double the size of the record file (the original one and a copy).
  15650.      This space is not needed if one does a repair with `--quick', as
  15651.      in this case only the index file will be re-created.  This space
  15652.      is needed on the same disk as the original record file!
  15653.  
  15654.    * Space for the new index file that replaces the old one. The old
  15655.      index file is truncated at start, so one usually ignore this space.
  15656.      This space is needed on the same disk as the original index file!
  15657.  
  15658.    * When using `--recover' or `--sort-recover' (but not when using
  15659.      `--safe-recover', you will need space for a sort buffer for:
  15660.      `(largest_key + row_pointer_length)*number_of_rows * 2'.  You can
  15661.      check the length of the keys and the row_pointer_length with
  15662.      `myisamchk -dv table'.  This space is allocated on the temporary
  15663.      disk (specified by `TMPDIR' or `--tmpdir=#').
  15664.  
  15665. If you have a problem with disk space during repair, you can try to use
  15666. `--safe-recover' instead of `--recover'.
  15667.  
  15668. 
  15669. File: mysql.info,  Node: Crash recovery,  Next: Check,  Prev: myisamchk memory,  Up: Table maintenance
  15670.  
  15671. Using `myisamchk' for Crash Recovery
  15672. ....................................
  15673.  
  15674. If you run `mysqld' with `--skip-locking' (which is the default on some
  15675. systems, like Linux), you can't reliably use `myisamchk' to check a
  15676. table when `mysqld' is using the same table.  If you can be sure that
  15677. no one is accessing the tables through `mysqld' while you run
  15678. `myisamchk', you only have to do `mysqladmin flush-tables' before you
  15679. start checking the tables.  If you can't guarantee the above, then you
  15680. must take down `mysqld' while you check the tables.  If you run
  15681. `myisamchk' while `mysqld' is updating the tables, you may get a
  15682. warning that a table is corrupt even if it isn't.
  15683.  
  15684. If you are not using `--skip-locking', you can use `myisamchk' to check
  15685. tables at any time.  While you do this, all clients that try to update
  15686. the table will wait until `myisamchk' is ready before continuing.
  15687.  
  15688. If you use `myisamchk' to repair or optimize tables, you *MUST* always
  15689. ensure that the `mysqld' server is not using the table (this also
  15690. applies if you are using `--skip-locking').  If you don't take down
  15691. `mysqld' you should at least do a `mysqladmin flush-tables' before you
  15692. run `myisamchk'.
  15693.  
  15694. This chapter describes how to check for and deal with data corruption
  15695. in MySQL databases.  If your tables get corrupted a lot you should try
  15696. to find the reason for this! *Note Crashing::.
  15697.  
  15698. The `MyISAM' table section contains reason for why a table could be
  15699. corrupted. *Note MyISAM table problems::.
  15700.  
  15701. When performing crash recovery, it is important to understand that each
  15702. table `tbl_name' in a database corresponds to three files in the
  15703. database directory:
  15704.  
  15705. *File*         *Purpose*
  15706. `tbl_name.frm' Table definition (form) file
  15707. `tbl_name.MYD' Data file
  15708. `tbl_name.MYI' Index file
  15709.  
  15710. Each of these three file types is subject to corruption in various
  15711. ways, but problems occur most often in data files and index files.
  15712.  
  15713. `myisamchk' works by creating a copy of the `.MYD' (data) file row by
  15714. row. It ends the repair stage by removing the old `.MYD' file and
  15715. renaming the new file to the original file name.  If you use `--quick',
  15716. `myisamchk' does not create a temporary `.MYD' file, but instead
  15717. assumes that the `.MYD' file is correct and only generates a new index
  15718. file without touching the `.MYD' file. This is safe, because
  15719. `myisamchk' automatically detects if the `.MYD' file is corrupt and
  15720. aborts the repair in this case.  You can also give two `--quick'
  15721. options to `myisamchk'.  In this case, `myisamchk' does not abort on
  15722. some errors (like duplicate key) but instead tries to resolve them by
  15723. modifying the `.MYD' file. Normally the use of two `--quick' options is
  15724. useful only if you have too little free disk space to perform a normal
  15725. repair.  In this case you should at least make a backup before running
  15726. `myisamchk'.
  15727.  
  15728. 
  15729. File: mysql.info,  Node: Check,  Next: Repair,  Prev: Crash recovery,  Up: Table maintenance
  15730.  
  15731. How to Check Tables for Errors
  15732. ..............................
  15733.  
  15734. To check a MyISAM table, use the following commands:
  15735.  
  15736. `myisamchk tbl_name'
  15737.      This finds 99.99% of all errors. What it can't find is corruption
  15738.      that involves *ONLY* the data file (which is very unusual). If you
  15739.      want to check a table, you should normally run `myisamchk' without
  15740.      options or with either the `-s' or `--silent' option.
  15741.  
  15742. `myisamchk -m tbl_name'
  15743.      This finds 99.999% of all errors. It checks first all index
  15744.      entries for errors and then it reads through all rows. It
  15745.      calculates a checksum for all keys in the rows and verifies that
  15746.      they checksum matches the checksum for the keys in the index tree.
  15747.  
  15748. `myisamchk -e tbl_name'
  15749.      This does a complete and thorough check of all data (`-e' means
  15750.      "extended check"). It does a check-read of every key for each row
  15751.      to verify that they indeed point to the correct row.  This may
  15752.      take a LONG time on a big table with many keys.  `myisamchk' will
  15753.      normally stop after the first error it finds. If you want to
  15754.      obtain more information, you can add the `--verbose' (`-v')
  15755.      option.  This causes `myisamchk' to keep going, up through a
  15756.      maximum of 20 errors.  In normal usage, a simple `myisamchk' (with
  15757.      no arguments other than the table name) is sufficient.
  15758.  
  15759. `myisamchk -e -i tbl_name'
  15760.      Like the previous command, but the `-i' option tells `myisamchk' to
  15761.      print some informational statistics, too.
  15762.  
  15763. 
  15764. File: mysql.info,  Node: Repair,  Next: Optimization,  Prev: Check,  Up: Table maintenance
  15765.  
  15766. How to Repair Tables
  15767. ....................
  15768.  
  15769. In the following section we only talk about using `myisamchk' on
  15770. `MyISAM' tables (extensions `.MYI' and `.MYD').  If you are using
  15771. `ISAM' tables (extensions `.ISM' and `.ISD'), you should use `isamchk'
  15772. instead.
  15773.  
  15774. Starting with MySQL Version 3.23.14, you can repair MyISAM tables with
  15775. the `REPAIR TABLE' command. *Note REPAIR TABLE::.
  15776.  
  15777. The symptoms of a corrupted table include queries that abort
  15778. unexpectedly and observable errors such as these:
  15779.  
  15780.    * `tbl_name.frm' is locked against change
  15781.  
  15782.    * Can't find file `tbl_name.MYI' (Errcode: ###)
  15783.  
  15784.    * Unexpected end of file
  15785.  
  15786.    * Record file is crashed
  15787.  
  15788.    * Got error ### from table handler
  15789.  
  15790.      To get more information about the error you can run `perror ###'.
  15791.      Here is the most common errors that indicates a problem with the
  15792.      table:
  15793.  
  15794.           shell> perror 126 127 132 134 135 136 141 144 145
  15795.           126 = Index file is crashed / Wrong file format
  15796.           127 = Record-file is crashed
  15797.           132 = Old database file
  15798.           134 = Record was already deleted (or record file crashed)
  15799.           135 = No more room in record file
  15800.           136 = No more room in index file
  15801.           141 = Duplicate unique key or constraint on write or update
  15802.           144 = Table is crashed and last repair failed
  15803.           145 = Table was marked as crashed and should be repaired
  15804.  
  15805.      Note that error 135, no more room in record file, is not an error
  15806.      that can be fixed by a simple repair. In this case you have to do:
  15807.  
  15808.           ALTER TABLE table MAX_ROWS=xxx AVG_ROW_LENGTH=yyy;
  15809.  
  15810.  
  15811. In the other cases, you must repair your tables. `myisamchk' can
  15812. usually detect and fix most things that go wrong.
  15813.  
  15814. The repair process involves up to four stages, described below. Before
  15815. you begin, you should `cd' to the database directory and check the
  15816. permissions of the table files. Make sure they are readable by the Unix
  15817. user that `mysqld' runs as (and to you, because you need to access the
  15818. files you are checking).  If it turns out you need to modify files,
  15819. they must also be writable by you.
  15820.  
  15821. If you are using MySQL Version 3.23.16 and above, you can (and should)
  15822. use the `CHECK' and `REPAIR' commands to check and repair `MyISAM'
  15823. tables.  *Note CHECK TABLE::.  *Note REPAIR TABLE::.
  15824.  
  15825. The manual section about table maintenance includes the options to
  15826. `isamchk'/`myisamchk'.  *Note Table maintenance::.
  15827.  
  15828. The following section is for the cases where the above command fails or
  15829. if you want to use the extended features that `isamchk'/`myisamchk'
  15830. provides.
  15831.  
  15832. If you are going to repair a table from the command line, you must first
  15833. take down the `mysqld' server. Note that when you do `mysqladmin
  15834. shutdown' on a remote server, the `mysqld' server will still be alive
  15835. for a while after `mysqladmin' returns, until all queries are stopped
  15836. and all keys have been flushed to disk.
  15837.  
  15838. *Stage 1: Checking your tables*
  15839.  
  15840. Run `myisamchk *.MYI' or `myisamchk -e *.MYI' if you have more time.
  15841. Use the `-s' (silent) option to suppress unnecessary information.
  15842.  
  15843. If the `mysqld' server is done you should use the -update option to tell
  15844. `myisamchk' to mark the table as 'checked'.
  15845.  
  15846. You have to repair only those tables for which `myisamchk' announces an
  15847. error.  For such tables, proceed to Stage 2.
  15848.  
  15849. If you get weird errors when checking (such as `out of memory' errors),
  15850. or if `myisamchk' crashes, go to Stage 3.
  15851.  
  15852. *Stage 2: Easy safe repair*
  15853.  
  15854. NOTE: If you want repairing to go much faster, you should add: `-O
  15855. sort_buffer=# -O key_buffer=#' (where # is about 1/4 of the available
  15856. memory) to all `isamchk/myisamchk' commands.
  15857.  
  15858. First, try `myisamchk -r -q tbl_name' (`-r -q' means "quick recovery
  15859. mode"). This will attempt to repair the index file without touching the
  15860. data file.  If the data file contains everything that it should and the
  15861. delete links point at the correct locations within the data file, this
  15862. should work, and the table is fixed. Start repairing the next table.
  15863. Otherwise, use the following procedure:
  15864.  
  15865.   1. Make a backup of the data file before continuing.
  15866.  
  15867.   2. Use `myisamchk -r tbl_name' (`-r' means "recovery mode"). This will
  15868.      remove incorrect records and deleted records from the data file and
  15869.      reconstruct the index file.
  15870.  
  15871.   3. If the preceding step fails, use `myisamchk --safe-recover
  15872.      tbl_name'.  Safe recovery mode uses an old recovery method that
  15873.      handles a few cases that regular recovery mode doesn't (but is
  15874.      slower).
  15875.  
  15876. If you get weird errors when repairing (such as `out of memory'
  15877. errors), or if `myisamchk' crashes, go to Stage 3.
  15878.  
  15879. *Stage 3: Difficult repair*
  15880.  
  15881. You should only reach this stage if the first 16K block in the index
  15882. file is destroyed or contains incorrect information, or if the index
  15883. file is missing.  In this case, it's necessary to create a new index
  15884. file. Do so as follows:
  15885.  
  15886.   1. Move the data file to some safe place.
  15887.  
  15888.   2. Use the table description file to create new (empty) data and
  15889.      index files:
  15890.  
  15891.           shell> mysql db_name
  15892.           mysql> SET AUTOCOMMIT=1;
  15893.           mysql> TRUNCATE TABLE table_name;
  15894.           mysql> quit
  15895.  
  15896.      If your SQL version doesn't have `TRUNCATE TABLE', use `DELETE FROM
  15897.      table_name' instead.
  15898.  
  15899.   3. Copy the old data file back onto the newly created data file.
  15900.      (Don't just move the old file back onto the new file; you want to
  15901.      retain a copy in case something goes wrong.)
  15902.  
  15903. Go back to Stage 2.  `myisamchk -r -q' should work now.  (This shouldn't
  15904. be an endless loop.)
  15905.  
  15906. *Stage 4: Very difficult repair*
  15907.  
  15908. You should reach this stage only if the description file has also
  15909. crashed. That should never happen, because the description file isn't
  15910. changed after the table is created:
  15911.  
  15912.   1. Restore the description file from a backup and go back to Stage 3.
  15913.      You can also restore the index file and go back to Stage 2.  In
  15914.      the latter case, you should start with `myisamchk -r'.
  15915.  
  15916.   2. If you don't have a backup but know exactly how the table was
  15917.      created, create a copy of the table in another database.  Remove
  15918.      the new data file, then move the description and index files from
  15919.      the other database to your crashed database.  This gives you new
  15920.      description and index files, but leaves the data file alone.  Go
  15921.      back to Stage 2 and attempt to reconstruct the index file.
  15922.  
  15923. 
  15924. File: mysql.info,  Node: Optimization,  Prev: Repair,  Up: Table maintenance
  15925.  
  15926. Table Optimization
  15927. ..................
  15928.  
  15929. To coalesce fragmented records and eliminate wasted space resulting from
  15930. deleting or updating records, run `myisamchk' in recovery mode:
  15931.  
  15932.      shell> myisamchk -r tbl_name
  15933.  
  15934. You can optimize a table in the same way using the SQL `OPTIMIZE TABLE'
  15935. statement.  `OPTIMIZE TABLE' does a repair of the table, a key analyzes
  15936. and also sorts the index tree to give faster key lookups.  There is
  15937. also no possibility of unwanted interaction between a utility and the
  15938. server, because the server does all the work when you use `OPTIMIZE
  15939. TABLE'. *Note OPTIMIZE TABLE::.
  15940.  
  15941. `myisamchk' also has a number of other options you can use to improve
  15942. the performance of a table:
  15943.  
  15944. `-S, --sort-index'
  15945.  
  15946. `-R index_num, --sort-records=index_num'
  15947.  
  15948. `-a, --analyze'
  15949. For a full description of the option. *Note myisamchk syntax::.
  15950.  
  15951. 
  15952. File: mysql.info,  Node: Maintenance regimen,  Next: Table-info,  Prev: Table maintenance,  Up: Disaster Prevention
  15953.  
  15954. Setting Up a Table Maintenance Regimen
  15955. --------------------------------------
  15956.  
  15957. Starting with MySQL Version 3.23.13, you can check MyISAM tables with
  15958. the `CHECK TABLE' command. *Note CHECK TABLE::.  You can repair tables
  15959. with the `REPAIR TABLE' command. *Note REPAIR TABLE::.
  15960.  
  15961. It is a good idea to perform table checks on a regular basis rather than
  15962. waiting for problems to occur.  For maintenance purposes, you can use
  15963. `myisamchk -s' to check tables.  The `-s' option (short for `--silent')
  15964. causes `myisamchk' to run in silent mode, printing messages only when
  15965. errors occur.
  15966.  
  15967. It's also a good idea to check tables when the server starts up.  For
  15968. example, whenever the machine has done a reboot in the middle of an
  15969. update, you usually need to check all the tables that could have been
  15970. affected. (This is an "expected crashed table".) You could add a test to
  15971. `safe_mysqld' that runs `myisamchk' to check all tables that have been
  15972. modified during the last 24 hours if there is an old `.pid' (process
  15973. ID) file left after a reboot.  (The `.pid' file is created by `mysqld'
  15974. when it starts up and removed when it terminates normally.  The
  15975. presence of a `.pid' file at system startup time indicates that
  15976. `mysqld' terminated abnormally.)
  15977.  
  15978. An even better test would be to check any table whose last-modified time
  15979. is more recent than that of the `.pid' file.
  15980.  
  15981. You should also check your tables regularly during normal system
  15982. operation.  At MySQL AB, we run a `cron' job to check all our important
  15983. tables once a week, using a line like this in a `crontab' file:
  15984.  
  15985.      35 0 * * 0 /path/to/myisamchk --fast --silent /path/to/datadir/*/*.MYI
  15986.  
  15987. This prints out information about crashed tables so we can examine and
  15988. repair them when needed.
  15989.  
  15990. As we haven't had any unexpectedly crashed tables (tables that become
  15991. corrupted for reasons other than hardware trouble) for a couple of
  15992. years now (this is really true), once a week is more than enough for us.
  15993.  
  15994. We recommend that to start with, you execute `myisamchk -s' each night
  15995. on all tables that have been updated during the last 24 hours, until
  15996. you come to trust MySQL as much as we do.
  15997.  
  15998. Normally you don't need to maintain MySQL tables that much.  If you are
  15999. changing tables with dynamic size rows (tables with `VARCHAR', `BLOB'
  16000. or `TEXT' columns) or have tables with many deleted rows you may want
  16001. to from time to time (once a month?) defragment/reclaim space from the
  16002. tables.
  16003.  
  16004. You can do this by using `OPTIMIZE TABLE' on the tables in question or
  16005. if you can take the `mysqld' server down for a while do:
  16006.  
  16007.      isamchk -r --silent --sort-index -O sort_buffer_size=16M */*.ISM
  16008.      myisamchk -r --silent --sort-index  -O sort_buffer_size=16M */*.MYI
  16009.  
  16010. 
  16011. File: mysql.info,  Node: Table-info,  Prev: Maintenance regimen,  Up: Disaster Prevention
  16012.  
  16013. Getting Information About a Table
  16014. ---------------------------------
  16015.  
  16016. To get a description of a table or statistics about it, use the
  16017. commands shown below. We explain some of the information in more detail
  16018. later:
  16019.  
  16020. `myisamchk -d tbl_name'
  16021.      Runs `myisamchk' in "describe mode" to produce a description of
  16022.      your table. If you start the MySQL server using the
  16023.      `--skip-locking' option, `myisamchk' may report an error for a
  16024.      table that is updated while it runs.  However, because `myisamchk'
  16025.      doesn't change the table in describe mode, there isn't any risk of
  16026.      destroying data.
  16027.  
  16028. `myisamchk -d -v tbl_name'
  16029.      To produce more information about what `myisamchk' is doing, add
  16030.      `-v' to tell it to run in verbose mode.
  16031.  
  16032. `myisamchk -eis tbl_name'
  16033.      Shows only the most important information from a table. It is slow
  16034.      because it must read the whole table.
  16035.  
  16036. `myisamchk -eiv tbl_name'
  16037.      This is like `-eis', but tells you what is being done.
  16038.  
  16039. Example of `myisamchk -d' output:
  16040.      MyISAM file:     company.MYI
  16041.      Record format:   Fixed length
  16042.      Data records:    1403698  Deleted blocks:         0
  16043.      Recordlength:    226
  16044.      
  16045.      table description:
  16046.      Key Start Len Index   Type
  16047.      1   2     8   unique  double
  16048.      2   15    10  multip. text packed stripped
  16049.      3   219   8   multip. double
  16050.      4   63    10  multip. text packed stripped
  16051.      5   167   2   multip. unsigned short
  16052.      6   177   4   multip. unsigned long
  16053.      7   155   4   multip. text
  16054.      8   138   4   multip. unsigned long
  16055.      9   177   4   multip. unsigned long
  16056.          193   1           text
  16057.  
  16058. Example of `myisamchk -d -v' output:
  16059.      MyISAM file:         company
  16060.      Record format:       Fixed length
  16061.      File-version:        1
  16062.      Creation time:       1999-10-30 12:12:51
  16063.      Recover time:        1999-10-31 19:13:01
  16064.      Status:              checked
  16065.      Data records:           1403698  Deleted blocks:              0
  16066.      Datafile parts:         1403698  Deleted data:                0
  16067.      Datafilepointer (bytes):      3  Keyfile pointer (bytes):     3
  16068.      Max datafile length: 3791650815  Max keyfile length: 4294967294
  16069.      Recordlength:               226
  16070.      
  16071.      table description:
  16072.      Key Start Len Index   Type                  Rec/key     Root Blocksize
  16073.      1   2     8   unique  double                      1 15845376      1024
  16074.      2   15    10  multip. text packed stripped        2 25062400      1024
  16075.      3   219   8   multip. double                     73 40907776      1024
  16076.      4   63    10  multip. text packed stripped        5 48097280      1024
  16077.      5   167   2   multip. unsigned short           4840 55200768      1024
  16078.      6   177   4   multip. unsigned long            1346 65145856      1024
  16079.      7   155   4   multip. text                     4995 75090944      1024
  16080.      8   138   4   multip. unsigned long              87 85036032      1024
  16081.      9   177   4   multip. unsigned long             178 96481280      1024
  16082.          193   1           text
  16083.  
  16084. Example of `myisamchk -eis' output:
  16085.      Checking MyISAM file: company
  16086.      Key:  1:  Keyblocks used:  97%  Packed:    0%  Max levels:  4
  16087.      Key:  2:  Keyblocks used:  98%  Packed:   50%  Max levels:  4
  16088.      Key:  3:  Keyblocks used:  97%  Packed:    0%  Max levels:  4
  16089.      Key:  4:  Keyblocks used:  99%  Packed:   60%  Max levels:  3
  16090.      Key:  5:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  16091.      Key:  6:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  16092.      Key:  7:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  16093.      Key:  8:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  16094.      Key:  9:  Keyblocks used:  98%  Packed:    0%  Max levels:  4
  16095.      Total:    Keyblocks used:  98%  Packed:   17%
  16096.      
  16097.      Records:          1403698    M.recordlength:     226   Packed:             0%
  16098.      Recordspace used:     100%   Empty space:          0%  Blocks/Record:   1.00
  16099.      Record blocks:    1403698    Delete blocks:        0
  16100.      Recorddata:     317235748    Deleted data:         0
  16101.      Lost space:             0    Linkdata:             0
  16102.      
  16103.      User time 1626.51, System time 232.36
  16104.      Maximum resident set size 0, Integral resident set size 0
  16105.      Non physical pagefaults 0, Physical pagefaults 627, Swaps 0
  16106.      Blocks in 0 out 0, Messages in 0 out 0, Signals 0
  16107.      Voluntary context switches 639, Involuntary context switches 28966
  16108.  
  16109. Example of `myisamchk -eiv' output:
  16110.      Checking MyISAM file: company
  16111.      Data records: 1403698   Deleted blocks:       0
  16112.      - check file-size
  16113.      - check delete-chain
  16114.      block_size 1024:
  16115.      index  1:
  16116.      index  2:
  16117.      index  3:
  16118.      index  4:
  16119.      index  5:
  16120.      index  6:
  16121.      index  7:
  16122.      index  8:
  16123.      index  9:
  16124.      No recordlinks
  16125.      - check index reference
  16126.      - check data record references index: 1
  16127.      Key:  1:  Keyblocks used:  97%  Packed:    0%  Max levels:  4
  16128.      - check data record references index: 2
  16129.      Key:  2:  Keyblocks used:  98%  Packed:   50%  Max levels:  4
  16130.      - check data record references index: 3
  16131.      Key:  3:  Keyblocks used:  97%  Packed:    0%  Max levels:  4
  16132.      - check data record references index: 4
  16133.      Key:  4:  Keyblocks used:  99%  Packed:   60%  Max levels:  3
  16134.      - check data record references index: 5
  16135.      Key:  5:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  16136.      - check data record references index: 6
  16137.      Key:  6:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  16138.      - check data record references index: 7
  16139.      Key:  7:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  16140.      - check data record references index: 8
  16141.      Key:  8:  Keyblocks used:  99%  Packed:    0%  Max levels:  3
  16142.      - check data record references index: 9
  16143.      Key:  9:  Keyblocks used:  98%  Packed:    0%  Max levels:  4
  16144.      Total:    Keyblocks used:   9%  Packed:   17%
  16145.      
  16146.      - check records and index references
  16147.      [LOTS OF ROW NUMBERS DELETED]
  16148.      
  16149.      Records:          1403698    M.recordlength:     226   Packed:             0%
  16150.      Recordspace used:     100%   Empty space:          0%  Blocks/Record:   1.00
  16151.      Record blocks:    1403698    Delete blocks:        0
  16152.      Recorddata:     317235748    Deleted data:         0
  16153.      Lost space:             0    Linkdata:             0
  16154.      
  16155.      User time 1639.63, System time 251.61
  16156.      Maximum resident set size 0, Integral resident set size 0
  16157.      Non physical pagefaults 0, Physical pagefaults 10580, Swaps 0
  16158.      Blocks in 4 out 0, Messages in 0 out 0, Signals 0
  16159.      Voluntary context switches 10604, Involuntary context switches 122798
  16160.  
  16161. Here are the sizes of the data and index files for the table used in the
  16162. preceding examples:
  16163.  
  16164.      -rw-rw-r--   1 monty    tcx     317235748 Jan 12 17:30 company.MYD
  16165.      -rw-rw-r--   1 davida   tcx      96482304 Jan 12 18:35 company.MYM
  16166.  
  16167. Explanations for the types of information `myisamchk' produces are
  16168. given below.  The "keyfile" is the index file.  "Record" and "row" are
  16169. synonymous:
  16170.  
  16171. `ISAM file'
  16172.      Name of the ISAM (index) file.
  16173.  
  16174. `Isam-version'
  16175.      Version of ISAM format. Currently always 2.
  16176.  
  16177. `Creation time'
  16178.      When the data file was created.
  16179.  
  16180. `Recover time'
  16181.      When the index/data file was last reconstructed.
  16182.  
  16183. `Data records'
  16184.      How many records are in the table.
  16185.  
  16186. `Deleted blocks'
  16187.      How many deleted blocks still have reserved space.  You can
  16188.      optimize your table to minimize this space.  *Note Optimization::.
  16189.  
  16190. `Datafile: Parts'
  16191.      For dynamic record format, this indicates how many data blocks
  16192.      there are. For an optimized table without fragmented records, this
  16193.      is the same as `Data records'.
  16194.  
  16195. `Deleted data'
  16196.      How many bytes of non-reclaimed deleted data there are.  You can
  16197.      optimize your table to minimize this space.  *Note Optimization::.
  16198.  
  16199. `Datafile pointer'
  16200.      The size of the data file pointer, in bytes. It is usually 2, 3,
  16201.      4, or 5 bytes. Most tables manage with 2 bytes, but this cannot be
  16202.      controlled from MySQL yet. For fixed tables, this is a record
  16203.      address. For dynamic tables, this is a byte address.
  16204.  
  16205. `Keyfile pointer'
  16206.      The size of the index file pointer, in bytes. It is usually 1, 2,
  16207.      or 3 bytes. Most tables manage with 2 bytes, but this is calculated
  16208.      automatically by MySQL. It is always a block address.
  16209.  
  16210. `Max datafile length'
  16211.      How long the table's data file (`.MYD' file) can become, in bytes.
  16212.  
  16213. `Max keyfile length'
  16214.      How long the table's key file (`.MYI' file) can become, in bytes.
  16215.  
  16216. `Recordlength'
  16217.      How much space each record takes, in bytes.
  16218.  
  16219. `Record format'
  16220.      The format used to store table rows.  The examples shown above use
  16221.      `Fixed length'.  Other possible values are `Compressed' and
  16222.      `Packed'.
  16223.  
  16224. `table description'
  16225.      A list of all keys in the table. For each key, some low-level
  16226.      information is presented:
  16227.  
  16228.     `Key'
  16229.           This key's number.
  16230.  
  16231.     `Start'
  16232.           Where in the record this index part starts.
  16233.  
  16234.     `Len'
  16235.           How long this index part is. For packed numbers, this should
  16236.           always be the full length of the column. For strings, it may
  16237.           be shorter than the full length of the indexed column,
  16238.           because you can index a prefix of a string column.
  16239.  
  16240.     `Index'
  16241.           `unique' or `multip.' (multiple). Indicates whether or not
  16242.           one value can exist multiple times in this index.
  16243.  
  16244.     `Type'
  16245.           What data-type this index part has. This is an ISAM data-type
  16246.           with the options `packed', `stripped' or `empty'.
  16247.  
  16248.     `Root'
  16249.           Address of the root index block.
  16250.  
  16251.     `Blocksize'
  16252.           The size of each index block. By default this is 1024, but
  16253.           the value may be changed at compile time.
  16254.  
  16255.     `Rec/key'
  16256.           This is a statistical value used by the optimizer. It tells
  16257.           how many records there are per value for this key. A unique
  16258.           key always has a value of 1. This may be updated after a
  16259.           table is loaded (or greatly changed) with `myisamchk -a'. If
  16260.           this is not updated at all, a default value of 30 is given.
  16261.  
  16262. `'
  16263.      In the first example above, the 9th key is a multi-part key with
  16264.      two parts.
  16265.  
  16266. `Keyblocks used'
  16267.      What percentage of the keyblocks are used. Because the table used
  16268.      in the examples had just been reorganized with `myisamchk', the
  16269.      values are very high (very near the theoretical maximum).
  16270.  
  16271. `Packed'
  16272.      MySQL tries to pack keys with a common suffix. This can only be
  16273.      used for `CHAR'/`VARCHAR'/`DECIMAL' keys. For long strings like
  16274.      names, this can significantly reduce the space used. In the third
  16275.      example above, the 4th key is 10 characters long and a 60%
  16276.      reduction in space is achieved.
  16277.  
  16278. `Max levels'
  16279.      How deep the B-tree for this key is. Large tables with long keys
  16280.      get high values.
  16281.  
  16282. `Records'
  16283.      How many rows are in the table.
  16284.  
  16285. `M.recordlength'
  16286.      The average record length. For tables with fixed-length records,
  16287.      this is the exact record length.
  16288.  
  16289. `Packed'
  16290.      MySQL strips spaces from the end of strings. The `Packed' value
  16291.      indicates the percentage of savings achieved by doing this.
  16292.  
  16293. `Recordspace used'
  16294.      What percentage of the data file is used.
  16295.  
  16296. `Empty space'
  16297.      What percentage of the data file is unused.
  16298.  
  16299. `Blocks/Record'
  16300.      Average number of blocks per record (that is, how many links a
  16301.      fragmented record is composed of). This is always 1 for
  16302.      fixed-format tables. This value should stay as close to 1.0 as
  16303.      possible. If it gets too big, you can reorganize the table with
  16304.      `myisamchk'.  *Note Optimization::.
  16305.  
  16306. `Recordblocks'
  16307.      How many blocks (links) are used. For fixed format, this is the
  16308.      same as the number of records.
  16309.  
  16310. `Deleteblocks'
  16311.      How many blocks (links) are deleted.
  16312.  
  16313. `Recorddata'
  16314.      How many bytes in the data file are used.
  16315.  
  16316. `Deleted data'
  16317.      How many bytes in the data file are deleted (unused).
  16318.  
  16319. `Lost space'
  16320.      If a record is updated to a shorter length, some space is lost.
  16321.      This is the sum of all such losses, in bytes.
  16322.  
  16323. `Linkdata'
  16324.      When the dynamic table format is used, record fragments are linked
  16325.      with pointers (4 to 7 bytes each). `Linkdata' is the sum of the
  16326.      amount of storage used by all such pointers.
  16327.  
  16328. If a table has been compressed with `myisampack', `myisamchk -d' prints
  16329. additional information about each table column.  See *Note
  16330. `myisampack': myisampack, for an example of this information and a
  16331. description of what it means.
  16332.  
  16333. 
  16334. File: mysql.info,  Node: Database Administration,  Next: Localization,  Prev: Disaster Prevention,  Up: MySQL Database Administration
  16335.  
  16336. Database Administration Language Reference
  16337. ==========================================
  16338.  
  16339. * Menu:
  16340.  
  16341. * OPTIMIZE TABLE::              `OPTIMIZE TABLE' Syntax
  16342. * ANALYZE TABLE::               `ANALYZE TABLE' Syntax
  16343. * FLUSH::                       `FLUSH' Syntax
  16344. * KILL::                        `KILL' Syntax
  16345. * SHOW::                        `SHOW' Syntax
  16346.  
  16347. 
  16348. File: mysql.info,  Node: OPTIMIZE TABLE,  Next: ANALYZE TABLE,  Prev: Database Administration,  Up: Database Administration
  16349.  
  16350. `OPTIMIZE TABLE' Syntax
  16351. -----------------------
  16352.  
  16353.      OPTIMIZE TABLE tbl_name[,tbl_name]...
  16354.  
  16355. `OPTIMIZE TABLE' should be used if you have deleted a large part of a
  16356. table or if you have made many changes to a table with variable-length
  16357. rows (tables that have `VARCHAR', `BLOB', or `TEXT' columns).  Deleted
  16358. records are maintained in a linked list and subsequent `INSERT'
  16359. operations reuse old record positions. You can use `OPTIMIZE TABLE' to
  16360. reclaim the unused space and to defragment the data file.
  16361.  
  16362. For the moment `OPTIMIZE TABLE' only works on *MyISAM* and `BDB'
  16363. tables. For `BDB' tables, `OPTIMIZE TABLE' is currently mapped to
  16364. `ANALYZE TABLE'. *Note ANALYZE TABLE::.
  16365.  
  16366. You can get optimize table to work on other table types by starting
  16367. `mysqld' with `--skip-new' or `--safe-mode', but in this case `OPTIMIZE
  16368. TABLE' is just mapped to `ALTER TABLE'.
  16369.  
  16370. `OPTIMIZE TABLE' works the following way:
  16371.    * If the table has deleted or split rows, repair the table.
  16372.  
  16373.    * If the index pages are not sorted, sort them.
  16374.  
  16375.    * If the statistics are not up to date (and the repair couldn't be
  16376.      done by sorting the index), update them.
  16377.  
  16378. `OPTIMIZE TABLE' for `MyISAM' tables is equvialent of running
  16379. `myisamchk --quick --check-changed-tables --sort-index --analyze' on
  16380. the table.
  16381.  
  16382. Note that the table is locked during the time `OPTIMIZE TABLE' is
  16383. running!
  16384.  
  16385. 
  16386. File: mysql.info,  Node: ANALYZE TABLE,  Next: FLUSH,  Prev: OPTIMIZE TABLE,  Up: Database Administration
  16387.  
  16388. `ANALYZE TABLE' Syntax
  16389. ----------------------
  16390.  
  16391.      ANALYZE TABLE tbl_name[,tbl_name...]
  16392.  
  16393. Analyze and store the key distribution for the table.  During the
  16394. analyze the table is locked with a read lock.  This works on `MyISAM'
  16395. and `BDB' tables.
  16396.  
  16397. This is equivalent to running `myisamchk -a' on the table.
  16398.  
  16399. MySQL uses the stored key distribution to decide in which order tables
  16400. should be joined when one does a join on something else than a constant.
  16401.  
  16402. The command returns a table with the following columns:
  16403.  
  16404. *Column*                  *Value*
  16405. Table                     Table name
  16406. Op                        Always "analyze"
  16407. Msg_type                  One of `status', `error', `info' or `warning'.
  16408. Msg_text                  The message.
  16409.  
  16410. You can check the stored key distribution with the `SHOW INDEX' command.
  16411. *Note SHOW DATABASE INFO::.
  16412.  
  16413. If the table hasn't changed since the last `ANALYZE TABLE' command, the
  16414. table will not be analyzed again.
  16415.  
  16416. 
  16417. File: mysql.info,  Node: FLUSH,  Next: KILL,  Prev: ANALYZE TABLE,  Up: Database Administration
  16418.  
  16419. `FLUSH' Syntax
  16420. --------------
  16421.  
  16422.      FLUSH flush_option [,flush_option]
  16423.  
  16424. You should use the `FLUSH' command if you want to clear some of the
  16425. internal caches MySQL uses.  To execute `FLUSH', you must have the
  16426. *RELOAD* privilege.
  16427.  
  16428. `flush_option' can be any of the following:
  16429.  
  16430. `HOSTS'     Empties the host cache tables.  You should flush the host
  16431.             tables if some of your hosts change IP number or if you get
  16432.             the error message `Host ... is blocked'.  When more than
  16433.             `max_connect_errors' errors occur in a row for a given host
  16434.             while connection to the MySQL server, MySQL assumes
  16435.             something is wrong and blocks the host from further
  16436.             connection requests.  Flushing the host tables allows the
  16437.             host to attempt to connect again. *Note Blocked host::.) You
  16438.             can start `mysqld' with `-O max_connection_errors=999999999'
  16439.             to avoid this error message.
  16440. `LOGS'      Closes and reopens all log files.  If you have specified the
  16441.             update log file or a binary log file without an extension,
  16442.             the extension number of the log file will be incremented by
  16443.             one relative to the previous file.  If you have used an
  16444.             extension in the file name, MySQL will close and reopen the
  16445.             update log file.  *Note Update log::. This is the same thing
  16446.             as sending the `SIGHUP' signal to the `mysqld' server.
  16447. `PRIVILEGES'Reloads the privileges from the grant tables in the `mysql'
  16448.             database.
  16449. `TABLES'    Closes all open tables and force all tables in use to be
  16450.             closed.
  16451. `[TABLE |   Flushes only the given tables.
  16452. TABLES]     
  16453. table_name  
  16454. [,table_name...]'
  16455. `TABLES     Closes all open tables and locks all tables for all
  16456. WITH READ   databases with a read until one executes `UNLOCK TABLES'.
  16457. LOCK'       This is very convenient way to get backups if you have a
  16458.             file system, like Veritas,that can take snapshots in time.
  16459. `STATUS'    Resets most status variables to zero. This is something one
  16460.             should only use when debugging a query.
  16461.  
  16462. You can also access each of the commands shown above with the
  16463. `mysqladmin' utility, using the `flush-hosts', `flush-logs', `reload',
  16464. or `flush-tables' commands.
  16465.  
  16466. Take also a look at the `RESET' command used with replication. *Note
  16467. Replication SQL::.
  16468.  
  16469. 
  16470. File: mysql.info,  Node: KILL,  Next: SHOW,  Prev: FLUSH,  Up: Database Administration
  16471.  
  16472. `KILL' Syntax
  16473. -------------
  16474.  
  16475.      KILL thread_id
  16476.  
  16477. Each connection to `mysqld' runs in a separate thread.  You can see
  16478. which threads are running with the `SHOW PROCESSLIST' command and kill
  16479. a thread with the `KILL thread_id' command.
  16480.  
  16481. If you have the *process* privilege, you can see and kill all threads.
  16482. Otherwise, you can see and kill only your own threads.
  16483.  
  16484. You can also use the `mysqladmin processlist' and `mysqladmin kill'
  16485. commands to examine and kill threads.
  16486.  
  16487. When you do a `KILL', a thread specific `kill flag' is set for the
  16488. thread.
  16489.  
  16490. In most cases it may take some time for the thread to die as the kill
  16491. flag is only checked at specific intervals.
  16492.  
  16493.    * In `SELECT', `ORDER BY' and `GROUP BY' loops, the flag is checked
  16494.      after reading a block of rows. If the kill flag is set the
  16495.      statement is aborted
  16496.  
  16497.    * When doing an `ALTER TABLE' the kill flag is checked before each
  16498.      block of rows are read from the original table. If the kill flag
  16499.      was set the command is aborted and the temporary table is deleted.
  16500.  
  16501.    * When doing an `UPDATE TABLE' and `DELETE TABLE', the kill flag is
  16502.      checked after each block read and after each updated or delete
  16503.      row. If the kill flag is set the statement is aborted.  Note that
  16504.      if you are not using transactions, the changes will not be rolled
  16505.      back!
  16506.  
  16507.    * `GET_LOCK()' will abort with `NULL'.
  16508.  
  16509.    * An `INSERT DELAYED' thread will quickly flush all rows it has in
  16510.      memory and die.
  16511.  
  16512.    * If the thread is in the table lock handler (state: `Locked'), the
  16513.      table lock will be quickly aborted.
  16514.  
  16515.    * If the thread is waiting for free disk space in a `write' call, the
  16516.      write is aborted with an disk full error message.
  16517.  
  16518. * Menu:
  16519.  
  16520. * SHOW::                        `SHOW' Syntax
  16521.  
  16522. 
  16523. File: mysql.info,  Node: SHOW,  Prev: KILL,  Up: Database Administration
  16524.  
  16525. `SHOW' Syntax
  16526. -------------
  16527.  
  16528.         SHOW DATABASES [LIKE wild]
  16529.      or SHOW [OPEN] TABLES [FROM db_name] [LIKE wild]
  16530.      or SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name] [LIKE wild]
  16531.      or SHOW INDEX FROM tbl_name [FROM db_name]
  16532.      or SHOW TABLE STATUS [FROM db_name] [LIKE wild]
  16533.      or SHOW STATUS [LIKE wild]
  16534.      or SHOW VARIABLES [LIKE wild]
  16535.      or SHOW LOGS
  16536.      or SHOW [FULL] PROCESSLIST
  16537.      or SHOW GRANTS FOR user
  16538.      or SHOW CREATE TABLE table_name
  16539.      or SHOW MASTER STATUS
  16540.      or SHOW MASTER LOGS
  16541.      or SHOW SLAVE STATUS
  16542.  
  16543. `SHOW' provides information about databases, tables, columns, or status
  16544. information about the server. If the `LIKE wild' part is used, the
  16545. `wild' string can be a string that uses the SQL `%' and `_' wild-card
  16546. characters.
  16547.  
  16548. * Menu:
  16549.  
  16550. * SHOW DATABASE INFO::          Retrieving information about Database, Tables, Columns, and Indexes
  16551. * SHOW TABLE STATUS::           `SHOW TABLE STATUS'
  16552. * SHOW STATUS::                 `SHOW STATUS'
  16553. * SHOW VARIABLES::              `SHOW VARIABLES'
  16554. * SHOW LOGS::                   `SHOW LOGS'
  16555. * SHOW PROCESSLIST::            `SHOW PROCESSLIST'
  16556. * SHOW GRANTS::                 `SHOW GRANTS'
  16557. * SHOW CREATE TABLE::           `SHOW CREATE TABLE'
  16558.  
  16559. 
  16560. File: mysql.info,  Node: SHOW DATABASE INFO,  Next: SHOW TABLE STATUS,  Prev: SHOW,  Up: SHOW
  16561.  
  16562. Retrieving information about Database, Tables, Columns, and Indexes
  16563. ...................................................................
  16564.  
  16565. You can use `db_name.tbl_name' as an alternative to the `tbl_name FROM
  16566. db_name' syntax.  These two statements are equivalent:
  16567.  
  16568.      mysql> SHOW INDEX FROM mytable FROM mydb;
  16569.      mysql> SHOW INDEX FROM mydb.mytable;
  16570.  
  16571. `SHOW DATABASES' lists the databases on the MySQL server host.  You can
  16572. also get this list using the `mysqlshow' command.
  16573.  
  16574. `SHOW TABLES' lists the tables in a given database.  You can also get
  16575. this list using the `mysqlshow db_name' command.
  16576.  
  16577. *NOTE:* If a user doesn't have any privileges for a table, the table
  16578. will not show up in the output from `SHOW TABLES' or `mysqlshow
  16579. db_name'.
  16580.  
  16581. `SHOW OPEN TABLES' lists the tables that are currently open in the
  16582. table cache. *Note Table cache::.  The `Comment' field tells how many
  16583. times the table is `cached' and `in_use'.
  16584.  
  16585. `SHOW COLUMNS' lists the columns in a given table.  If you specify the
  16586. `FULL' option, you will also get the privileges you have for each
  16587. column.  If the column types are different than you expect them to be
  16588. based on a `CREATE TABLE' statement, note that MySQL sometimes changes
  16589. column types.  *Note Silent column changes::.
  16590.  
  16591. The `DESCRIBE' statement provides information similar to `SHOW COLUMNS'.
  16592. *Note `DESCRIBE': DESCRIBE.
  16593.  
  16594. `SHOW FIELDS' is a synonym for `SHOW COLUMNS', and `SHOW KEYS' is a
  16595. synonym for `SHOW INDEX'.  You can also list a table's columns or
  16596. indexes with `mysqlshow db_name tbl_name' or `mysqlshow -k db_name
  16597. tbl_name'.
  16598.  
  16599. `SHOW INDEX' returns the index information in a format that closely
  16600. resembles the `SQLStatistics' call in ODBC. The following columns are
  16601. returned:
  16602.  
  16603. *Column*                  *Meaning*
  16604. `Table'                   Name of the table.
  16605. `Non_unique'              0 if the index can't contain duplicates.
  16606. `Key_name'                Name of the index.
  16607. `Seq_in_index'            Column sequence number in index,
  16608.                                                  starting with 1.
  16609. `Column_name'             Column name.
  16610. `Collation'               How the column is sorted in the index.
  16611.                                                         In MySQL, this
  16612.                           can have values
  16613.                                 `A' (Ascending) or `NULL' (Not
  16614.                                                       sorted).
  16615. `Cardinality'             Number of unique values in the index.
  16616.                                                        This is updated
  16617.                           by running
  16618.                            `isamchk -a'.
  16619. `Sub_part'                Number of indexed characters if the
  16620.                                                     column is only
  16621.                           partly indexed.
  16622.                                  `NULL' if the entire key is indexed.
  16623. `Comment'                 Various remarks.  For now, it tells
  16624.                                                     whether index is
  16625.                           FULLTEXT or not.
  16626.  
  16627. Note that as the `Cardinality' is counted based on statistics stored as
  16628. integers, it's not necessarily accurate for small tables.
  16629.  
  16630. 
  16631. File: mysql.info,  Node: SHOW TABLE STATUS,  Next: SHOW STATUS,  Prev: SHOW DATABASE INFO,  Up: SHOW
  16632.  
  16633. `SHOW TABLE STATUS'
  16634. ...................
  16635.  
  16636.      SHOW TABLE STATUS [FROM db_name] [LIKE wild]
  16637.  
  16638. `SHOW TABLE STATUS' (new in Version 3.23) works likes `SHOW STATUS',
  16639. but provides a lot of information about each table. You can also get
  16640. this list using the `mysqlshow --status db_name' command.  The
  16641. following columns are returned:
  16642.  
  16643. *Column*               *Meaning*
  16644. `Name'                 Name of the table.
  16645. `Type'                 Type of table. *Note Table types::.
  16646. `Row_format'           The row storage format (Fixed, Dynamic, or
  16647.                        Compressed).
  16648. `Rows'                 Number of rows.
  16649. `Avg_row_length'       Average row length.
  16650. `Data_length'          Length of the data file.
  16651. `Max_data_length'      Max length of the data file.
  16652. `Index_length'         Length of the index file.
  16653. `Data_free'            Number of allocated but not used bytes.
  16654. `Auto_increment'       Next autoincrement value.
  16655. `Create_time'          When the table was created.
  16656. `Update_time'          When the data file was last updated.
  16657. `Check_time'           When the table was last checked.
  16658. `Create_options'       Extra options used with `CREATE TABLE'.
  16659. `Comment'              The comment used when creating the table (or some
  16660.                        information why MySQL couldn't access the table
  16661.                        information).
  16662.  
  16663. `InnoDB' tables will report the free space in the tablespace in the
  16664. table comment.
  16665.  
  16666. 
  16667. File: mysql.info,  Node: SHOW STATUS,  Next: SHOW VARIABLES,  Prev: SHOW TABLE STATUS,  Up: SHOW
  16668.  
  16669. `SHOW STATUS'
  16670. .............
  16671.  
  16672. `SHOW STATUS' provides server status information (like `mysqladmin
  16673. extended-status'). The output resembles that shown below, though the
  16674. format and numbers probably differ:
  16675.  
  16676.      +--------------------------+------------+
  16677.      | Variable_name            | Value      |
  16678.      +--------------------------+------------+
  16679.      | Aborted_clients          | 0          |
  16680.      | Aborted_connects         | 0          |
  16681.      | Bytes_received           | 155372598  |
  16682.      | Bytes_sent               | 1176560426 |
  16683.      | Connections              | 30023      |
  16684.      | Created_tmp_disk_tables  | 0          |
  16685.      | Created_tmp_tables       | 8340       |
  16686.      | Created_tmp_files        | 60         |
  16687.      | Delayed_insert_threads   | 0          |
  16688.      | Delayed_writes           | 0          |
  16689.      | Delayed_errors           | 0          |
  16690.      | Flush_commands           | 1          |
  16691.      | Handler_delete           | 462604     |
  16692.      | Handler_read_first       | 105881     |
  16693.      | Handler_read_key         | 27820558   |
  16694.      | Handler_read_next        | 390681754  |
  16695.      | Handler_read_prev        | 6022500    |
  16696.      | Handler_read_rnd         | 30546748   |
  16697.      | Handler_read_rnd_next    | 246216530  |
  16698.      | Handler_update           | 16945404   |
  16699.      | Handler_write            | 60356676   |
  16700.      | Key_blocks_used          | 14955      |
  16701.      | Key_read_requests        | 96854827   |
  16702.      | Key_reads                | 162040     |
  16703.      | Key_write_requests       | 7589728    |
  16704.      | Key_writes               | 3813196    |
  16705.      | Max_used_connections     | 0          |
  16706.      | Not_flushed_key_blocks   | 0          |
  16707.      | Not_flushed_delayed_rows | 0          |
  16708.      | Open_tables              | 1          |
  16709.      | Open_files               | 2          |
  16710.      | Open_streams             | 0          |
  16711.      | Opened_tables            | 44600      |
  16712.      | Questions                | 2026873    |
  16713.      | Select_full_join         | 0          |
  16714.      | Select_full_range_join   | 0          |
  16715.      | Select_range             | 99646      |
  16716.      | Select_range_check       | 0          |
  16717.      | Select_scan              | 30802      |
  16718.      | Slave_running            | OFF        |
  16719.      | Slave_open_temp_tables   | 0          |
  16720.      | Slow_launch_threads      | 0          |
  16721.      | Slow_queries             | 0          |
  16722.      | Sort_merge_passes        | 30         |
  16723.      | Sort_range               | 500        |
  16724.      | Sort_rows                | 30296250   |
  16725.      | Sort_scan                | 4650       |
  16726.      | Table_locks_immediate    | 1920382    |
  16727.      | Table_locks_waited       | 0          |
  16728.      | Threads_cached           | 0          |
  16729.      | Threads_created          | 30022      |
  16730.      | Threads_connected        | 1          |
  16731.      | Threads_running          | 1          |
  16732.      | Uptime                   | 80380      |
  16733.      +--------------------------+------------+
  16734.  
  16735. The status variables listed above have the following meaning:
  16736.  
  16737. *Variable*                *Meaning*
  16738. `Aborted_clients'         Number of connections aborted because the
  16739.                           client died without closing the connection
  16740.                           properly. *Note Communication errors::.
  16741. `Aborted_connects'        Number of tries to connect to the MySQL server
  16742.                           that failed. *Note Communication errors::.
  16743. `Bytes_received'          Number of bytes received from all clients.
  16744. `Bytes_sent'              Number of bytes sent to all clients.
  16745. `Com_xxxx'                Number of times the xxx commands has been
  16746.                           executed.
  16747. `Connections'             Number of connection attempts to the MySQL
  16748.                           server.
  16749. `Created_tmp_disk_tables' Number of implicit temporary tables on disk
  16750.                           created while executing statements.
  16751. `Created_tmp_tables'      Number of implicit temporary tables in memory
  16752.                           created while executing statements.
  16753. `Created_tmp_files'       How many temporary files `mysqld' have created.
  16754. `Delayed_insert_threads'  Number of delayed insert handler threads in
  16755.                           use.
  16756. `Delayed_writes'          Number of rows written with `INSERT DELAYED'.
  16757. `Delayed_errors'          Number of rows written with `INSERT DELAYED'
  16758.                           for which some error occurred (probably
  16759.                           `duplicate key').
  16760. `Flush_commands'          Number of executed `FLUSH' commands.
  16761. `Handler_delete'          Number of times a row was deleted from a table.
  16762. `Handler_read_first'      Number of times the first entry was read from
  16763.                           an index.  If this is high, it suggests that
  16764.                           the server is doing a lot of full index scans,
  16765.                           for example, `SELECT col1 FROM foo', assuming
  16766.                           that col1 is indexed.
  16767. `Handler_read_key'        Number of requests to read a row based on a
  16768.                           key. If this is high, it is a good indication
  16769.                           that your queries and tables are properly
  16770.                           indexed.
  16771. `Handler_read_next'       Number of requests to read next row in key
  16772.                           order. This will be incremented if you are
  16773.                           querying an index column with a range
  16774.                           constraint. This also will be incremented if
  16775.                           you are doing an index scan.
  16776. `Handler_read_rnd'        Number of requests to read a row based on a
  16777.                           fixed position.  This will be high if you are
  16778.                           doing a lot of queries that require sorting of
  16779.                           the result.
  16780. `Handler_read_rnd_next'   Number of requests to read the next row in the
  16781.                           datafile.  This will be high if you are doing
  16782.                           a lot of table scans. Generally this suggests
  16783.                           that your tables are not properly indexed or
  16784.                           that your queries are not written to take
  16785.                           advantage of the indexes you have.
  16786. `Handler_update'          Number of requests to update a row in a table.
  16787. `Handler_write'           Number of requests to insert a row in a table.
  16788. `Key_blocks_used'         The number of used blocks in the key cache.
  16789. `Key_read_requests'       The number of requests to read a key block
  16790.                           from the cache.
  16791. `Key_reads'               The number of physical reads of a key block
  16792.                           from disk.
  16793. `Key_write_requests'      The number of requests to write a key block to
  16794.                           the cache.
  16795. `Key_writes'              The number of physical writes of a key block
  16796.                           to disk.
  16797. `Max_used_connections'    The maximum number of connections in use
  16798.                           simultaneously.
  16799. `Not_flushed_key_blocks'  Keys blocks in the key cache that has changed
  16800.                           but hasn't yet been flushed to disk.
  16801. `Not_flushed_delayed_rows'Number of rows waiting to be written in
  16802.                           `INSERT DELAY' queues.
  16803. `Open_tables'             Number of tables that are open.
  16804. `Open_files'              Number of files that are open.
  16805. `Open_streams'            Number of streams that are open (used mainly
  16806.                           for logging).
  16807. `Opened_tables'           Number of tables that have been opened.
  16808. `Select_full_join'        Number of joins without keys (If this is 0,
  16809.                           you should carefully check the index of your
  16810.                           tables).
  16811. `Select_full_range_join'  Number of joins where we used a range search
  16812.                           on reference table.
  16813. `Select_range'            Number of joins where we used ranges on the
  16814.                           first table. (It's normally not critical even
  16815.                           if this is big.)
  16816. `Select_scan'             Number of joins where we did a full scann of
  16817.                           the first table.
  16818. `Select_range_check'      Number of joins without keys where we check
  16819.                           for key usage after each row (If this is 0,
  16820.                           you should carefully check the index of your
  16821.                           tables).
  16822. `Questions'               Number of queries sent to the server.
  16823. `Slave_open_temp_tables'  Number of temporary tables currently open by
  16824.                           the slave thread
  16825. `Slow_launch_threads'     Number of threads that have taken more than
  16826.                           `slow_launch_time' to create.
  16827. `Slow_queries'            Number of queries that have taken more than
  16828.                           `long_query_time'. *Note Slow query log::.
  16829. `Sort_merge_passes'       Number of merges passes the sort algoritm have
  16830.                           had to do. If this value is large you should
  16831.                           consider increasing `sort_buffer'.
  16832. `Sort_range'              Number of sorts that where done with ranges.
  16833. `Sort_rows'               Number of sorted rows.
  16834. `Sort_scan'               Number of sorts that where done by scanning
  16835.                           the table.
  16836. `Table_locks_immediate'   Number of times a table lock was acquired
  16837.                           immediately. Available after 3.23.33.
  16838. `Table_locks_waited'      Number of times a table lock could not be
  16839.                           acquired immediately and a wait was needed. If
  16840.                           this is high, and you have performance
  16841.                           problems, you should first optimize your
  16842.                           queries, and then either split your table(s)
  16843.                           or use replication. Available after 3.23.33.
  16844. `Threads_cached'          Number of threads in the thread cache.
  16845. `Threads_connected'       Number of currently open connections.
  16846. `Threads_created'         Number of threads created to handle
  16847.                           connections.
  16848. `Threads_running'         Number of threads that are not sleeping.
  16849. `Uptime'                  How many seconds the server has been up.
  16850.  
  16851. Some comments about the above:
  16852.  
  16853.    * If `Opened_tables' is big, then your `table_cache' variable is
  16854.      probably too small.
  16855.  
  16856.    * If `key_reads' is big, then your `key_buffer_size' variable is
  16857.      probably too small.  The cache hit rate can be calculated with
  16858.      `key_reads'/`key_read_requests'.
  16859.  
  16860.    * If `Handler_read_rnd' is big, then you probably have a lot of
  16861.      queries that require MySQL to scan whole tables or you have joins
  16862.      that don't use keys properly.
  16863.  
  16864.    * If `Threads_created' is big, you may want to increase the
  16865.      `thread_cache_size' variable.
  16866.  
  16867. 
  16868. File: mysql.info,  Node: SHOW VARIABLES,  Next: SHOW LOGS,  Prev: SHOW STATUS,  Up: SHOW
  16869.  
  16870. `SHOW VARIABLES'
  16871. ................
  16872.  
  16873.      SHOW VARIABLES [LIKE wild]
  16874.  
  16875. `SHOW VARIABLES' shows the values of some MySQL system variables.  You
  16876. can also get this information using the `mysqladmin variables' command.
  16877. If the default values are unsuitable, you can set most of these
  16878. variables using command-line options when `mysqld' starts up.  *Note
  16879. Command-line options::.
  16880.  
  16881. The output resembles that shown below, though the format and numbers may
  16882. differ somewhat:
  16883.  
  16884.      +-------------------------+---------------------------+
  16885.      | Variable_name           | Value                     |
  16886.      +-------------------------+---------------------------+
  16887.      | ansi_mode               | OFF                       |
  16888.      | back_log                | 50                        |
  16889.      | basedir                 | /my/monty/                |
  16890.      | bdb_cache_size          | 16777216                  |
  16891.      | bdb_log_buffer_size     | 32768                     |
  16892.      | bdb_home                | /my/monty/data/           |
  16893.      | bdb_max_lock            | 10000                     |
  16894.      | bdb_logdir              |                           |
  16895.      | bdb_shared_data         | OFF                       |
  16896.      | bdb_tmpdir              | /tmp/                     |
  16897.      | binlog_cache_size       | 32768                     |
  16898.      | concurrent_insert       | ON                        |
  16899.      | connect_timeout         | 5                         |
  16900.      | datadir                 | /my/monty/data/           |
  16901.      | delay_key_write         | ON                        |
  16902.      | delayed_insert_limit    | 100                       |
  16903.      | delayed_insert_timeout  | 300                       |
  16904.      | delayed_queue_size      | 1000                      |
  16905.      | flush                   | OFF                       |
  16906.      | flush_time              | 0                         |
  16907.      | have_bdb                | YES                       |
  16908.      | have_innodb             | YES                       |
  16909.      | have_raid               | YES                       |
  16910.      | have_ssl                | NO                        |
  16911.      | init_file               |                           |
  16912.      | interactive_timeout     | 28800                     |
  16913.      | join_buffer_size        | 131072                    |
  16914.      | key_buffer_size         | 16776192                  |
  16915.      | language                | /my/monty/share/english/  |
  16916.      | large_files_support     | ON                        |
  16917.      | log                     | OFF                       |
  16918.      | log_update              | OFF                       |
  16919.      | log_bin                 | OFF                       |
  16920.      | log_slave_updates       | OFF                       |
  16921.      | long_query_time         | 10                        |
  16922.      | low_priority_updates    | OFF                       |
  16923.      | lower_case_table_names  | 0                         |
  16924.      | max_allowed_packet      | 1048576                   |
  16925.      | max_binlog_cache_size   | 4294967295                |
  16926.      | max_connections         | 100                       |
  16927.      | max_connect_errors      | 10                        |
  16928.      | max_delayed_threads     | 20                        |
  16929.      | max_heap_table_size     | 16777216                  |
  16930.      | max_join_size           | 4294967295                |
  16931.      | max_sort_length         | 1024                      |
  16932.      | max_tmp_tables          | 32                        |
  16933.      | max_write_lock_count    | 4294967295                |
  16934.      | myisam_recover_options  | DEFAULT                   |
  16935.      | myisam_sort_buffer_size | 8388608                   |
  16936.      | net_buffer_length       | 16384                     |
  16937.      | net_read_timeout        | 30                        |
  16938.      | net_retry_count         | 10                        |
  16939.      | net_write_timeout       | 60                        |
  16940.      | open_files_limit        | 0                         |
  16941.      | pid_file                | /my/monty/data/donna.pid  |
  16942.      | port                    | 3306                      |
  16943.      | protocol_version        | 10                        |
  16944.      | record_buffer           | 131072                    |
  16945.      | query_buffer_size       | 0                         |
  16946.      | safe_show_database      | OFF                       |
  16947.      | server_id               | 0                         |
  16948.      | skip_locking            | ON                        |
  16949.      | skip_networking         | OFF                       |
  16950.      | skip_show_database      | OFF                       |
  16951.      | slow_launch_time        | 2                         |
  16952.      | socket                  | /tmp/mysql.sock           |
  16953.      | sort_buffer             | 2097116                   |
  16954.      | table_cache             | 64                        |
  16955.      | table_type              | MYISAM                    |
  16956.      | thread_cache_size       | 4                         |
  16957.      | thread_stack            | 65536                     |
  16958.      | tmp_table_size          | 1048576                   |
  16959.      | tmpdir                  | /tmp/                     |
  16960.      | version                 | 3.23.29a-gamma-debug      |
  16961.      | wait_timeout            | 28800                     |
  16962.      +-------------------------+---------------------------+
  16963.  
  16964. Each option is described below. Values for buffer sizes, lengths, and
  16965. stack sizes are given in bytes.  You can specify values with a suffix
  16966. of `K' or `M' to indicate kilobytes or megabytes. For example, `16M'
  16967. indicates 16 megabytes.  The case of suffix letters does not matter;
  16968. `16M' and `16m' are equivalent:
  16969.  
  16970. ``ansi_mode'.'
  16971.      Is `ON' if `mysqld' was started with `--ansi'.  *Note ANSI mode::.
  16972.  
  16973. ``back_log''
  16974.      The number of outstanding connection requests MySQL can have. This
  16975.      comes into play when the main MySQL thread gets *VERY* many
  16976.      connection requests in a very short time. It then takes some time
  16977.      (although very little) for the main thread to check the connection
  16978.      and start a new thread. The `back_log' value indicates how many
  16979.      requests can be stacked during this short time before MySQL
  16980.      momentarily stops answering new requests. You need to increase
  16981.      this only if you expect a large number of connections in a short
  16982.      period of time.
  16983.  
  16984.      In other words, this value is the size of the listen queue for
  16985.      incoming TCP/IP connections.  Your operating system has its own
  16986.      limit on the size of this queue.  The manual page for the Unix
  16987.      `listen(2)' system call should have more details.  Check your OS
  16988.      documentation for the maximum value for this variable.  Attempting
  16989.      to set `back_log' higher than your operating system limit will be
  16990.      ineffective.
  16991.  
  16992. ``basedir''
  16993.      The value of the `--basedir' option.
  16994.  
  16995. ``bdb_cache_size''
  16996.      The buffer that is allocated to cache index and rows for `BDB'
  16997.      tables.  If you don't use `BDB' tables, you should start `mysqld'
  16998.      with `--skip-bdb' to not waste memory for this cache.
  16999.  
  17000. ``bdb_log_buffer_size''
  17001.      The buffer that is allocated to cache index and rows for `BDB'
  17002.      tables.  If you don't use `BDB' tables, you should set this to 0 or
  17003.      start `mysqld' with `--skip-bdb' to not waste memory for this
  17004.      cache.
  17005.  
  17006. ``bdb_home''
  17007.      The value of the `--bdb-home' option.
  17008.  
  17009. ``bdb_max_lock''
  17010.      The maximum number of locks (1000 by default) you can have active
  17011.      on a BDB table. You should increase this if you get errors of type
  17012.      `bdb: Lock table is out of available locks' or `Got error 12 from
  17013.      ...' when you have do long transactions or when `mysqld' has to
  17014.      examine a lot of rows to calculate the query.
  17015.  
  17016. ``bdb_logdir''
  17017.      The value of the `--bdb-logdir' option.
  17018.  
  17019. ``bdb_shared_data''
  17020.      Is `ON' if you are using `--bdb-shared-data'.
  17021.  
  17022. ``bdb_tmpdir''
  17023.      The value of the `--bdb-tmpdir' option.
  17024.  
  17025. ``binlog_cache_size'.  The size of the cache to hold the SQL'
  17026.      statements for the binary log during a transaction.  If you often
  17027.      use big, multi-statement transactions you can increase this to get
  17028.      more performance. *Note COMMIT::.
  17029.  
  17030. ``character_set''
  17031.      The default character set.
  17032.  
  17033. ``character_sets''
  17034.      The supported character sets.
  17035.  
  17036. ``concurrent_inserts''
  17037.      If `ON' (the default), MySQL will allow you to use `INSERT' on
  17038.      `MyISAM' tables at the same time as you run `SELECT' queries on
  17039.      them.  You can turn this option off by starting `mysqld' with
  17040.      `--safe' or `--skip-new'.
  17041.  
  17042. ``connect_timeout''
  17043.      The number of seconds the `mysqld' server is waiting for a connect
  17044.      packet before responding with `Bad handshake'.
  17045.  
  17046. ``datadir''
  17047.      The value of the `--datadir' option.
  17048.  
  17049. ``delay_key_write''
  17050.      If enabled (is on by default), MySQL will honor the
  17051.      `delay_key_write' option `CREATE TABLE'.  This means that the key
  17052.      buffer for tables with this option will not get flushed on every
  17053.      index update, but only when a table is closed.  This will speed up
  17054.      writes on keys a lot, but you should add automatic checking of all
  17055.      tables with `myisamchk --fast --force' if you use this.  Note that
  17056.      if you start `mysqld' with the `--delay-key-write-for-all-tables'
  17057.      option this means that all tables will be treated as if they were
  17058.      created with the `delay_key_write' option.  You can clear this flag
  17059.      by starting `mysqld' with `--skip-new' or `--safe-mode'.
  17060.  
  17061. ``delayed_insert_limit''
  17062.      After inserting `delayed_insert_limit' rows, the `INSERT DELAYED'
  17063.      handler will check if there are any `SELECT' statements pending.
  17064.      If so, it allows these to execute before continuing.
  17065.  
  17066. ``delayed_insert_timeout''
  17067.      How long a `INSERT DELAYED' thread should wait for `INSERT'
  17068.      statements before terminating.
  17069.  
  17070. ``delayed_queue_size''
  17071.      What size queue (in rows) should be allocated for handling `INSERT
  17072.      DELAYED'.  If the queue becomes full, any client that does `INSERT
  17073.      DELAYED' will wait until there is room in the queue again.
  17074.  
  17075. ``flush''
  17076.      This is `ON' if you have started MySQL with the `--flush' option.
  17077.  
  17078. ``flush_time''
  17079.      If this is set to a non-zero value, then every `flush_time'
  17080.      seconds all tables will be closed (to free up resources and sync
  17081.      things to disk). We only recommend this option on Win95, Win98, or
  17082.      on systems where you have very little resources.
  17083.  
  17084. ``have_bdb''
  17085.      `YES' if `mysqld' supports Berkeley DB tables. `DISABLED' if
  17086.      `--skip-bdb' is used.
  17087.  
  17088. ``have_innodb''
  17089.      `YES' if `mysqld' supports InnoDB tables. `DISABLED' if
  17090.      `--skip-innodb' is used.
  17091.  
  17092. ``have_raid''
  17093.      `YES' if `mysqld' supports the `RAID' option.
  17094.  
  17095. ``have_ssl''
  17096.      `YES' if `mysqld' supports SSL (encryption) on the client/server
  17097.      protocol.
  17098.  
  17099. ``init_file''
  17100.      The name of the file specified with the `--init-file' option when
  17101.      you start the server.  This is a file of SQL statements you want
  17102.      the server to execute when it starts.
  17103.  
  17104. ``interactive_timeout''
  17105.      The number of seconds the server waits for activity on an
  17106.      interactive connection before closing it.  An interactive client
  17107.      is defined as a client that uses the `CLIENT_INTERACTIVE' option to
  17108.      `mysql_real_connect()'.  See also `wait_timeout'.
  17109.  
  17110. ``join_buffer_size''
  17111.      The size of the buffer that is used for full joins (joins that do
  17112.      not use indexes).  The buffer is allocated one time for each full
  17113.      join between two tables. Increase this value to get a faster full
  17114.      join when adding indexes is not possible. (Normally the best way
  17115.      to get fast joins is to add indexes.)
  17116.  
  17117. ``key_buffer_size''
  17118.      Index blocks are buffered and are shared by all threads.
  17119.      `key_buffer_size' is the size of the buffer used for index blocks.
  17120.  
  17121.      Increase this to get better index handling (for all reads and
  17122.      multiple writes) to as much as you can afford; 64M on a 256M
  17123.      machine that mainly runs MySQL is quite common.  If you, however,
  17124.      make this too big (more than 50% of your total memory?) your
  17125.      system may start to page and become REALLY slow. Remember that
  17126.      because MySQL does not cache data read, that you will have to
  17127.      leave some room for the OS filesystem cache.
  17128.  
  17129.      You can check the performance of the key buffer by doing `show
  17130.      status' and examine the variables `Key_read_requests',
  17131.      `Key_reads', `Key_write_requests', and `Key_writes'.  The
  17132.      `Key_reads/Key_read_request' ratio should normally be < 0.01.  The
  17133.      `Key_write/Key_write_requests' is usually near 1 if you are using
  17134.      mostly updates/deletes but may be much smaller if you tend to do
  17135.      updates that affect many at the same time or if you are using
  17136.      `delay_key_write'. *Note SHOW::.
  17137.  
  17138.      To get even more speed when writing many rows at the same time, use
  17139.      `LOCK TABLES'.  *Note `LOCK TABLES': LOCK TABLES.
  17140.  
  17141. ``language''
  17142.      The language used for error messages.
  17143.  
  17144. ``large_file_support''
  17145.      If `mysqld' was compiled with options for big file support.
  17146.  
  17147. ``locked_in_memory''
  17148.      If `mysqld' was locked in memory with `--memlock'
  17149.  
  17150. ``log''
  17151.      If logging of all queries is enabled.
  17152.  
  17153. ``log_update''
  17154.      If the update log is enabled.
  17155.  
  17156. ``log_bin''
  17157.      If the binary log is enabled.
  17158.  
  17159. ``log_slave_updates''
  17160.      If the updates from the slave should be logged.
  17161.  
  17162. ``long_query_time''
  17163.      If a query takes longer than this (in seconds), the `Slow_queries'
  17164.      counter will be incremented. If you are using
  17165.      `--log-slow-queries', the query will be logged to the slow query
  17166.      logfile. *Note Slow query log::.
  17167.  
  17168. ``lower_case_table_names''
  17169.      If set to 1 table names are stored in lowercase on disk and table
  17170.      names will be case-insensitive.  *Note Name case sensitivity::.
  17171.  
  17172. ``max_allowed_packet''
  17173.      The maximum size of one packet. The message buffer is initialized
  17174.      to `net_buffer_length' bytes, but can grow up to
  17175.      `max_allowed_packet' bytes when needed.  This value by default is
  17176.      small, to catch big (possibly wrong) packets.  You must increase
  17177.      this value if you are using big `BLOB' columns. It should be as
  17178.      big as the biggest `BLOB' you want to use.  The current protocol
  17179.      limits `max_allowed_packet' to 16M.
  17180.  
  17181. ``max_binlog_cache_size''
  17182.      If a multi-statement transaction requires more than this amount of
  17183.      memory, one will get the error "Multi-statement transaction
  17184.      required more than 'max_binlog_cache_size' bytes of storage".
  17185.  
  17186. ``max_binlog_size''
  17187.      Available after 3.23.33. If a write to the binary (replication)
  17188.      log exceeds the given value, rotate the logs. You cannot set it to
  17189.      less than 1024 bytes, or more than 1 GB. Default is 1 GB.
  17190.  
  17191. ``max_connections''
  17192.      The number of simultaneous clients allowed. Increasing this value
  17193.      increases the number of file descriptors that `mysqld' requires.
  17194.      See below for comments on file descriptor limits. *Note Too many
  17195.      connections::.
  17196.  
  17197. ``max_connect_errors''
  17198.      If there is more than this number of interrupted connections from
  17199.      a host this host will be blocked from further connections.  You
  17200.      can unblock a host with the command `FLUSH HOSTS'.
  17201.  
  17202. ``max_delayed_threads''
  17203.      Don't start more than this number of threads to handle `INSERT
  17204.      DELAYED' statements.  If you try to insert data into a new table
  17205.      after all `INSERT DELAYED' threads are in use, the row will be
  17206.      inserted as if the `DELAYED' attribute wasn't specified.
  17207.  
  17208. ``max_heap_table_size''
  17209.      Don't allow creation of heap tables bigger than this.
  17210.  
  17211. ``max_join_size''
  17212.      Joins that are probably going to read more than `max_join_size'
  17213.      records return an error. Set this value if your users tend to
  17214.      perform joins that lack a `WHERE' clause, that take a long time,
  17215.      and that return millions of rows.
  17216.  
  17217. ``max_sort_length''
  17218.      The number of bytes to use when sorting `BLOB' or `TEXT' values
  17219.      (only the first `max_sort_length' bytes of each value are used;
  17220.      the rest are ignored).
  17221.  
  17222. ``max_user_connections''
  17223.      The maximum number of active connections for a single user (0 = no
  17224.      limit).
  17225.  
  17226. ``max_tmp_tables''
  17227.      (This option doesn't yet do anything.)  Maximum number of
  17228.      temporary tables a client can keep open at the same time.
  17229.  
  17230. ``max_write_lock_count''
  17231.      After this many write locks, allow some read locks to run in
  17232.      between.
  17233.  
  17234. ``myisam_recover_options''
  17235.      The value of the `--myisam-recover' option.
  17236.  
  17237. ``myisam_sort_buffer_size''
  17238.      The buffer that is allocated when sorting the index when doing a
  17239.      `REPAIR' or when creating indexes with `CREATE INDEX' or `ALTER
  17240.      TABLE'.
  17241.  
  17242. ``myisam_max_extra_sort_file_size'.'
  17243.      If the creating of the temporary file for fast index creation
  17244.      would be this much bigger than using the key cache, then prefer
  17245.      the key cache method.  This is mainly used to force long character
  17246.      keys in large tables to use the slower key cache method to create
  17247.      the index.  *NOTE* that this parameter is given in megabytes!
  17248.  
  17249. ``myisam_max_sort_file_size''
  17250.      The maximum size of the temporary file MySQL is allowed to use
  17251.      while recreating the index (during `REPAIR', `ALTER TABLE' or
  17252.      `LOAD DATA INFILE'.  If the file size would be bigger than this,
  17253.      the index will be created through the key cache (which is slower).
  17254.      *NOTE* that this parameter is given in megabytes!
  17255.  
  17256. ``net_buffer_length''
  17257.      The communication buffer is reset to this size between queries.
  17258.      This should not normally be changed, but if you have very little
  17259.      memory, you can set it to the expected size of a query.  (That is,
  17260.      the expected length of SQL statements sent by clients.  If
  17261.      statements exceed this length, the buffer is automatically
  17262.      enlarged, up to `max_allowed_packet' bytes.)
  17263.  
  17264. ``net_read_timeout''
  17265.      Number of seconds to wait for more data from a connection before
  17266.      aborting the read.  Note that when we don't expect data from a
  17267.      connection, the timeout is defined by `write_timeout'. See also
  17268.      `slave_read_timeout'.
  17269.  
  17270. ``net_retry_count''
  17271.      If a read on a communication port is interrupted, retry this many
  17272.      times before giving up.  This value should be quite high on
  17273.      `FreeBSD' as internal interrupts are sent to all threads.
  17274.  
  17275. ``net_write_timeout''
  17276.      Number of seconds to wait for a block to be written to a
  17277.      connection before aborting the write.
  17278.  
  17279. ``open_files_limit''
  17280.      If this is not 0, then `mysqld' will use this value to reserve file
  17281.      descriptors to use with `setrlimit()'.  If this value is 0 then
  17282.      `mysqld' will reserve `max_connections*5' or `max_connections +
  17283.      table_cache*2' (whichever is larger) number of files.  You should
  17284.      try increasing this if `mysqld' gives you the error 'Too many open
  17285.      files'.
  17286.  
  17287. ``pid_file''
  17288.      The value of the `--pid-file' option.
  17289.  
  17290. ``port''
  17291.      The value of the `--port' option.
  17292.  
  17293. ``protocol_version''
  17294.      The protocol version used by the MySQL server.
  17295.  
  17296. ``record_buffer''
  17297.      Each thread that does a sequential scan allocates a buffer of this
  17298.      size for each table it scans. If you do many sequential scans, you
  17299.      may want to increase this value.
  17300.  
  17301. ``record_rnd_buffer''
  17302.      When reading rows in sorted order after a sort, the rows are read
  17303.      through this buffer to avoid a disk seeks.  If not set, then it's
  17304.      set to the value of `record_buffer'.
  17305.  
  17306. ``query_buffer_size''
  17307.      The initial allocation of the query buffer. If most of your
  17308.      queries are long (like when inserting blobs), you should increase
  17309.      this!
  17310.  
  17311. ``safe_show_databases''
  17312.      Don't show databases for which the user doesn't have any database
  17313.      or table privileges. This can improve security if you're concerned
  17314.      about people being able to see what databases other users have.
  17315.      See also `skip_show_databases'.
  17316.  
  17317. ``server_id''
  17318.      The value of the `--server-id' option.
  17319.  
  17320. ``skip_locking''
  17321.      Is OFF if `mysqld' uses external locking.
  17322.  
  17323. ``skip_networking''
  17324.      Is ON if we only allow local (socket) connections.
  17325.  
  17326. ``skip_show_databases''
  17327.      This prevents people from doing `SHOW DATABASES' if they don't have
  17328.      the `PROCESS_PRIV' privilege. This can improve security if you're
  17329.      concerned about people being able to see what databases other users
  17330.      have. See also `safe_show_databases'.
  17331.  
  17332. ``slave_read_timeout''
  17333.      Number of seconds to wait for more data from a master/slave
  17334.      connection before aborting the read.
  17335.  
  17336. ``slow_launch_time''
  17337.      If creating the thread takes longer than this value (in seconds),
  17338.      the `Slow_launch_threads' counter will be incremented.
  17339.  
  17340. ``socket''
  17341.      The Unix socket used by the server.
  17342.  
  17343. ``sort_buffer''
  17344.      Each thread that needs to do a sort allocates a buffer of this
  17345.      size. Increase this value for faster `ORDER BY' or `GROUP BY'
  17346.      operations.  *Note Temporary files::.
  17347.  
  17348. ``table_cache''
  17349.      The number of open tables for all threads. Increasing this value
  17350.      increases the number of file descriptors that `mysqld' requires.
  17351.      MySQL needs two file descriptors for each unique open table.  See
  17352.      below for comments on file descriptor limits. You can check if you
  17353.      need to increase the table cache by checking the `Opened_tables'
  17354.      variable. *Note SHOW::.  If this variable is big and you don't do
  17355.      `FLUSH TABLES' a lot (which just forces all tables to be closed and
  17356.      reopenend), then you should increase the value of this variable.
  17357.  
  17358.      Make sure that your operating system can handle the number of open
  17359.      file descriptors implied by the `table_cache' setting.  If
  17360.      `table_cache' is set too high, MySQL may run out of file
  17361.      descriptors and refuse connections, fail to perform queries, and
  17362.      be very unreliable.
  17363.  
  17364.      For information about how the table cache works, see *Note Table
  17365.      cache::.
  17366.  
  17367. ``table_type''
  17368.      The default table type
  17369.  
  17370. ``thread_cache_size''
  17371.      How many threads we should keep in a cache for reuse.  When a
  17372.      client disconnects, the client's threads are put in the cache if
  17373.      there aren't more than `thread_cache_size' threads from before.
  17374.      All new threads are first taken from the cache, and only when the
  17375.      cache is empty is a new thread created.  This variable can be
  17376.      increased to improve performance if you have a lot of new
  17377.      connections. (Normally this doesn't give a notable performance
  17378.      improvement if you have a good thread implementation.)  By examing
  17379.      the difference between the `Connections' and `Threads_created' you
  17380.      can see how efficient the current thread cache is for you.
  17381.  
  17382. ``thread_concurrency''
  17383.      On Solaris, `mysqld' will call `thr_setconcurrency()' with this
  17384.      value.  `thr_setconcurrency()' permits the application to give the
  17385.      threads system a hint for the desired number of threads that should
  17386.      be run at the same time.
  17387.  
  17388. ``thread_stack''
  17389.      The stack size for each thread.  Many of the limits detected by the
  17390.      `crash-me' test are dependent on this value. The default is large
  17391.      enough for normal operation.  *Note MySQL Benchmarks::.
  17392.  
  17393. ``timezone''
  17394.      The timezone for the server.
  17395.  
  17396. ``tmp_table_size''
  17397.      If an in-memory temporary table exceeds this size, MySQL will
  17398.      automatically convert it to an on-disk `MyISAM' table.  Increase
  17399.      the value of `tmp_table_size' if you do many advanced `GROUP BY'
  17400.      queries and you have lots of memory.
  17401.  
  17402. ``tmpdir''
  17403.      The directory used for temporary files and temporary tables.
  17404.  
  17405. ``version''
  17406.      The version number for the server.
  17407.  
  17408. ``wait_timeout''
  17409.      The number of seconds the server waits for activity on a
  17410.      connection before closing it. See also `interactive_timeout'.
  17411.  
  17412. The manual section that describes tuning MySQL contains some
  17413. information of how to tune the above variables. *Note Server
  17414. parameters::.
  17415.  
  17416. 
  17417. File: mysql.info,  Node: SHOW LOGS,  Next: SHOW PROCESSLIST,  Prev: SHOW VARIABLES,  Up: SHOW
  17418.  
  17419. `SHOW LOGS'
  17420. ...........
  17421.  
  17422. `SHOW LOGS' shows you status information about existing log files.  It
  17423. currently only displays information about Berkeley DB log files.
  17424.  
  17425.    * `File' shows the full path to the log file
  17426.  
  17427.    * `Type' shows the type of the log file (`BDB' for Berkeley DB log
  17428.      files)
  17429.  
  17430.    * `Status' shows the status of the log file (`FREE' if the file can
  17431.      be removed, or `IN USE' if the file is needed by the transaction
  17432.      subsystem)
  17433.  
  17434. 
  17435. File: mysql.info,  Node: SHOW PROCESSLIST,  Next: SHOW GRANTS,  Prev: SHOW LOGS,  Up: SHOW
  17436.  
  17437. `SHOW PROCESSLIST'
  17438. ..................
  17439.  
  17440. `SHOW PROCESSLIST' shows you which threads are running.  You can also
  17441. get this information using the `mysqladmin processlist' command.  If
  17442. you have the *process* privilege, you can see all threads.  Otherwise,
  17443. you can see only your own threads.  *Note `KILL': KILL.  If you don't
  17444. use the `FULL' option, then only the first 100 characters of each query
  17445. will be shown.
  17446.  
  17447. This command is very useful if you get the 'too many connections' error
  17448. message and want to find out what's going on. MySQL reserves one extra
  17449. connection for a client with the `Process_priv' privilege to ensure
  17450. that you should always be able to login and check the system (assuming
  17451. you are not giving this privilege to all your users).
  17452.  
  17453. 
  17454. File: mysql.info,  Node: SHOW GRANTS,  Next: SHOW CREATE TABLE,  Prev: SHOW PROCESSLIST,  Up: SHOW
  17455.  
  17456. `SHOW GRANTS'
  17457. .............
  17458.  
  17459. `SHOW GRANTS FOR user' lists the grant commands that must be issued to
  17460. duplicate the grants for a user.
  17461.  
  17462.      mysql> SHOW GRANTS FOR root@localhost;
  17463.      +---------------------------------------------------------------------+
  17464.      | Grants for root@localhost                                           |
  17465.      +---------------------------------------------------------------------+
  17466.      | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
  17467.      +---------------------------------------------------------------------+
  17468.  
  17469. 
  17470. File: mysql.info,  Node: SHOW CREATE TABLE,  Prev: SHOW GRANTS,  Up: SHOW
  17471.  
  17472. `SHOW CREATE TABLE'
  17473. ...................
  17474.  
  17475. Shows a `CREATE TABLE' statement that will create the given table:
  17476.  
  17477.      mysql> show create table t\G
  17478.      *************************** 1. row ***************************
  17479.             Table: t
  17480.      Create Table: CREATE TABLE t (
  17481.        id int(11) default NULL auto_increment,
  17482.        s char(60) default NULL,
  17483.        PRIMARY KEY (id)
  17484.      ) TYPE=MyISAM
  17485.  
  17486. `SHOW CREATE TABLE' will quote table and column names according to
  17487. `SQL_QUOTE_SHOW_CREATE' option.  *Note `SET OPTION
  17488. SQL_QUOTE_SHOW_CREATE': SET OPTION.
  17489.  
  17490. 
  17491. File: mysql.info,  Node: Localization,  Next: Server-Side Scripts,  Prev: Database Administration,  Up: MySQL Database Administration
  17492.  
  17493. MySQL Localization and International Usage
  17494. ==========================================
  17495.  
  17496. * Menu:
  17497.  
  17498. * Character sets::              The Character Set Used for Data and Sorting
  17499. * Languages::                   Non-English Error Messages
  17500. * Adding character set::        Adding a New Character Set
  17501. * Character arrays::            The character definition arrays
  17502. * String collating::            String Collating Support
  17503. * Multi-byte characters::       Multi-byte Character Support
  17504.  
  17505. 
  17506. File: mysql.info,  Node: Character sets,  Next: Languages,  Prev: Localization,  Up: Localization
  17507.  
  17508. The Character Set Used for Data and Sorting
  17509. -------------------------------------------
  17510.  
  17511. By default, MySQL uses the ISO-8859-1 (Latin1) character set with
  17512. sorting according to Swedish/Finnish. This is the character set suitable
  17513. in the USA and western Europe.
  17514.  
  17515. All standard MySQL binaries are compiled with
  17516. `--with-extra-charsets=complex'.  This will add code to all standard
  17517. programs to be able to handle `latin1' and all multi-byte character
  17518. sets within the binary. Other character sets will be loaded from a
  17519. character-set definition file when needed.
  17520.  
  17521. The character set determines what characters are allowed in names and
  17522. how things are sorted by the `ORDER BY' and `GROUP BY' clauses of the
  17523. `SELECT' statement.
  17524.  
  17525. You can change the character set with the `--default-character-set'
  17526. option when you start the server.  The character sets available depend
  17527. on the `--with-charset=charset' and `--with-extra-charset=
  17528. list-of-charset | complex | all' options to `configure', and the
  17529. character set configuration files listed in `SHAREDIR/charsets/Index'.
  17530. *Note configure options::.
  17531.  
  17532. If you change the character set when running MySQL (which may also
  17533. change the sort order), you must run myisamchk -r -q on all tables.
  17534. Otherwise your indexes may not be ordered correctly.
  17535.  
  17536. When a client connects to a MySQL server, the server sends the default
  17537. character set in use to the client.  The client will switch to use this
  17538. character set for this connection.
  17539.  
  17540. One should use `mysql_real_escape_string()' when escaping strings for a
  17541. SQL query.  `mysql_real_escape_string()' is identical to the old
  17542. `mysql_escape_string()' function, except that it takes the MYSQL
  17543. connection handle as the first parameter.
  17544.  
  17545. If the client is compiled with different paths than where the server is
  17546. installed and the user who configured MySQL didn't included all
  17547. character sets in the MySQL binary, one must specify for the client
  17548. where it can find the additional character sets it will need if the
  17549. server runs with a different character set than the client.
  17550.  
  17551. One can specify this by putting in a MySQL option file:
  17552.  
  17553.      [client]
  17554.      character-sets-dir=/usr/local/mysql/share/mysql/charsets
  17555.  
  17556. where the path points to where the dynamic MySQL character sets are
  17557. stored.
  17558.  
  17559. One can force the client to use specific character set by specifying:
  17560.  
  17561.      [client]
  17562.      default-character-set=character-set-name
  17563.  
  17564. but normally this is never needed.
  17565.  
  17566. 
  17567. File: mysql.info,  Node: Languages,  Next: Adding character set,  Prev: Character sets,  Up: Localization
  17568.  
  17569. Non-English Error Messages
  17570. --------------------------
  17571.  
  17572. `mysqld' can issue error messages in the following languages: Czech,
  17573. Danish, Dutch, English (the default), Estonian, French, German, Greek,
  17574. Hungarian, Italian, Japanese, Korean, Norwegian, Norwegian-ny, Polish,
  17575. Portuguese, Romanian, Russian, Slovak, Spanish, and Swedish.
  17576.  
  17577. To start `mysqld' with a particular language, use either the
  17578. `--language=lang' or `-L lang' options. For example:
  17579.  
  17580.      shell> mysqld --language=swedish
  17581.  
  17582. or:
  17583.  
  17584.      shell> mysqld --language=/usr/local/share/swedish
  17585.  
  17586. Note that all language names are specified in lowercase.
  17587.  
  17588. The language files are located (by default) in
  17589. `MYSQL_BASE_DIR/share/LANGUAGE/'.
  17590.  
  17591. To update the error message file, you should edit the `errmsg.txt' file
  17592. and execute the following command to generate the `errmsg.sys' file:
  17593.  
  17594.      shell> comp_err errmsg.txt errmsg.sys
  17595.  
  17596. If you upgrade to a newer version of MySQL, remember to repeat your
  17597. changes with the new `errmsg.txt' file.
  17598.  
  17599. 
  17600. File: mysql.info,  Node: Adding character set,  Next: Character arrays,  Prev: Languages,  Up: Localization
  17601.  
  17602. Adding a New Character Set
  17603. --------------------------
  17604.  
  17605. To add another character set to MySQL, use the following procedure.
  17606.  
  17607. Decide if the set is simple or complex.  If the character set does not
  17608. need to use special string collating routines for sorting and does not
  17609. need multi-byte character support, it is simple.  If it needs either of
  17610. those features, it is complex.
  17611.  
  17612. For example, `latin1' and `danish' are simple charactersets while
  17613. `big5' or `czech' are complex character sets.
  17614.  
  17615. In the following section, we have assumed that you name your character
  17616. set `MYSET'.
  17617.  
  17618. For a simple character set do the following:
  17619.  
  17620.   1. Add MYSET to the end of the `sql/share/charsets/Index' file Assign
  17621.      an unique number to it.
  17622.  
  17623.   2. Create the file `sql/share/charsets/MYSET.conf'.  (You can use
  17624.      `sql/share/charsets/latin1.conf' as a base for this).
  17625.  
  17626.      The syntax for the file very simple:
  17627.  
  17628.         * Comments start with a '#' character and proceed to the end of
  17629.           the line.
  17630.  
  17631.         * Words are separated by arbitrary amounts of whitespace.
  17632.  
  17633.         * When defining the character set, every word must be a number
  17634.           in hexadecimal format
  17635.  
  17636.         * The `ctype' array takes up the first 257 words. The
  17637.           `to_lower', `to_upper' and `sort_order' arrays take up 256
  17638.           words each after that.
  17639.  
  17640.      *Note Character arrays::.
  17641.  
  17642.   3. Add the character set name to the `CHARSETS_AVAILABLE' and
  17643.      `COMPILED_CHARSETS' lists in `configure.in'.
  17644.  
  17645.   4. Reconfigure, recompile, and test.
  17646.  
  17647.  
  17648. For a complex character set do the following:
  17649.  
  17650.   1. Create the file `strings/ctype-MYSET.c' in the MySQL source
  17651.      distribution.
  17652.  
  17653.   2. Add MYSET to the end of the `sql/share/charsets/Index' file.
  17654.      Assign an unique number to it.
  17655.  
  17656.   3. Look at one of the existing `ctype-*.c' files to see what needs to
  17657.      be defined, for example `strings/ctype-big5.c'. Note that the
  17658.      arrays in your file must have names like `ctype_MYSET',
  17659.      `to_lower_MYSET', and so on.  This corresponds to the arrays in
  17660.      the simple character set. *Note Character arrays::.  For a complex
  17661.      character set
  17662.  
  17663.   4. Near the top of the file, place a special comment like this:
  17664.  
  17665.           /*
  17666.            * This comment is parsed by configure to create ctype.c,
  17667.            * so don't change it unless you know what you are doing.
  17668.            *
  17669.            * .configure. number_MYSET=MYNUMBER
  17670.            * .configure. strxfrm_multiply_MYSET=N
  17671.            * .configure. mbmaxlen_MYSET=N
  17672.            */
  17673.  
  17674.      The `configure' program uses this comment to include the character
  17675.      set into the MySQL library automatically.
  17676.  
  17677.      The strxfrm_multiply and mbmaxlen lines will be explained in the
  17678.      following sections.  Only include them if you the string collating
  17679.      functions or the multi-byte character set functions, respectively.
  17680.  
  17681.   5. You should then create some of the following functions:
  17682.  
  17683.         * `my_strncoll_MYSET()'
  17684.  
  17685.         * `my_strcoll_MYSET()'
  17686.  
  17687.         * `my_strxfrm_MYSET()'
  17688.  
  17689.         * `my_like_range_MYSET()'
  17690.  
  17691.      *Note String collating::.
  17692.  
  17693.   6. Add the character set name to the `CHARSETS_AVAILABLE' and
  17694.      `COMPILED_CHARSETS' lists in `configure.in'.
  17695.  
  17696.   7. Reconfigure, recompile, and test.
  17697.  
  17698. The file `sql/share/charsets/README' includes some more instructions.
  17699.  
  17700. If you want to have the character set included in the MySQL
  17701. distribution, mail a patch to <internals@lists.mysql.com>.
  17702.  
  17703. 
  17704. File: mysql.info,  Node: Character arrays,  Next: String collating,  Prev: Adding character set,  Up: Localization
  17705.  
  17706. The character definition arrays
  17707. -------------------------------
  17708.  
  17709. `to_lower[]' and `to_upper[]' are simple arrays that hold the lowercase
  17710. and uppercase characters corresponding to each member of the character
  17711. set.  For example:
  17712.  
  17713.      to_lower['A'] should contain 'a'
  17714.      to_upper['a'] should contain 'A'
  17715.  
  17716. `sort_order[]' is a map indicating how characters should be ordered for
  17717. comparison and sorting purposes.  For many character sets, this is the
  17718. same as `to_upper[]' (which means sorting will be case insensitive).
  17719. MySQL will sort characters based on the value of
  17720. `sort_order[character]'.  For more complicated sorting rules, see the
  17721. discussion of string collating below. *Note String collating::.
  17722.  
  17723. `ctype[]' is an array of bit values, with one element for one character.
  17724. (Note that `to_lower[]', `to_upper[]', and `sort_order[]' are indexed
  17725. by character value, but `ctype[]' is indexed by character value + 1.
  17726. This is an old legacy to be able to handle EOF.)
  17727.  
  17728. You can find the following bitmask definitions in `m_ctype.h':
  17729.  
  17730.      #define _U      01      /* Uppercase */
  17731.      #define _L      02      /* Lowercase */
  17732.      #define _N      04      /* Numeral (digit) */
  17733.      #define _S      010     /* Spacing character */
  17734.      #define _P      020     /* Punctuation */
  17735.      #define _C      040     /* Control character */
  17736.      #define _B      0100    /* Blank */
  17737.      #define _X      0200    /* heXadecimal digit */
  17738.  
  17739. The `ctype[]' entry for each character should be the union of the
  17740. applicable bitmask values that describe the character.  For example,
  17741. `'A'' is an uppercase character (`_U') as well as a hexadecimal digit
  17742. (`_X'), so `ctype['A'+1]' should contain the value:
  17743.  
  17744.      _U + _X = 01 + 0200 = 0201
  17745.  
  17746. 
  17747. File: mysql.info,  Node: String collating,  Next: Multi-byte characters,  Prev: Character arrays,  Up: Localization
  17748.  
  17749. String Collating Support
  17750. ------------------------
  17751.  
  17752. If the sorting rules for your language are too complex to be handled
  17753. with the simple `sort_order[]' table, you need to use the string
  17754. collating functions.
  17755.  
  17756. Right now the best documentation on this is the character sets that are
  17757. already implemented.  Look at the big5, czech, gbk, sjis, and tis160
  17758. character sets for examples.
  17759.  
  17760. You must specify the `strxfrm_multiply_MYSET=N' value in the special
  17761. comment at the top of the file.  `N' should be set to the maximum ratio
  17762. the strings may grow during `my_strxfrm_MYSET' (it must be a positive
  17763. integer).
  17764.  
  17765. 
  17766. File: mysql.info,  Node: Multi-byte characters,  Prev: String collating,  Up: Localization
  17767.  
  17768. Multi-byte Character Support
  17769. ----------------------------
  17770.  
  17771. If your want to add support for a new character set that includes
  17772. multi-byte characters, you need to use the multi-byte character
  17773. functions.
  17774.  
  17775. Right now the best documentation on this is the character sets that are
  17776. already implemented.  Look at the euc_kr, gb2312, gbk, sjis and ujis
  17777. character sets for examples. These are implemented in the
  17778. `ctype-'charset'.c' files in the `strings' directory.
  17779.  
  17780. You must specify the `mbmaxlen_MYSET=N' value in the special comment at
  17781. the top of the source file.  `N' should be set to the size in bytes of
  17782. the largest character in the set.
  17783.  
  17784. 
  17785. File: mysql.info,  Node: Server-Side Scripts,  Next: Client-Side Scripts,  Prev: Localization,  Up: MySQL Database Administration
  17786.  
  17787. MySQL Server-Side Scripts and Utilities
  17788. =======================================
  17789.  
  17790. * Menu:
  17791.  
  17792. * Server-Side Overview::        Overview of the Server-Side Scripts and Utilities
  17793. * safe_mysqld::                 safe_mysqld, the wrapper around mysqld
  17794. * mysqld_multi::                mysqld_multi, program for managing multiple MySQL servers
  17795. * myisampack::                  myisampack, The MySQL Compressed Read-only Table Generator
  17796. * mysqld-max::                  mysqld-max, An extended mysqld server
  17797.  
  17798. 
  17799. File: mysql.info,  Node: Server-Side Overview,  Next: safe_mysqld,  Prev: Server-Side Scripts,  Up: Server-Side Scripts
  17800.  
  17801. Overview of the Server-Side Scripts and Utilities
  17802. -------------------------------------------------
  17803.  
  17804. All MySQL clients that communicate with the server using the
  17805. `mysqlclient' library use the following environment variables:
  17806.  
  17807. *Name*             *Description*
  17808. `MYSQL_UNIX_PORT'  The default socket; used for connections to
  17809.                    `localhost'
  17810. `MYSQL_TCP_PORT'   The default TCP/IP port
  17811. `MYSQL_PWD'        The default password
  17812. `MYSQL_DEBUG'      Debug-trace options when debugging
  17813. `TMPDIR'           The directory where temporary tables/files are created
  17814.  
  17815. Use of `MYSQL_PWD' is insecure.  *Note Connecting::.
  17816.  
  17817. The `mysql' client uses the file named in the `MYSQL_HISTFILE'
  17818. environment variable to save the command-line history. The default
  17819. value for the history file is `$HOME/.mysql_history', where `$HOME' is
  17820. the value of the `HOME' environment variable. *Note Environment
  17821. variables::.
  17822.  
  17823. All MySQL programs take many different options. However, every MySQL
  17824. program provides a `--help' option that you can use to get a full
  17825. description of the program's different options. For example, try `mysql
  17826. --help'.
  17827.  
  17828. You can override default options for all standard client programs with
  17829. an option file. *Note Option files::.
  17830.  
  17831. The list below briefly describes the MySQL programs:
  17832.  
  17833. `myisamchk'
  17834.      Utility to describe, check, optimize, and repair MySQL tables.
  17835.      Because `myisamchk' has many functions, it is described in its own
  17836.      chapter. *Note MySQL Database Administration::.
  17837.  
  17838. `make_binary_distribution'
  17839.      Makes a binary release of a compiled MySQL. This could be sent by
  17840.      FTP to `/pub/mysql/Incoming' on `support.mysql.com' for the
  17841.      convenience of other MySQL users.
  17842.  
  17843. `msql2mysql'
  17844.      A shell script that converts `mSQL' programs to MySQL. It doesn't
  17845.      handle all cases, but it gives a good start when converting.
  17846.  
  17847. `mysqlaccess'
  17848.      A script that checks the access privileges for a host, user, and
  17849.      database combination.
  17850.  
  17851. `mysqladmin'
  17852.      Utility for performing administrative operations, such as creating
  17853.      or dropping databases, reloading the grant tables, flushing tables
  17854.      to disk, and reopening log files.  `mysqladmin' can also be used
  17855.      to retrieve version, process, and status information from the
  17856.      server.  *Note `mysqladmin': mysqladmin.
  17857.  
  17858. `mysqlbug'
  17859.      The MySQL bug report script.  This script should always be used
  17860.      when filing a bug report to the MySQL list.
  17861.  
  17862. `mysqld'
  17863.      The SQL daemon. This should always be running.
  17864.  
  17865. `mysqldump'
  17866.      Dumps a MySQL database into a file as SQL statements or as
  17867.      tab-separated text files. Enhanced freeware originally by Igor
  17868.      Romanenko.  *Note `mysqldump': mysqldump.
  17869.  
  17870. `mysqlimport'
  17871.      Imports text files into their respective tables using `LOAD DATA
  17872.      INFILE'. *Note `mysqlimport': mysqlimport.
  17873.  
  17874. `mysqlshow'
  17875.      Displays information about databases, tables, columns, and indexes.
  17876.  
  17877. `mysql_install_db'
  17878.      Creates the MySQL grant tables with default privileges. This is
  17879.      usually executed only once, when first installing MySQL on a
  17880.      system.
  17881.  
  17882. `replace'
  17883.      A utility program that is used by `msql2mysql', but that has more
  17884.      general applicability as well.  `replace' changes strings in place
  17885.      in files or on the standard input. Uses a finite state machine to
  17886.      match longer strings first. Can be used to swap strings. For
  17887.      example, this command swaps `a' and `b' in the given files:
  17888.  
  17889.           shell> replace a b b a -- file1 file2 ...
  17890.  
  17891. 
  17892. File: mysql.info,  Node: safe_mysqld,  Next: mysqld_multi,  Prev: Server-Side Overview,  Up: Server-Side Scripts
  17893.  
  17894. safe_mysqld, the wrapper around mysqld
  17895. --------------------------------------
  17896.  
  17897. `safe_mysqld' is the recommended way to start a `mysqld' daemon on
  17898. Unix.  `safe_mysqld' adds some safety features such as restarting the
  17899. server when an error occurs and logging run-time information to a log
  17900. file.
  17901.  
  17902. If you don't use `--mysqld=#' or `--mysqld-version=#' `safe_mysqld'
  17903. will use an executable named `mysqld-max' if it exists. If not,
  17904. `safe_mysqld' will start `mysqld'.  This makes it very easy to test to
  17905. use `mysqld-max' instead of `mysqld';  Just copy `mysqld-max' to where
  17906. you have `mysqld' and it will be used.
  17907.  
  17908. Normally one should never edit the `safe_mysqld' script, but instead
  17909. put the options to `safe_mysqld' in the `[safe_mysqld]' section in the
  17910. `my.cnf' file. `safe_mysqld' will read all options from the `[mysqld]',
  17911. `[server]' and `[safe_mysqld]' sections from the option files.  *Note
  17912. Option files::.
  17913.  
  17914. Note that all options on the command line to `safe_mysqld' are passed
  17915. to `mysqld'.  If you wants to use any options in `safe_mysqld' that
  17916. `mysqld' doesn't support, you must specify these in the option file.
  17917.  
  17918. Most of the options to `safe_mysqld' are the same as the options to
  17919. `mysqld'. *Note Command-line options::.
  17920.  
  17921. `safe_mysqld' supports the following options:
  17922.  
  17923. `--basedir=path'
  17924.  
  17925. `--core-file-size=#'
  17926.      Size of the core file `mysqld' should be able to create. Passed to
  17927.      `ulimit -c'.
  17928.  
  17929. `--datadir=path'
  17930.  
  17931. `--defaults-extra-file=path'
  17932.  
  17933. `--defaults-file=path'
  17934.  
  17935. `--err-log=path'
  17936.  
  17937. `--ledir=path'
  17938.      Path to `mysqld'
  17939.  
  17940. `--log=path'
  17941.  
  17942. `--mysqld=mysqld-version'
  17943.      Name of the `mysqld' version in the `ledir' directory you want to
  17944.      start.
  17945.  
  17946. `--mysqld-version=version'
  17947.      Similar to `--mysqld=' but here you only give the suffix for
  17948.      `mysqld'.  For example if you use `--mysqld-version=max',
  17949.      `safe_mysqld' will start the `ledir/mysqld-max' version.  If the
  17950.      argument to `--mysqld-version' is empty, `ledir/mysqld' will be
  17951.      used.
  17952.  
  17953. `--no-defaults'
  17954.  
  17955. `--open-files-limit=#'
  17956.      Number of files `mysqld' should be able to open. Passed to `ulimit
  17957.      -n'. Note that you need to start `safe_mysqld' as root for this to
  17958.      work properly!
  17959.  
  17960. `--pid-file=path'
  17961.  
  17962. `--port=#'
  17963.  
  17964. `--socket=path'
  17965.  
  17966. `--timezone=#'
  17967.      Set the timezone (the `TZ') variable to the value of this
  17968.      parameter.
  17969.  
  17970. `--user=#'
  17971. The `safe_mysqld' script is written so that it normally is able to start
  17972. a server that was installed from either a source or a binary version of
  17973. MySQL, even if these install the server in slightly different
  17974. locations.  `safe_mysqld' expects one of these conditions to be true:
  17975.  
  17976.    * The server and databases can be found relative to the directory
  17977.      from which `safe_mysqld' is invoked.  `safe_mysqld' looks under
  17978.      its working directory for `bin' and `data' directories (for binary
  17979.      distributions) or for `libexec' and `var' directories (for source
  17980.      distributions).  This condition should be met if you execute
  17981.      `safe_mysqld' from your MySQL installation directory (for example,
  17982.      `/usr/local/mysql' for a binary distribution).
  17983.  
  17984.    * If the server and databases cannot be found relative to the
  17985.      working directory, `safe_mysqld' attempts to locate them by
  17986.      absolute pathnames.  Typical locations are `/usr/local/libexec'
  17987.      and `/usr/local/var'.  The actual locations are determined when
  17988.      the distribution was built from which `safe_mysqld' comes.  They
  17989.      should be correct if MySQL was installed in a standard location.
  17990.  
  17991. Because `safe_mysqld' will try to find the server and databases relative
  17992. to its own working directory, you can install a binary distribution of
  17993. MySQL anywhere, as long as you start `safe_mysqld' from the MySQL
  17994. installation directory:
  17995.  
  17996.      shell> cd mysql_installation_directory
  17997.      shell> bin/safe_mysqld &
  17998.  
  17999. If `safe_mysqld' fails, even when invoked from the MySQL installation
  18000. directory, you can modify it to use the path to `mysqld' and the
  18001. pathname options that are correct for your system.  Note that if you
  18002. upgrade MySQL in the future, your modified version of `safe_mysqld'
  18003. will be overwritten, so you should make a copy of your edited version
  18004. that you can reinstall.
  18005.  
  18006. 
  18007. File: mysql.info,  Node: mysqld_multi,  Next: myisampack,  Prev: safe_mysqld,  Up: Server-Side Scripts
  18008.  
  18009. mysqld_multi, program for managing multiple MySQL servers
  18010. ---------------------------------------------------------
  18011.  
  18012. `mysqld_multi' is meant for managing several `mysqld' processes running
  18013. in different UNIX sockets and TCP/IP ports.
  18014.  
  18015. The program will search for group(s) named [mysqld#] from my.cnf (or the
  18016. given -config-file=...), where # can be any positive number starting
  18017. from 1. These groups should be the same as the usual `[mysqld]' group
  18018. (e.g. options to mysqld, see MySQL manual for detailed information
  18019. about this group), but with those port, socket etc. options that are
  18020. wanted for each separate `mysqld' processes. The number in the group
  18021. name has another function; it can be used for starting, stopping, or
  18022. reporting some specific `mysqld' servers with this program. See the
  18023. usage and options below for more information.
  18024.  
  18025.      Usage: mysqld_multi [OPTIONS] {start|stop|report} [GNR,GNR,GNR...]
  18026.      or     mysqld_multi [OPTIONS] {start|stop|report} [GNR-GNR,GNR,GNR-GNR,...]
  18027.  
  18028. The GNR above means the group number. You can start, stop or report any
  18029. GNR, or several of them at the same time. (See -example) The GNRs list
  18030. can be comma separated, or a dash combined, of which the latter means
  18031. that all the GNRs between GNR1-GNR2 will be affected. Without GNR
  18032. argument all the found groups will be either started, stopped, or
  18033. reported. Note that you must not have any white spaces in the GNR list.
  18034. Anything after a white space is ignored.
  18035.  
  18036. `mysqld_multi' supports the following options:
  18037.  
  18038. `--config-file=...'
  18039.      Alternative config file. NOTE: This will not affect this program's
  18040.      own options (group `[mysqld_multi]'), but only groups [mysqld#].
  18041.      Without this option everything will be searched from the ordinary
  18042.      my.cnf file.
  18043.  
  18044. `--example'
  18045.      Give an example of a config file.
  18046.  
  18047. `--help'
  18048.      Print this help and exit.
  18049.  
  18050. `--log=...'
  18051.      Log file. Full path to and the name for the log file. NOTE: If the
  18052.      file exists, everything will be appended.
  18053.  
  18054. `--mysqladmin=...'
  18055.      `mysqladmin' binary to be used for a server shutdown.
  18056.  
  18057. `--mysqld=...'
  18058.      `mysqld' binary to be used. Note that you can give `safe_mysqld'
  18059.      to this option also. The options are passed to `mysqld'. Just make
  18060.      sure you have `mysqld' in your environment variable `PATH' or fix
  18061.      `safe_mysqld'.
  18062.  
  18063. `--no-log'
  18064.      Print to stdout instead of the log file. By default the log file is
  18065.      turned on.
  18066.  
  18067. `--password=...'
  18068.      Password for user for `mysqladmin'.
  18069.  
  18070. `--tcp-ip'
  18071.      Connect to the MySQL server(s) via the TCP/IP port instead of the
  18072.      UNIX socket. This affects stopping and reporting.  If a socket file
  18073.      is missing, the server may still be running, but can be accessed
  18074.      only via the TCP/IP port.  By default connecting is done via the
  18075.      UNIX socket.
  18076.  
  18077. `--user=...'
  18078.      MySQL user for `mysqladmin'.
  18079.  
  18080. `--version'
  18081.      Print the version number and exit.
  18082.  
  18083. Some notes about `mysqld_multi':
  18084.  
  18085.    * Make sure that the MySQL user, who is stopping the `mysqld'
  18086.      services (e.g using the `mysqladmin') have the same password and
  18087.      username for all the data directories accessed (to the 'mysql'
  18088.      database) And make sure that the user has the 'Shutdown_priv'
  18089.      privilege! If you have many data- directories and many different
  18090.      'mysql' databases with different passwords for the MySQL 'root'
  18091.      user, you may want to create a common 'multi_admin' user for each
  18092.      using the same password (see below). Example how to do it:
  18093.           shell> mysql -u root -S /tmp/mysql.sock -proot_password -e
  18094.           "GRANT SHUTDOWN ON *.* TO multi_admin@localhost IDENTIFIED BY 'multipass'"
  18095.           *Note Privileges::.
  18096.      You will have to do the above for each `mysqld' running in each
  18097.      data directory, that you have (just change the socket, -S=...)
  18098.  
  18099.    * `pid-file' is very important, if you are using `safe_mysqld' to
  18100.      start `mysqld' (e.g. -mysqld=safe_mysqld) Every `mysqld' should
  18101.      have its own `pid-file'. The advantage using `safe_mysqld' instead
  18102.      of `mysqld' directly here is, that `safe_mysqld' 'guards' every
  18103.      `mysqld' process and will restart it, if a `mysqld' process fails
  18104.      due to signal kill -9, or similar. (Like segmentation fault, which
  18105.      MySQL should never do, of course ;) Please note that `safe_mysqld'
  18106.      script may require that you start it from a certain place. This
  18107.      means that you may have to CD to a certain directory, before you
  18108.      start the `mysqld_multi'. If you have problems starting, please
  18109.      see the `safe_mysqld' script. Check especially the lines:
  18110.           --------------------------------------------------------------------------
  18111.           MY_PWD=`pwd` Check if we are starting this relative (for the binary
  18112.           release) if test -d /data/mysql -a -f ./share/mysql/english/errmsg.sys
  18113.           -a -x ./bin/mysqld
  18114.           --------------------------------------------------------------------------
  18115.           *Note `safe_mysqld': safe_mysqld.
  18116.      The above test should be successful, or you may encounter problems.
  18117.  
  18118.    * Beware of the dangers starting multiple `mysqlds' in the same data
  18119.      directory.  Use separate data directories, unless you *KNOW* what
  18120.      you are doing!
  18121.  
  18122.    * The socket file and the TCP/IP port must be different for every
  18123.      `mysqld'.
  18124.  
  18125.    * The first and fifth `mysqld' group were intentionally left out from
  18126.      the example.  You may have 'gaps' in the config file. This gives
  18127.      you more flexibility.  The order in which the `mysqlds' are
  18128.      started or stopped depends on the order in which they appear in
  18129.      the config file.
  18130.  
  18131.    * When you want to refer to a certain group using GNR with this
  18132.      program, just use the number in the end of the group name (
  18133.      [mysqld# <== ).
  18134.  
  18135.    * You may want to use option '-user' for `mysqld', but in order to
  18136.      do this you need to be root when you start the `mysqld_multi'
  18137.      script. Having the option in the config file doesn't matter; you
  18138.      will just get a warning, if you are not the superuser and the
  18139.      `mysqlds' are started under *YOUR* UNIX account. *IMPORTANT*: Make
  18140.      sure that the `pid-file' and the data directory are
  18141.      read+write(+execute for the latter one) accessible for *THAT* UNIX
  18142.      user, who the specific `mysqld' process is started as. *DON'T* use
  18143.      the UNIX root account for this, unless you *KNOW* what you are
  18144.      doing!
  18145.  
  18146.    * *MOST IMPORTANT*: Make sure that you understand the meanings of
  18147.      the options that are passed to the `mysqlds' and why *WOULD YOU
  18148.      WANT* to have separate `mysqld' processes. Starting multiple
  18149.      `mysqlds' in one data directory *WILL NOT* give you extra
  18150.      performance in a threaded system!
  18151.  
  18152. *Note Multiple servers::.
  18153.  
  18154. This is an example of the config file on behalf of `mysqld_multi'.
  18155.  
  18156.      # This file should probably be in your home dir (~/.my.cnf) or /etc/my.cnf
  18157.      # Version 2.1 by Jani Tolonen
  18158.      
  18159.      [mysqld_multi]
  18160.      mysqld     = /usr/local/bin/safe_mysqld
  18161.      mysqladmin = /usr/local/bin/mysqladmin
  18162.      user       = multi_admin
  18163.      password   = multipass
  18164.      
  18165.      [mysqld2]
  18166.      socket     = /tmp/mysql.sock2
  18167.      port       = 3307
  18168.      pid-file   = /usr/local/mysql/var2/hostname.pid2
  18169.      datadir    = /usr/local/mysql/var2
  18170.      language   = /usr/local/share/mysql/english
  18171.      user       = john
  18172.      
  18173.      [mysqld3]
  18174.      socket     = /tmp/mysql.sock3
  18175.      port       = 3308
  18176.      pid-file   = /usr/local/mysql/var3/hostname.pid3
  18177.      datadir    = /usr/local/mysql/var3
  18178.      language   = /usr/local/share/mysql/swedish
  18179.      user       = monty
  18180.      
  18181.      [mysqld4]
  18182.      socket     = /tmp/mysql.sock4
  18183.      port       = 3309
  18184.      pid-file   = /usr/local/mysql/var4/hostname.pid4
  18185.      datadir    = /usr/local/mysql/var4
  18186.      language   = /usr/local/share/mysql/estonia
  18187.      user       = tonu
  18188.      
  18189.      [mysqld6]
  18190.      socket     = /tmp/mysql.sock6
  18191.      port       = 3311
  18192.      pid-file   = /usr/local/mysql/var6/hostname.pid6
  18193.      datadir    = /usr/local/mysql/var6
  18194.      language   = /usr/local/share/mysql/japanese
  18195.      user       = jani
  18196.  
  18197. *Note Option files::.
  18198.  
  18199. 
  18200. File: mysql.info,  Node: myisampack,  Next: mysqld-max,  Prev: mysqld_multi,  Up: Server-Side Scripts
  18201.  
  18202. myisampack, The MySQL Compressed Read-only Table Generator
  18203. ----------------------------------------------------------
  18204.  
  18205. `myisampack' is used to compress MyISAM tables, and `pack_isam' is used
  18206. to compress ISAM tables. Because ISAM tables are deprecated, we will
  18207. only discuss `myisampack' here, but everything said about `myisampack'
  18208. should also be true for `pack_isam'.
  18209.  
  18210. `myisampack' works by compressing each column in the table separately.
  18211. The information needed to decompress columns is read into memory when
  18212. the table is opened. This results in much better performance when
  18213. accessing individual records, because you only have to uncompress
  18214. exactly one record, not a much larger disk block as when using Stacker
  18215. on MS-DOS.  Usually, `myisampack' packs the data file 40%-70%.
  18216.  
  18217. MySQL uses memory mapping (`mmap()') on compressed tables and falls
  18218. back to normal read/write file usage if `mmap()' doesn't work.
  18219.  
  18220. There are currently two limitations with `myisampack':
  18221.    * After packing, the table is read-only.
  18222.  
  18223.    * `myisampack' can also pack `BLOB' or `TEXT' columns. The older
  18224.      `pack_isam' could not do this.
  18225.  
  18226. Fixing these limitations is on our TODO list but with low priority.
  18227.  
  18228. `myisampack' is invoked like this:
  18229.  
  18230.      shell> myisampack [options] filename ...
  18231.  
  18232. Each filename should be the name of an index (`.MYI') file.  If you are
  18233. not in the database directory, you should specify the pathname to the
  18234. file.  It is permissible to omit the `.MYI' extension.
  18235.  
  18236. `myisampack' supports the following options:
  18237.  
  18238. `-b, --backup'
  18239.      Make a backup of the table as `tbl_name.OLD'.
  18240.  
  18241. `-#, --debug=debug_options'
  18242.      Output debug log. The `debug_options' string often is
  18243.      `'d:t:o,filename''.
  18244.  
  18245. `-f, --force'
  18246.      Force packing of the table even if it becomes bigger or if the
  18247.      temporary file exists.  `myisampack' creates a temporary file
  18248.      named `tbl_name.TMD' while it compresses the table.  If you kill
  18249.      `myisampack', the `.TMD' file may not be deleted.  Normally,
  18250.      `myisampack' exits with an error if it finds that `tbl_name.TMD'
  18251.      exists.  With `--force', `myisampack' packs the table anyway.
  18252.  
  18253. `-?, --help'
  18254.      Display a help message and exit.
  18255.  
  18256. `-j big_tbl_name, --join=big_tbl_name'
  18257.      Join all tables named on the command line into a single table
  18258.      `big_tbl_name'.  All tables that are to be combined MUST be
  18259.      identical (same column names and types, same indexes, etc.).
  18260.  
  18261. `-p #, --packlength=#'
  18262.      Specify the record length storage size, in bytes.  The value
  18263.      should be 1, 2, or 3.  (`myisampack' stores all rows with length
  18264.      pointers of 1, 2, or 3 bytes.  In most normal cases, `myisampack'
  18265.      can determine the right length value before it begins packing the
  18266.      file, but it may notice during the packing process that it could
  18267.      have used a shorter length. In this case, `myisampack' will print
  18268.      a note that the next time you pack the same file, you could use a
  18269.      shorter record length.)
  18270.  
  18271. `-s, --silent'
  18272.      Silent mode.  Write output only when errors occur.
  18273.  
  18274. `-t, --test'
  18275.      Don't actually pack table, just test packing it.
  18276.  
  18277. `-T dir_name, --tmp_dir=dir_name'
  18278.      Use the named directory as the location in which to write the
  18279.      temporary table.
  18280.  
  18281. `-v, --verbose'
  18282.      Verbose mode.  Write information about progress and packing result.
  18283.  
  18284. `-V, --version'
  18285.      Display version information and exit.
  18286.  
  18287. `-w, --wait'
  18288.      Wait and retry if table is in use.  If the `mysqld' server was
  18289.      invoked with the `--skip-locking' option, it is not a good idea to
  18290.      invoke `myisampack' if the table might be updated during the
  18291.      packing process.
  18292.  
  18293. The sequence of commands shown below illustrates a typical table
  18294. compression session:
  18295.  
  18296.      shell> ls -l station.*
  18297.      -rw-rw-r--   1 monty    my         994128 Apr 17 19:00 station.MYD
  18298.      -rw-rw-r--   1 monty    my          53248 Apr 17 19:00 station.MYI
  18299.      -rw-rw-r--   1 monty    my           5767 Apr 17 19:00 station.frm
  18300.      
  18301.      shell> myisamchk -dvv station
  18302.      
  18303.      MyISAM file:     station
  18304.      Isam-version:  2
  18305.      Creation time: 1996-03-13 10:08:58
  18306.      Recover time:  1997-02-02  3:06:43
  18307.      Data records:              1192  Deleted blocks:              0
  18308.      Datafile: Parts:           1192  Deleted data:                0
  18309.      Datafile pointer (bytes):     2  Keyfile pointer (bytes):     2
  18310.      Max datafile length:   54657023  Max keyfile length:   33554431
  18311.      Recordlength:               834
  18312.      Record format: Fixed length
  18313.      
  18314.      table description:
  18315.      Key Start Len Index   Type                       Root  Blocksize    Rec/key
  18316.      1   2     4   unique  unsigned long              1024       1024          1
  18317.      2   32    30  multip. text                      10240       1024          1
  18318.      
  18319.      Field Start Length Type
  18320.      1     1     1
  18321.      2     2     4
  18322.      3     6     4
  18323.      4     10    1
  18324.      5     11    20
  18325.      6     31    1
  18326.      7     32    30
  18327.      8     62    35
  18328.      9     97    35
  18329.      10    132   35
  18330.      11    167   4
  18331.      12    171   16
  18332.      13    187   35
  18333.      14    222   4
  18334.      15    226   16
  18335.      16    242   20
  18336.      17    262   20
  18337.      18    282   20
  18338.      19    302   30
  18339.      20    332   4
  18340.      21    336   4
  18341.      22    340   1
  18342.      23    341   8
  18343.      24    349   8
  18344.      25    357   8
  18345.      26    365   2
  18346.      27    367   2
  18347.      28    369   4
  18348.      29    373   4
  18349.      30    377   1
  18350.      31    378   2
  18351.      32    380   8
  18352.      33    388   4
  18353.      34    392   4
  18354.      35    396   4
  18355.      36    400   4
  18356.      37    404   1
  18357.      38    405   4
  18358.      39    409   4
  18359.      40    413   4
  18360.      41    417   4
  18361.      42    421   4
  18362.      43    425   4
  18363.      44    429   20
  18364.      45    449   30
  18365.      46    479   1
  18366.      47    480   1
  18367.      48    481   79
  18368.      49    560   79
  18369.      50    639   79
  18370.      51    718   79
  18371.      52    797   8
  18372.      53    805   1
  18373.      54    806   1
  18374.      55    807   20
  18375.      56    827   4
  18376.      57    831   4
  18377.      
  18378.      shell> myisampack station.MYI
  18379.      Compressing station.MYI: (1192 records)
  18380.      - Calculating statistics
  18381.      
  18382.      normal:     20  empty-space:      16  empty-zero:        12  empty-fill:  11
  18383.      pre-space:   0  end-space:        12  table-lookups:      5  zero:         7
  18384.      Original trees:  57  After join: 17
  18385.      - Compressing file
  18386.      87.14%
  18387.      
  18388.      shell> ls -l station.*
  18389.      -rw-rw-r--   1 monty    my         127874 Apr 17 19:00 station.MYD
  18390.      -rw-rw-r--   1 monty    my          55296 Apr 17 19:04 station.MYI
  18391.      -rw-rw-r--   1 monty    my           5767 Apr 17 19:00 station.frm
  18392.      
  18393.      shell> myisamchk -dvv station
  18394.      
  18395.      MyISAM file:     station
  18396.      Isam-version:  2
  18397.      Creation time: 1996-03-13 10:08:58
  18398.      Recover time:  1997-04-17 19:04:26
  18399.      Data records:              1192  Deleted blocks:              0
  18400.      Datafile: Parts:           1192  Deleted data:                0
  18401.      Datafilepointer (bytes):      3  Keyfile pointer (bytes):     1
  18402.      Max datafile length:   16777215  Max keyfile length:     131071
  18403.      Recordlength:               834
  18404.      Record format: Compressed
  18405.      
  18406.      table description:
  18407.      Key Start Len Index   Type                       Root  Blocksize    Rec/key
  18408.      1   2     4   unique  unsigned long             10240       1024          1
  18409.      2   32    30  multip. text                      54272       1024          1
  18410.      
  18411.      Field Start Length Type                         Huff tree  Bits
  18412.      1     1     1      constant                             1     0
  18413.      2     2     4      zerofill(1)                          2     9
  18414.      3     6     4      no zeros, zerofill(1)                2     9
  18415.      4     10    1                                           3     9
  18416.      5     11    20     table-lookup                         4     0
  18417.      6     31    1                                           3     9
  18418.      7     32    30     no endspace, not_always              5     9
  18419.      8     62    35     no endspace, not_always, no empty    6     9
  18420.      9     97    35     no empty                             7     9
  18421.      10    132   35     no endspace, not_always, no empty    6     9
  18422.      11    167   4      zerofill(1)                          2     9
  18423.      12    171   16     no endspace, not_always, no empty    5     9
  18424.      13    187   35     no endspace, not_always, no empty    6     9
  18425.      14    222   4      zerofill(1)                          2     9
  18426.      15    226   16     no endspace, not_always, no empty    5     9
  18427.      16    242   20     no endspace, not_always              8     9
  18428.      17    262   20     no endspace, no empty                8     9
  18429.      18    282   20     no endspace, no empty                5     9
  18430.      19    302   30     no endspace, no empty                6     9
  18431.      20    332   4      always zero                          2     9
  18432.      21    336   4      always zero                          2     9
  18433.      22    340   1                                           3     9
  18434.      23    341   8      table-lookup                         9     0
  18435.      24    349   8      table-lookup                        10     0
  18436.      25    357   8      always zero                          2     9
  18437.      26    365   2                                           2     9
  18438.      27    367   2      no zeros, zerofill(1)                2     9
  18439.      28    369   4      no zeros, zerofill(1)                2     9
  18440.      29    373   4      table-lookup                        11     0
  18441.      30    377   1                                           3     9
  18442.      31    378   2      no zeros, zerofill(1)                2     9
  18443.      32    380   8      no zeros                             2     9
  18444.      33    388   4      always zero                          2     9
  18445.      34    392   4      table-lookup                        12     0
  18446.      35    396   4      no zeros, zerofill(1)               13     9
  18447.      36    400   4      no zeros, zerofill(1)                2     9
  18448.      37    404   1                                           2     9
  18449.      38    405   4      no zeros                             2     9
  18450.      39    409   4      always zero                          2     9
  18451.      40    413   4      no zeros                             2     9
  18452.      41    417   4      always zero                          2     9
  18453.      42    421   4      no zeros                             2     9
  18454.      43    425   4      always zero                          2     9
  18455.      44    429   20     no empty                             3     9
  18456.      45    449   30     no empty                             3     9
  18457.      46    479   1                                          14     4
  18458.      47    480   1                                          14     4
  18459.      48    481   79     no endspace, no empty               15     9
  18460.      49    560   79     no empty                             2     9
  18461.      50    639   79     no empty                             2     9
  18462.      51    718   79     no endspace                         16     9
  18463.      52    797   8      no empty                             2     9
  18464.      53    805   1                                          17     1
  18465.      54    806   1                                           3     9
  18466.      55    807   20     no empty                             3     9
  18467.      56    827   4      no zeros, zerofill(2)                2     9
  18468.      57    831   4      no zeros, zerofill(1)                2     9
  18469.  
  18470. The information printed by `myisampack' is described below:
  18471.  
  18472. `normal'
  18473.      The number of columns for which no extra packing is used.
  18474.  
  18475. `empty-space'
  18476.      The number of columns containing values that are only spaces;
  18477.      these will occupy 1 bit.
  18478.  
  18479. `empty-zero'
  18480.      The number of columns containing values that are only binary 0's;
  18481.      these will occupy 1 bit.
  18482.  
  18483. `empty-fill'
  18484.      The number of integer columns that don't occupy the full byte
  18485.      range of their type; these are changed to a smaller type (for
  18486.      example, an `INTEGER' column may be changed to `MEDIUMINT').
  18487.  
  18488. `pre-space'
  18489.      The number of decimal columns that are stored with leading spaces.
  18490.      In this case, each value will contain a count for the number of
  18491.      leading spaces.
  18492.  
  18493. `end-space'
  18494.      The number of columns that have a lot of trailing spaces.  In this
  18495.      case, each value will contain a count for the number of trailing
  18496.      spaces.
  18497.  
  18498. `table-lookup'
  18499.      The column had only a small number of different values, which were
  18500.      converted to an `ENUM' before Huffman compression.
  18501.  
  18502. `zero'
  18503.      The number of columns for which all values are zero.
  18504.  
  18505. `Original trees'
  18506.      The initial number of Huffman trees.
  18507.  
  18508. `After join'
  18509.      The number of distinct Huffman trees left after joining trees to
  18510.      save some header space.
  18511.  
  18512. After a table has been compressed, `myisamchk -dvv' prints additional
  18513. information about each field:
  18514.  
  18515. `Type'
  18516.      The field type may contain the following descriptors:
  18517.  
  18518.     `constant'
  18519.           All rows have the same value.
  18520.  
  18521.     `no endspace'
  18522.           Don't store endspace.
  18523.  
  18524.     `no endspace, not_always'
  18525.           Don't store endspace and don't do end space compression for
  18526.           all values.
  18527.  
  18528.     `no endspace, no empty'
  18529.           Don't store endspace. Don't store empty values.
  18530.  
  18531.     `table-lookup'
  18532.           The column was converted to an `ENUM'.
  18533.  
  18534.     `zerofill(n)'
  18535.           The most significant `n' bytes in the value are always 0 and
  18536.           are not stored.
  18537.  
  18538.     `no zeros'
  18539.           Don't store zeros.
  18540.  
  18541.     `always zero'
  18542.           0 values are stored in 1 bit.
  18543.  
  18544. `Huff tree'
  18545.      The Huffman tree associated with the field.
  18546.  
  18547. `Bits'
  18548.      The number of bits used in the Huffman tree.
  18549.  
  18550. After you have run `pack_isam'/`myisampack' you must run
  18551. `isamchk'/`myisamchk' to re-create the index.  At this time you can
  18552. also sort the index blocks and create statistics needed for the MySQL
  18553. optimizer to work more efficiently:
  18554.  
  18555.      myisamchk -rq --analyze --sort-index table_name.MYI
  18556.      isamchk   -rq --analyze --sort-index table_name.ISM
  18557.  
  18558. After you have installed the packed table into the MySQL database
  18559. directory you should do `mysqladmin flush-tables' to force `mysqld' to
  18560. start using the new table.
  18561.  
  18562. If you want to unpack a packed table, you can do this with the
  18563. `--unpack' option to `isamchk' or `myisamchk'.
  18564.  
  18565. 
  18566. File: mysql.info,  Node: mysqld-max,  Prev: myisampack,  Up: Server-Side Scripts
  18567.  
  18568. mysqld-max, An extended mysqld server
  18569. -------------------------------------
  18570.  
  18571. `mysqld-max' is the MySQL server (`mysqld') configured with the
  18572. following configure options:
  18573.  
  18574. *Option*               *Comment*
  18575. -with-server-suffix=-maxAdd a suffix to the `mysqld' version string.
  18576. -with-bdb              Support for Berkeley DB (BDB) tables
  18577. -with-innodb           Support for InnoDB tables.
  18578. CFLAGS=-DUSE_SYMDIR    Symbolic links support for Windows.
  18579.  
  18580. You can find the MySQL-max binaries at
  18581. `http://www.mysql.com/downloads/mysql-max-3.23.html'.
  18582.  
  18583. The Windows MySQL 3.23 binary distribution includes both the standard
  18584. `mysqld.exe' binary and the `mysqld-max.exe' binary.
  18585. `http://www.mysql.com/downloads/mysql-3.23.html'.  *Note Windows
  18586. installation::.
  18587.  
  18588. Note that as Berkeley DB and InnoDB are not available for all platforms,
  18589. some of the `Max' binaries may not have support for both of these.  You
  18590. can check which table types are supported by doing the following query:
  18591.  
  18592.      mysql> show variables like "have_%";
  18593.      +---------------+-------+
  18594.      | Variable_name | Value |
  18595.      +---------------+-------+
  18596.      | have_bdb      | YES   |
  18597.      | have_innodb   | NO    |
  18598.      | have_isam     | YES   |
  18599.      | have_raid     | NO    |
  18600.      | have_ssl      | NO    |
  18601.      +---------------+-------+
  18602.  
  18603. The meaning of the values are:
  18604.  
  18605. *Value*                *Meaning*.
  18606. YES                    The option is activated and usable.
  18607. NO                     MySQL is not compiled with support for this
  18608.                        option.
  18609. DISABLED               The xxxx option is disabled because one started
  18610.                        `mysqld' with `--skip-xxxx' or because one didn't
  18611.                        start `mysqld' with all needed options to enable
  18612.                        the option.  In this case the `hostname.err' file
  18613.                        should contain a reason for why the option is
  18614.                        disabled.
  18615.  
  18616. *NOTE*:  To be able to create InnoDB tables you *MUST* edit your
  18617. startup options to include at least the `innodb_data_file_path' option.
  18618. *Note InnoDB start::.
  18619.  
  18620. To get better performance for BDB tables, you should add some
  18621. configuration options for these too. *Note BDB start::.
  18622.  
  18623. `safe_mysqld' will automatically try to start any `mysqld' binary with
  18624. the `-max' prefix. This makes it very easy to test out a another
  18625. `mysqld' binary in an existing installation.  Just run `configure' with
  18626. the options you want and then install the new `mysqld' binary as
  18627. `mysqld-max' in the same directory where your old `mysqld' binary is.
  18628. *Note `safe_mysqld': safe_mysqld.
  18629.  
  18630. The `mysqld-max' RPM uses the above mentioned `safe_mysqld' feature. It
  18631. just installs the `mysqld-max' executable and `safe_mysqld' will
  18632. automatically use this executable when `safe_mysqld' is restarted.
  18633.  
  18634. The following table shows which table types our standard *MySQL-Max*
  18635. binaries includes:
  18636.  
  18637. *System*                      *BDB*                  *InnoDB*
  18638. AIX 4.3                       N                      Y
  18639. HP-UX 11.0                    N                      Y
  18640. Linux-Alpha                   N                      Y
  18641. Linux-Intel                   Y                      Y
  18642. Linux-Ia64                    N                      Y
  18643. Solaris-intel                 N                      Y
  18644. Solaris-sparc                 Y                      Y
  18645. SCO OSR5                      Y                      Y
  18646. UnixWare                      Y                      Y
  18647. Windows/NT                    Y                      Y
  18648.  
  18649. 
  18650. File: mysql.info,  Node: Client-Side Scripts,  Next: Log Files,  Prev: Server-Side Scripts,  Up: MySQL Database Administration
  18651.  
  18652. MySQL Client-Side Scripts and Utilities
  18653. =======================================
  18654.  
  18655. * Menu:
  18656.  
  18657. * Client-Side Overview::        Overview of the Client-Side Scripts and Utilities
  18658. * mysql::                       The Command-line Tool
  18659. * mysqladmin::                  mysqladmin, Administrating a MySQL Server
  18660. * Using mysqlcheck::            Using `mysqlcheck' for Table Maintenance and Crash Recovery
  18661. * mysqldump::                   mysqldump, Dumping Table Structure and Data
  18662. * mysqlhotcopy::                mysqlhotcopy, Copying MySQL Databases and Tables
  18663. * mysqlimport::                 mysqlimport, Importing Data from Text Files
  18664. * mysqlshow::                   Showing Databases, Tables, and Columns
  18665. * perror::                      perror, Explaining Error Codes
  18666. * Batch Commands::              How to Run SQL Commands from a Text File
  18667.  
  18668. 
  18669. File: mysql.info,  Node: Client-Side Overview,  Next: mysql,  Prev: Client-Side Scripts,  Up: Client-Side Scripts
  18670.  
  18671. Overview of the Client-Side Scripts and Utilities
  18672. -------------------------------------------------
  18673.  
  18674. All MySQL clients that communicate with the server using the
  18675. `mysqlclient' library use the following environment variables:
  18676.  
  18677. *Name*             *Description*
  18678. `MYSQL_UNIX_PORT'  The default socket; used for connections to
  18679.                    `localhost'
  18680. `MYSQL_TCP_PORT'   The default TCP/IP port
  18681. `MYSQL_PWD'        The default password
  18682. `MYSQL_DEBUG'      Debug-trace options when debugging
  18683. `TMPDIR'           The directory where temporary tables/files are created
  18684.  
  18685. Use of `MYSQL_PWD' is insecure.  *Note Connecting::.
  18686.  
  18687. The `mysql' client uses the file named in the `MYSQL_HISTFILE'
  18688. environment variable to save the command-line history. The default
  18689. value for the history file is `$HOME/.mysql_history', where `$HOME' is
  18690. the value of the `HOME' environment variable. *Note Environment
  18691. variables::.
  18692.  
  18693. All MySQL programs take many different options. However, every MySQL
  18694. program provides a `--help' option that you can use to get a full
  18695. description of the program's different options. For example, try `mysql
  18696. --help'.
  18697.  
  18698. You can override default options for all standard client programs with
  18699. an option file. *Note Option files::.
  18700.  
  18701. The list below briefly describes the MySQL programs:
  18702.  
  18703. `myisamchk'
  18704.      Utility to describe, check, optimize, and repair MySQL tables.
  18705.      Because `myisamchk' has many functions, it is described in its own
  18706.      chapter. *Note MySQL Database Administration::.
  18707.  
  18708. `make_binary_distribution'
  18709.      Makes a binary release of a compiled MySQL. This could be sent by
  18710.      FTP to `/pub/mysql/Incoming' on `support.mysql.com' for the
  18711.      convenience of other MySQL users.
  18712.  
  18713. `msql2mysql'
  18714.      A shell script that converts `mSQL' programs to MySQL. It doesn't
  18715.      handle all cases, but it gives a good start when converting.
  18716.  
  18717. `mysqlaccess'
  18718.      A script that checks the access privileges for a host, user, and
  18719.      database combination.
  18720.  
  18721. `mysqladmin'
  18722.      Utility for performing administrative operations, such as creating
  18723.      or dropping databases, reloading the grant tables, flushing tables
  18724.      to disk, and reopening log files.  `mysqladmin' can also be used
  18725.      to retrieve version, process, and status information from the
  18726.      server.  *Note `mysqladmin': mysqladmin.
  18727.  
  18728. `mysqlbug'
  18729.      The MySQL bug report script.  This script should always be used
  18730.      when filing a bug report to the MySQL list.
  18731.  
  18732. `mysqld'
  18733.      The SQL daemon. This should always be running.
  18734.  
  18735. `mysqldump'
  18736.      Dumps a MySQL database into a file as SQL statements or as
  18737.      tab-separated text files. Enhanced freeware originally by Igor
  18738.      Romanenko.  *Note `mysqldump': mysqldump.
  18739.  
  18740. `mysqlimport'
  18741.      Imports text files into their respective tables using `LOAD DATA
  18742.      INFILE'. *Note `mysqlimport': mysqlimport.
  18743.  
  18744. `mysqlshow'
  18745.      Displays information about databases, tables, columns, and indexes.
  18746.  
  18747. `mysql_install_db'
  18748.      Creates the MySQL grant tables with default privileges. This is
  18749.      usually executed only once, when first installing MySQL on a
  18750.      system.
  18751.  
  18752. `replace'
  18753.      A utility program that is used by `msql2mysql', but that has more
  18754.      general applicability as well.  `replace' changes strings in place
  18755.      in files or on the standard input. Uses a finite state machine to
  18756.      match longer strings first. Can be used to swap strings. For
  18757.      example, this command swaps `a' and `b' in the given files:
  18758.  
  18759.           shell> replace a b b a -- file1 file2 ...
  18760.  
  18761. 
  18762. File: mysql.info,  Node: mysql,  Next: mysqladmin,  Prev: Client-Side Overview,  Up: Client-Side Scripts
  18763.  
  18764. The Command-line Tool
  18765. ---------------------
  18766.  
  18767. `mysql' is a simple SQL shell (with GNU `readline' capabilities).  It
  18768. supports interactive and non-interactive use. When used interactively,
  18769. query results are presented in an ASCII-table format. When used
  18770. non-interactively (for example, as a filter), the result is presented in
  18771. tab-separated format.  (The output format can be changed using
  18772. command-line options.)  You can run scripts simply like this:
  18773.  
  18774.      shell> mysql database < script.sql > output.tab
  18775.  
  18776. If you have problems due to insufficient memory in the client, use the
  18777. `--quick' option!  This forces `mysql' to use `mysql_use_result()'
  18778. rather than `mysql_store_result()' to retrieve the result set.
  18779.  
  18780. Using `mysql' is very easy. Just start it as follows: `mysql database'
  18781. or `mysql --user=user_name --password=your_password database'. Type a
  18782. SQL statement, end it with `;', `\g', or `\G' and press RETURN/ENTER.
  18783.  
  18784. `mysql' supports the following options:
  18785.  
  18786. `-?, --help'
  18787.      Display this help and exit.
  18788.  
  18789. `-A, --no-auto-rehash'
  18790.      No automatic rehashing. One has to use 'rehash' to get table and
  18791.      field completion. This gives a quicker start of mysql.
  18792.  
  18793. `-B, --batch'
  18794.      Print results with a tab as separator, each row on a new line.
  18795.      Doesn't use history file.
  18796.  
  18797. `--character-sets-dir=...'
  18798.      Directory where character sets are located.
  18799.  
  18800. `-C, --compress'
  18801.      Use compression in server/client protocol.
  18802.  
  18803. `-#, --debug[=...]'
  18804.      Debug log. Default is 'd:t:o,/tmp/mysql.trace'.
  18805.  
  18806. `-D, --database=...'
  18807.      Database to use. This is mainly useful in the `my.cnf' file.
  18808.  
  18809. `--default-character-set=...'
  18810.      Set the default character set.
  18811.  
  18812. `-e, --execute=...'
  18813.      Execute command and quit. (Output like with -batch)
  18814.  
  18815. `-E, --vertical'
  18816.      Print the output of a query (rows) vertically. Without this option
  18817.      you can also force this output by ending your statements with `\G'.
  18818.  
  18819. `-f, --force'
  18820.      Continue even if we get a SQL error.
  18821.  
  18822. `-g, --no-named-commands'
  18823.      Named commands are disabled. Use \* form only, or use named
  18824.      commands only in the beginning of a line ending with a semicolon
  18825.      (;). Since Version 10.9, the client now starts with this option
  18826.      ENABLED by default!  With the -g option, long format commands will
  18827.      still work from the first line, however.
  18828.  
  18829. `-G, --enable-named-commands'
  18830.      Named commands are *enabled*.  Long format commands are allowed as
  18831.      well as shortened \* commands.
  18832.  
  18833. `-i, --ignore-space'
  18834.      Ignore space after function names.
  18835.  
  18836. `-h, --host=...'
  18837.      Connect to the given host.
  18838.  
  18839. `-H, --html'
  18840.      Produce HTML output.
  18841.  
  18842. `-L, --skip-line-numbers'
  18843.      Don't write line number for errors. Useful when one wants to
  18844.      compare result files that includes error messages
  18845.  
  18846. `--no-pager'
  18847.      Disable pager and print to stdout. See interactive help (\h) also.
  18848.  
  18849. `--no-tee'
  18850.      Disable outfile. See interactive help (\h) also.
  18851.  
  18852. `-n, --unbuffered'
  18853.      Flush buffer after each query.
  18854.  
  18855. `-N, --skip-column-names'
  18856.      Don't write column names in results.
  18857.  
  18858. `-O, --set-variable var=option'
  18859.      Give a variable a value. `--help' lists variables.
  18860.  
  18861. `-o, --one-database'
  18862.      Only update the default database. This is useful for skipping
  18863.      updates to other database in the update log.
  18864.  
  18865. ``--pager[=...]''
  18866.      Output type. Default is your `ENV' variable `PAGER'. Valid pagers
  18867.      are less, more, cat [> filename], etc.  See interactive help (\h)
  18868.      also. This option does not work in batch mode. Pager works only in
  18869.      UNIX.
  18870.  
  18871. `-p[password], --password[=...]'
  18872.      Password to use when connecting to server. If a password is not
  18873.      given on the command line, you will be prompted for it.  Note that
  18874.      if you use the short form `-p' you can't have a space between the
  18875.      option and the password.
  18876.  
  18877. `-P  --port=...'
  18878.      TCP/IP port number to use for connection.
  18879.  
  18880. `-q, --quick'
  18881.      Don't cache result, print it row-by-row. This may slow down the
  18882.      server if the output is suspended. Doesn't use history file.
  18883.  
  18884. `-r, --raw'
  18885.      Write column values without escape conversion. Used with `--batch'
  18886.  
  18887. `-s, --silent'
  18888.      Be more silent.
  18889.  
  18890. `-S  --socket=...'
  18891.      Socket file to use for connection.
  18892.  
  18893. `-t  --table'
  18894.      Output in table format. This is default in non-batch mode.
  18895.  
  18896. `-T, --debug-info'
  18897.      Print some debug information at exit.
  18898.  
  18899. `--tee=...'
  18900.      Append everything into outfile. See interactive help (\h) also.
  18901.      Does not work in batch mode.
  18902.  
  18903. `-u, --user=#'
  18904.      User for login if not current user.
  18905.  
  18906. `-U, --safe-updates[=#], --i-am-a-dummy[=#]'
  18907.      Only allow `UPDATE' and `DELETE' that uses keys. See below for
  18908.      more information about this option.  You can reset this option if
  18909.      you have it in your `my.cnf' file by using `--safe-updates=0'.
  18910.  
  18911. `-v, --verbose'
  18912.      More verbose output (-v -v -v gives the table output format).
  18913.  
  18914. `-V, --version'
  18915.      Output version information and exit.
  18916.  
  18917. `-w, --wait'
  18918.      Wait and retry if connection is down instead of aborting.
  18919.  
  18920. You can also set the following variables with `-O' or `--set-variable':
  18921.  
  18922. Variable Name          Default        Description
  18923. connect_timeout        0              Number of seconds before timeout
  18924.                                       connection.
  18925. max_allowed_packet     16777216       Max packetlength to send/receive
  18926.                                       from to server
  18927. net_buffer_length      16384          Buffer for TCP/IP and socket
  18928.                                       communication
  18929. select_limit           1000           Automatic limit for SELECT when
  18930.                                       using -i-am-a-dummy
  18931. max_join_size          1000000        Automatic limit for rows in a join
  18932.                                       when using -i-am-a-dummy.
  18933.  
  18934. If you type 'help' on the command line, `mysql' will print out the
  18935. commands that it supports:
  18936.  
  18937.      mysql> help
  18938.      
  18939.      MySQL commands:
  18940.      help    (\h)    Display this text.
  18941.      ?       (\h)    Synonym for `help'.
  18942.      clear   (\c)    Clear command.
  18943.      connect (\r)    Reconnect to the server. Optional arguments are db and host.
  18944.      edit    (\e)    Edit command with $EDITOR.
  18945.      ego     (\G)    Send command to mysql server, display result vertically.
  18946.      exit    (\q)    Exit mysql. Same as quit.
  18947.      go      (\g)    Send command to mysql server.
  18948.      nopager (\n)    Disable pager, print to stdout.
  18949.      notee   (\t)    Don't write into outfile.
  18950.      pager   (\P)    Set PAGER [to_pager]. Print the query results via PAGER.
  18951.      print   (\p)    Print current command.
  18952.      quit    (\q)    Quit mysql.
  18953.      rehash  (\#)    Rebuild completion hash.
  18954.      source  (\.)    Execute a SQL script file. Takes a file name as an argument.
  18955.      status  (\s)    Get status information from the server.
  18956.      tee     (\T)    Set outfile [to_outfile]. Append everything into given outfile.
  18957.      use     (\u)    Use another database. Takes database name as argument.
  18958.  
  18959. From the above, pager only works in UNIX.
  18960.  
  18961. The `status' command gives you some information about the connection
  18962. and the server you are using. If you are running in the
  18963. `--safe-updates' mode, `status' will also print the values for the
  18964. `mysql' variables that affect your queries.
  18965.  
  18966. A useful startup option for beginners (introduced in MySQL Version
  18967. 3.23.11) is `--safe-updates' (or `--i-am-a-dummy' for users that has at
  18968. some time done a `DELETE FROM table_name' but forgot the `WHERE'
  18969. clause).  When using this option, `mysql' sends the following command
  18970. to the MySQL server when opening the connection:
  18971.  
  18972.      SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=#select_limit#,
  18973.          SQL_MAX_JOIN_SIZE=#max_join_size#"
  18974.  
  18975. where `#select_limit#' and `#max_join_size#' are variables that can be
  18976. set from the `mysql' command line. *Note `SET': SET OPTION.
  18977.  
  18978. The effect of the above is:
  18979.  
  18980.    * You are not allowed to do an `UPDATE' or `DELETE' statement if you
  18981.      don't have a key constraint in the `WHERE' part. One can, however,
  18982.      force an `UPDATE/DELETE' by using `LIMIT':
  18983.           UPDATE table_name SET not_key_column=# WHERE not_key_column=# LIMIT 1;
  18984.  
  18985.    * All big results are automatically limited to `#select_limit#' rows.
  18986.  
  18987.    * `SELECT''s that will probably need to examine more than
  18988.      `#max_join_size' row combinations will be aborted.
  18989.  
  18990. Some useful hints about the `mysql' client:
  18991.  
  18992. Some data is much more readable when displayed vertically, instead of
  18993. the usual horizontal box type output. For example longer text, which
  18994. includes new lines, is often much easier to be read with vertical
  18995. output.
  18996.  
  18997.      mysql> select * from mails where length(txt) < 300 limit 300,1\G
  18998.      *************************** 1. row ***************************
  18999.        msg_nro: 3068
  19000.           date: 2000-03-01 23:29:50
  19001.      time_zone: +0200
  19002.      mail_from: Monty
  19003.          reply: monty@no.spam.com
  19004.        mail_to: "Thimble Smith" <tim@no.spam.com>
  19005.            sbj: UTF-8
  19006.            txt: >>>>> "Thimble" == Thimble Smith writes:
  19007.      
  19008.      Thimble> Hi.  I think this is a good idea.  Is anyone familiar with UTF-8
  19009.      Thimble> or Unicode?  Otherwise I'll put this on my TODO list and see what
  19010.      Thimble> happens.
  19011.      
  19012.      Yes, please do that.
  19013.      
  19014.      Regards,
  19015.      Monty
  19016.           file: inbox-jani-1
  19017.           hash: 190402944
  19018.      1 row in set (0.09 sec)
  19019.  
  19020.    * For logging, you can use the `tee' option. The `tee' can be
  19021.      started with option `--tee=...', or from the command line
  19022.      interactively with command `tee'. All the data displayed on the
  19023.      screen will also be appended into a given file. This can be very
  19024.      useful for debugging purposes also. The `tee' can be disabled from
  19025.      the command line with command `notee'. Executing `tee' again
  19026.      starts logging again. Without a parameter the previous file will be
  19027.      used. Note that `tee' will flush the results into the file after
  19028.      each command, just before the command line appears again waiting
  19029.      for the next command.
  19030.  
  19031.    * Browsing, or searching the results in the interactive mode in UNIX
  19032.      less, more, or any other similar program, is now possible with
  19033.      option `--pager[=...]'. Without argument, `mysql' client will look
  19034.      for environment variable PAGER and set `pager' to that.  `pager'
  19035.      can be started from the interactive command line with command
  19036.      `pager' and disabled with command `nopager'.  The command takes an
  19037.      argument optionally and the `pager' will be set to that. Command
  19038.      `pager' can be called without an argument, but this requires that
  19039.      the option `--pager' was used, or the `pager' will default to
  19040.      stdout. `pager' works only in UNIX, since it uses the popen()
  19041.      function, which doesn't exist in Windows. In Windows, the `tee'
  19042.      option can be used instead, although it may not be as handy as
  19043.      `pager' can be in some situations.
  19044.  
  19045.    * A few tips about `pager': You can use it to write to a file:
  19046.           mysql> pager cat > /tmp/log.txt
  19047.      and the results will only go to a file. You can also pass any
  19048.      options for the programs that you want to use with the `pager':
  19049.           mysql> pager less -n -i -S
  19050.      From the above do note the option '-S'. You may find it very
  19051.      useful when browsing the results; try the option with horizontal
  19052.      output (end commands with '\g', or ';') and with vertical output
  19053.      (end commands with '\G'). Sometimes a very wide result set is hard
  19054.      to be read from the screen, with option -S to less you can browse
  19055.      the results within the interactive less from left to right,
  19056.      preventing lines longer than your screen from being continued to
  19057.      the next line. This can make the result set much more readable.
  19058.      You can swith the mode between on and off within the interactive
  19059.      less with '-S'. See the 'h' for more help about less.
  19060.  
  19061.    * Last (unless you already understood this from the above examples
  19062.      ;) you can combine very complex ways to handle the results, for
  19063.      example the following would send the results to two files in two
  19064.      different directories, on two different hard-disks mounted on /dr1
  19065.      and /dr2, yet let the results still be seen on the screen via less:
  19066.           mysql> pager cat | tee /dr1/tmp/res.txt | tee /dr2/tmp/res2.txt | less -n -i -S
  19067.  
  19068.    * You can also combine the two functions above; have the `tee'
  19069.      enabled, `pager' set to 'less' and you will be able to browse the
  19070.      results in unix 'less' and still have everything appended into a
  19071.      file the same time. The difference between `UNIX tee' used with the
  19072.      `pager' and the `mysql' client in-built `tee', is that the
  19073.      in-built `tee' works even if you don't have the `UNIX tee'
  19074.      available. The in-built `tee' also logs everything that is printed
  19075.      on the screen, where the `UNIX tee' used with `pager' doesn't log
  19076.      quite that much. Last, but not least, the interactive `tee' is
  19077.      more handy to switch on and off, when you want to log something
  19078.      into a file, but want to be able to turn the feature off sometimes.
  19079.  
  19080. 
  19081. File: mysql.info,  Node: mysqladmin,  Next: Using mysqlcheck,  Prev: mysql,  Up: Client-Side Scripts
  19082.  
  19083. mysqladmin, Administrating a MySQL Server
  19084. -----------------------------------------
  19085.  
  19086. A utility for performing administrative operations. The syntax is:
  19087.  
  19088.      shell> mysqladmin [OPTIONS] command [command-option] command ...
  19089.  
  19090. You can get a list of the options your version of `mysqladmin' supports
  19091. by executing `mysqladmin --help'.
  19092.  
  19093. The current `mysqladmin' supports the following commands:
  19094.  
  19095. `create databasename'
  19096.      Create a new database.
  19097.  
  19098. `drop databasename'
  19099.      Delete a database and all its tables.
  19100.  
  19101. `extended-status'
  19102.      Gives an extended status message from the server.
  19103.  
  19104. `flush-hosts'
  19105.      Flush all cached hosts.
  19106.  
  19107. `flush-logs'
  19108.      Flush all logs.
  19109.  
  19110. `flush-tables'
  19111.      Flush all tables.
  19112.  
  19113. `flush-privileges'
  19114.      Reload grant tables (same as reload).
  19115.  
  19116. `kill id,id,...'
  19117.      Kill mysql threads.
  19118.  
  19119. `password'
  19120.      Set a new password. Change old password to new-password.
  19121.  
  19122. `ping'
  19123.      Check if mysqld is alive.
  19124.  
  19125. `processlist'
  19126.      Show list of active threads in server.
  19127.  
  19128. `reload'
  19129.      Reload grant tables.
  19130.  
  19131. `refresh'
  19132.      Flush all tables and close and open logfiles.
  19133.  
  19134. `shutdown'
  19135.      Take server down.
  19136.  
  19137. `slave-start'
  19138.      Start slave replication thread.
  19139.  
  19140. `slave-stop'
  19141.      Stop slave replication thread.
  19142.  
  19143. `status'
  19144.      Gives a short status message from the server.
  19145.  
  19146. `variables'
  19147.      Prints variables available.
  19148.  
  19149. `version'
  19150.      Get version info from server.
  19151.  
  19152. All commands can be shortened to their unique prefix.  For example:
  19153.  
  19154.      shell> mysqladmin proc stat
  19155.      +----+-------+-----------+----+-------------+------+-------+------+
  19156.      | Id | User  | Host      | db | Command     | Time | State | Info |
  19157.      +----+-------+-----------+----+-------------+------+-------+------+
  19158.      | 6  | monty | localhost |    | Processlist | 0    |       |      |
  19159.      +----+-------+-----------+----+-------------+------+-------+------+
  19160.      Uptime: 10077  Threads: 1  Questions: 9  Slow queries: 0  Opens: 6  Flush tables: 1  Open tables: 2  Memory in use: 1092K  Max memory used: 1116K
  19161.  
  19162. The `mysqladmin status' command result has the following columns:
  19163.  
  19164. Uptime                 Number of seconds the MySQL server has been up.
  19165. Threads                Number of active threads (clients).
  19166. Questions              Number of questions from clients since `mysqld'
  19167.                        was started.
  19168. Slow queries           Queries that have taken more than
  19169.                        `long_query_time' seconds. *Note Slow query log::.
  19170. Opens                  How many tables `mysqld' has opened.
  19171. Flush tables           Number of `flush ...', `refresh', and `reload'
  19172.                        commands.
  19173. Open tables            Number of tables that are open now.
  19174. Memory in use          Memory allocated directly by the `mysqld' code
  19175.                        (only available when MySQL is compiled with
  19176.                        -with-debug=full).
  19177. Max memory used        Maximum memory allocated directly by the `mysqld'
  19178.                        code (only available when MySQL is compiled with
  19179.                        -with-debug=full).
  19180.  
  19181. If you do `myslqadmin shutdown' on a socket (in other words, on a the
  19182. computer where `mysqld' is running), `mysqladmin' will wait until the
  19183. MySQL `pid-file' is removed to ensure that the `mysqld' server has
  19184. stopped properly.
  19185.  
  19186. 
  19187. File: mysql.info,  Node: Using mysqlcheck,  Next: mysqldump,  Prev: mysqladmin,  Up: Client-Side Scripts
  19188.  
  19189. Using `mysqlcheck' for Table Maintenance and Crash Recovery
  19190. -----------------------------------------------------------
  19191.  
  19192. Since MySQL version 3.23.38 you will be able to use a new checking and
  19193. repairing tool for `MyISAM' tables. The difference to `myisamchk' is
  19194. that `mysqlcheck' should be used when the `mysqld' server is running,
  19195. where as `myisamchk' should be used when it is not. The benefit is that
  19196. you no longer have to take the server down for checking or repairing
  19197. your tables.
  19198.  
  19199. `mysqlcheck' uses MySQL server commands `CHECK', `REPAIR', `ANALYZE'
  19200. and `OPTIMIZE' in a convenient way for the user.
  19201.  
  19202. There are three alternative ways to invoke `mysqlcheck':
  19203.  
  19204.      shell> mysqlcheck [OPTIONS] database [tables]
  19205.      shell> mysqlcheck [OPTIONS] --databases DB1 [DB2 DB3...]
  19206.      shell> mysqlcheck [OPTIONS] --all-databases
  19207.  
  19208. So it can be used in a similar way as `mysqldump' when it comes to what
  19209. databases and tables you want to choose.
  19210.  
  19211. `mysqlcheck' does have a special feature compared to the other clients;
  19212. the default behavior, checking tables (-c), can be changed by renaming
  19213. the binary. So if you want to have a tool that repairs tables by
  19214. default, you should just copy `mysqlcheck' to your harddrive with a new
  19215. name, `mysqlrepair', or alternatively make a symbolic link to
  19216. `mysqlrepair' and name the symbolic link as `mysqlrepair'. If you
  19217. invoke `mysqlrepair' now, it will repair tables by default.
  19218.  
  19219. The names that you can use to change `mysqlcheck' default behavior are
  19220. here:
  19221.  
  19222.      mysqlrepair:   The default option will be -r
  19223.      mysqlanalyze:  The default option will be -a
  19224.      mysqloptimize: The default option will be -o
  19225.  
  19226. The options available for `mysqlcheck' are listed here, please check
  19227. what your version supports with `mysqlcheck --help'.
  19228.  
  19229. `-A, --all-databases'
  19230.      Check all the databases. This will be same as -databases with all
  19231.      databases selected
  19232.  
  19233. `-1, --all-in-1'
  19234.      Instead of making one query for each table, execute all queries in
  19235.      1 query separately for each database. Table names will be in a
  19236.      comma separated list.
  19237.  
  19238. `-a, --analyze'
  19239.      Analyze given tables.
  19240.  
  19241. `--auto-repair'
  19242.      If a checked table is corrupted, automatically fix it. Repairing
  19243.      will be done after all tables have been checked, if corrupted ones
  19244.      were found.
  19245.  
  19246. `-#, --debug=...'
  19247.      Output debug log. Often this is 'd:t:o,filename'
  19248.  
  19249. `--character-sets-dir=...'
  19250.      Directory where character sets are
  19251.  
  19252. `-c, --check'
  19253.      Check table for errors
  19254.  
  19255. `-C, --check-only-changed'
  19256.      Check only tables that have changed since last check or haven't
  19257.      been closed properly.
  19258.  
  19259. `--compress'
  19260.      Use compression in server/client protocol.
  19261.  
  19262. `-?, --help'
  19263.      Display this help message and exit.
  19264.  
  19265. `-B, --databases'
  19266.      To check several databases. Note the difference in usage; In this
  19267.      case no tables are given. All name arguments are regarded as
  19268.      database names.
  19269.  
  19270. `--default-character-set=...'
  19271.      Set the default character set
  19272.  
  19273. `-F, --fast'
  19274.      Check only tables that hasn't been closed properly
  19275.  
  19276. `-f, --force'
  19277.      Continue even if we get an sql-error.
  19278.  
  19279. `-e, --extended'
  19280.      If you are using this option with CHECK TABLE, it will ensure that
  19281.      the table is 100 percent consistent, but will take a long time.
  19282.  
  19283.      If you are using this option with REPAIR TABLE, it will run an
  19284.      extended repair on the table, which may not only take a long time
  19285.      to execute, but may produce a lot of garbage rows also!
  19286.  
  19287. `-h, --host=...'
  19288.      Connect to host.
  19289.  
  19290. `-m, --medium-check'
  19291.      Faster than extended-check, but only finds 99.99 percent of all
  19292.      errors. Should be good enough for most cases.
  19293.  
  19294. `-o, --optimize'
  19295.      Optimize table
  19296.  
  19297. `-p, --password[=...]'
  19298.      Password to use when connecting to server. If password is not given
  19299.      it's solicited on the tty.
  19300.  
  19301. `-P, --port=...'
  19302.      Port number to use for connection.
  19303.  
  19304. `-q, --quick'
  19305.      If you are using this option with CHECK TABLE, it prevents the
  19306.      check from scanning the rows to check for wrong links. This is the
  19307.      fastest check.
  19308.  
  19309.      If you are using this option with REPAIR TABLE, it will try to
  19310.      repair only the index tree. This is the fastest repair method for
  19311.      a table.
  19312.  
  19313. `-r, --repair'
  19314.      Can fix almost anything except unique keys that aren't unique.
  19315.  
  19316. `-s, --silent'
  19317.      Print only error messages.
  19318.  
  19319. `-S, --socket=...'
  19320.      Socket file to use for connection.
  19321.  
  19322. `--tables'
  19323.      Overrides option -databases (-B).
  19324.  
  19325. `-u, --user=#'
  19326.      User for login if not current user.
  19327.  
  19328. `-v, --verbose'
  19329.      Print info about the various stages.
  19330.  
  19331. `-V, --version'
  19332.      Output version information and exit.
  19333.  
  19334. 
  19335. File: mysql.info,  Node: mysqldump,  Next: mysqlhotcopy,  Prev: Using mysqlcheck,  Up: Client-Side Scripts
  19336.  
  19337. mysqldump, Dumping Table Structure and Data
  19338. -------------------------------------------
  19339.  
  19340. Utility to dump a database or a collection of database for backup or for
  19341. transferring the data to another SQL server (not necessarily a MySQL
  19342. server).  The dump will contain SQL statements to create the table
  19343. and/or populate the table.
  19344.  
  19345. If you are doing a backup on the server, you should consider using the
  19346. `mysqlhotcopy' instead. *Note `mysqlhotcopy': mysqlhotcopy.
  19347.  
  19348.      shell> mysqldump [OPTIONS] database [tables]
  19349.      OR     mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
  19350.      OR     mysqldump [OPTIONS] --all-databases [OPTIONS]
  19351.  
  19352. If you don't give any tables or use the `--databases' or
  19353. `--all-databases', the whole database(s) will be dumped.
  19354.  
  19355. You can get a list of the options your version of `mysqldump' supports
  19356. by executing `mysqldump --help'.
  19357.  
  19358. Note that if you run `mysqldump' without `--quick' or `--opt',
  19359. `mysqldump' will load the whole result set into memory before dumping
  19360. the result.  This will probably be a problem if you are dumping a big
  19361. database.
  19362.  
  19363. Note that if you are using a new copy of the `mysqldump' program and
  19364. you are going to do a dump that will be read into a very old MySQL
  19365. server, you should not use the `--opt' or `-e' options.
  19366.  
  19367. `mysqldump' supports the following options:
  19368.  
  19369. `--add-locks'
  19370.      Add `LOCK TABLES' before and `UNLOCK TABLE' after each table dump.
  19371.      (To get faster inserts into MySQL.)
  19372.  
  19373. `--add-drop-table'
  19374.      Add a `drop table' before each create statement.
  19375.  
  19376. `-A, --all-databases'
  19377.      Dump all the databases. This will be same as `--databases' with all
  19378.      databases selected.
  19379.  
  19380. `-a, --all'
  19381.      Include all MySQL-specific create options.
  19382.  
  19383. `--allow-keywords'
  19384.      Allow creation of column names that are keywords.  This works by
  19385.      prefixing each column name with the table name.
  19386.  
  19387. `-c, --complete-insert'
  19388.      Use complete insert statements (with column names).
  19389.  
  19390. `-C, --compress'
  19391.      Compress all information between the client and the server if both
  19392.      support compression.
  19393.  
  19394. `-B, --databases'
  19395.      To dump several databases. Note the difference in usage. In this
  19396.      case no tables are given. All name arguments are regarded as
  19397.      database names.  `USE db_name;' will be included in the output
  19398.      before each new database.
  19399.  
  19400. `--delayed'
  19401.      Insert rows with the `INSERT DELAYED' command.
  19402.  
  19403. `-e, --extended-insert'
  19404.      Use the new multiline `INSERT' syntax. (Gives more compact and
  19405.      faster inserts statements.)
  19406.  
  19407. `-#, --debug[=option_string]'
  19408.      Trace usage of the program (for debugging).
  19409.  
  19410. `--help'
  19411.      Display a help message and exit.
  19412.  
  19413. `--fields-terminated-by=...'
  19414. `--fields-enclosed-by=...'
  19415. `--fields-optionally-enclosed-by=...'
  19416. `--fields-escaped-by=...'
  19417. `--lines-terminated-by=...'
  19418.      These options are used with the `-T' option and have the same
  19419.      meaning as the corresponding clauses for `LOAD DATA INFILE'.
  19420.      *Note `LOAD DATA': LOAD DATA.
  19421.  
  19422. `-F, --flush-logs'
  19423.      Flush log file in the MySQL server before starting the dump.
  19424.  
  19425. `-f, --force,'
  19426.      Continue even if we get a SQL error during a table dump.
  19427.  
  19428. `-h, --host=..'
  19429.      Dump data from the MySQL server on the named host. The default host
  19430.      is `localhost'.
  19431.  
  19432. `-l, --lock-tables.'
  19433.      Lock all tables before starting the dump.  The tables are locked
  19434.      with `READ LOCAL' to allow concurrent inserts in the case of
  19435.      `MyISAM' tables.
  19436.  
  19437. `-n, --no-create-db'
  19438.      'CREATE DATABASE /*!32312 IF NOT EXISTS*/ db_name;' will not be
  19439.      put in the output. The above line will be added otherwise, if
  19440.      -databases or -all-databases option was given.
  19441.  
  19442. `-t, --no-create-info'
  19443.      Don't write table creation information (The `CREATE TABLE'
  19444.      statement.)
  19445.  
  19446. `-d, --no-data'
  19447.      Don't write any row information for the table.  This is very
  19448.      useful if you just want to get a dump of the structure for a table!
  19449.  
  19450. `--opt'
  19451.      Same as `--quick --add-drop-table --add-locks --extended-insert
  19452.      --lock-tables'.  Should give you the fastest possible dump for
  19453.      reading into a MySQL server.
  19454.  
  19455. `-pyour_pass, --password[=your_pass]'
  19456.      The password to use when connecting to the server. If you specify
  19457.      no `=your_pass' part, `mysqldump' you will be prompted for a
  19458.      password.
  19459.  
  19460. `-P port_num, --port=port_num'
  19461.      The TCP/IP port number to use for connecting to a host.  (This is
  19462.      used for connections to hosts other than `localhost', for which
  19463.      Unix sockets are used.)
  19464.  
  19465. `-q, --quick'
  19466.      Don't buffer query, dump directly to stdout. Uses
  19467.      `mysql_use_result()' to do this.
  19468.  
  19469. `-r, --result-file=...'
  19470.      Direct output to a given file. This option should be used in MSDOS,
  19471.      because it prevents new line '\n' from being converted to '\n\r'
  19472.      (new line + carriage return).
  19473.  
  19474. `-S /path/to/socket, --socket=/path/to/socket'
  19475.      The socket file to use when connecting to `localhost' (which is the
  19476.      default host).
  19477.  
  19478. `--tables'
  19479.      Overrides option -databases (-B).
  19480.  
  19481. `-T, --tab=path-to-some-directory'
  19482.      Creates a `table_name.sql' file, that contains the SQL CREATE
  19483.      commands, and a `table_name.txt' file, that contains the data, for
  19484.      each give table.  *NOTE*: This only works if `mysqldump' is run on
  19485.      the same machine as the `mysqld' daemon.  The format of the `.txt'
  19486.      file is made according to the `--fields-xxx' and `--lines--xxx'
  19487.      options.
  19488.  
  19489. `-u user_name, --user=user_name'
  19490.      The MySQL user name to use when connecting to the server. The
  19491.      default value is your Unix login name.
  19492.  
  19493. `-O var=option, --set-variable var=option'
  19494.      Set the value of a variable.  The possible variables are listed
  19495.      below.
  19496.  
  19497. `-v, --verbose'
  19498.      Verbose mode.  Print out more information on what the program does.
  19499.  
  19500. `-V, --version'
  19501.      Print version information and exit.
  19502.  
  19503. `-w, --where='where-condition''
  19504.      Dump only selected records. Note that QUOTES are mandatory:
  19505.  
  19506.           "--where=user='jimf'" "-wuserid>1" "-wuserid<1"
  19507.  
  19508. `-O net_buffer_length=#, where # < 16M'
  19509.      When creating multi-row-insert statements (as with option
  19510.      `--extended-insert' or `--opt'), `mysqldump' will create rows up
  19511.      to `net_buffer_length' length. If you increase this variable, you
  19512.      should also ensure that the `max_allowed_packet' variable in the
  19513.      MySQL server is bigger than the `net_buffer_length'.
  19514.  
  19515. The most normal use of `mysqldump' is probably for making a backup of
  19516. whole databases. *Note Backup::.
  19517.  
  19518.      mysqldump --opt database > backup-file.sql
  19519.  
  19520. You can read this back into MySQL with:
  19521.  
  19522.      mysql database < backup-file.sql
  19523.  
  19524. or
  19525.  
  19526.      mysql -e "source /patch-to-backup/backup-file.sql" database
  19527.  
  19528. However, it's also very useful to populate another MySQL server with
  19529. information from a database:
  19530.  
  19531.      mysqldump --opt database | mysql ---host=remote-host -C database
  19532.  
  19533. It is possible to dump several databases with one command:
  19534.  
  19535.      mysqldump --databases database1 [database2 database3...] > my_databases.sql
  19536.  
  19537. If all the databases are wanted, one can use:
  19538.  
  19539.      mysqldump --all-databases > all_databases.sql
  19540.  
  19541. 
  19542. File: mysql.info,  Node: mysqlhotcopy,  Next: mysqlimport,  Prev: mysqldump,  Up: Client-Side Scripts
  19543.  
  19544. mysqlhotcopy, Copying MySQL Databases and Tables
  19545. ------------------------------------------------
  19546.  
  19547. `mysqlhotcopy' is a perl script that uses `LOCK TABLES', `FLUSH TABLES'
  19548. and `cp' or `scp' to quickly make a backup of a database.  It's the
  19549. fastest way to make a backup of the database, of single tables but it
  19550. can only be run on the same machine where the database directories are.
  19551.  
  19552.      mysqlhotcopy db_name [/path/to/new_directory]
  19553.      
  19554.      mysqlhotcopy db_name_1 ... db_name_n /path/to/new_directory
  19555.      
  19556.      mysqlhotcopy db_name./regex/
  19557.  
  19558. `mysqlhotcopy' supports the following options:
  19559.  
  19560. `-?, --help'
  19561.      Display a help screen and exit
  19562.  
  19563. `-u, --user=#'
  19564.      User for database login
  19565.  
  19566. `-p, --password=#'
  19567.      Password to use when connecting to server
  19568.  
  19569. `-P, --port=#'
  19570.      Port to use when connecting to local server
  19571.  
  19572. `-S, --socket=#'
  19573.      Socket to use when connecting to local server
  19574.  
  19575. `--allowold'
  19576.      Don't abort if target already exists (rename it _old)
  19577.  
  19578. `--keepold'
  19579.      Don't delete previous (now renamed) target when done
  19580.  
  19581. `--noindices'
  19582.      Don't include full index files in copy to make the backup smaller
  19583.      and faster The indexes can later be reconstructed with `myisamchk
  19584.      -rq.'.
  19585.  
  19586. `--method=#'
  19587.      Method for copy (`cp' or `scp').
  19588.  
  19589. `-q, --quiet'
  19590.      Be silent except for errors
  19591.  
  19592. `--debug'
  19593.      Enable debug
  19594.  
  19595. `-n, --dryrun'
  19596.      Report actions without doing them
  19597.  
  19598. `--regexp=#'
  19599.      Copy all databases with names matching regexp
  19600.  
  19601. `--suffix=#'
  19602.      Suffix for names of copied databases
  19603.  
  19604. `--checkpoint=#'
  19605.      Insert checkpoint entry into specified db.table
  19606.  
  19607. `--flushlog'
  19608.      Flush logs once all tables are locked.
  19609.  
  19610. `--tmpdir=#'
  19611.      Temporary directory (instead of /tmp).
  19612.  
  19613. You can use `perldoc mysqlhotcopy' to get a more complete documentation
  19614. for `mysqlhotcopy'.
  19615.  
  19616. `mysqlhotcopy' reads the groups `[client]' and  `[mysqlhotcopy]' from
  19617. the option files.
  19618.  
  19619. To be able to execute `mysqlhotcopy' you need write access to the
  19620. backup directory, `SELECT' privilege to the tables you are about to
  19621. copy and the MySQL `Reload' privilege (to be able to execute `FLUSH
  19622. TABLES').
  19623.  
  19624. 
  19625. File: mysql.info,  Node: mysqlimport,  Next: mysqlshow,  Prev: mysqlhotcopy,  Up: Client-Side Scripts
  19626.  
  19627. mysqlimport, Importing Data from Text Files
  19628. -------------------------------------------
  19629.  
  19630. `mysqlimport' provides a command-line interface to the `LOAD DATA
  19631. INFILE' SQL statement.  Most options to `mysqlimport' correspond
  19632. directly to the same options to `LOAD DATA INFILE'.  *Note `LOAD DATA':
  19633. LOAD DATA.
  19634.  
  19635. `mysqlimport' is invoked like this:
  19636.  
  19637.      shell> mysqlimport [options] database textfile1 [textfile2....]
  19638.  
  19639. For each text file named on the command line, `mysqlimport' strips any
  19640. extension from the filename and uses the result to determine which
  19641. table to import the file's contents into.  For example, files named
  19642. `patient.txt', `patient.text', and `patient' would all be imported into
  19643. a table named `patient'.
  19644.  
  19645. `mysqlimport' supports the following options:
  19646.  
  19647. `-c, --columns=...'
  19648.      This option takes a comma-separated list of field names as an
  19649.      argument.  The field list is used to create a proper `LOAD DATA
  19650.      INFILE' command, which is then passed to MySQL. *Note `LOAD DATA':
  19651.      LOAD DATA.
  19652.  
  19653. `-C, --compress'
  19654.      Compress all information between the client and the server if both
  19655.      support compression.
  19656.  
  19657. `-#, --debug[=option_string]'
  19658.      Trace usage of the program (for debugging).
  19659.  
  19660. `-d, --delete'
  19661.      Empty the table before importing the text file.
  19662.  
  19663. `--fields-terminated-by=...'
  19664. `--fields-enclosed-by=...'
  19665. `--fields-optionally-enclosed-by=...'
  19666. `--fields-escaped-by=...'
  19667. `--lines-terminated-by=...'
  19668.      These options have the same meaning as the corresponding clauses
  19669.      for `LOAD DATA INFILE'. *Note `LOAD DATA': LOAD DATA.
  19670.  
  19671. `-f, --force'
  19672.      Ignore errors.  For example, if a table for a text file doesn't
  19673.      exist, continue processing any remaining files.  Without `--force',
  19674.      `mysqlimport' exits if a table doesn't exist.
  19675.  
  19676. `--help'
  19677.      Display a help message and exit.
  19678.  
  19679. `-h host_name, --host=host_name'
  19680.      Import data to the MySQL server on the named host. The default host
  19681.      is `localhost'.
  19682.  
  19683. `-i, --ignore'
  19684.      See the description for the `--replace' option.
  19685.  
  19686. `-l, --lock-tables'
  19687.      Lock *ALL* tables for writing before processing any text files.
  19688.      This ensures that all tables are synchronized on the server.
  19689.  
  19690. `-L, --local'
  19691.      Read input files from the client.  By default, text files are
  19692.      assumed to be on the server if you connect to `localhost' (which
  19693.      is the default host).
  19694.  
  19695. `-pyour_pass, --password[=your_pass]'
  19696.      The password to use when connecting to the server. If you specify
  19697.      no `=your_pass' part, `mysqlimport' you will be prompted for a
  19698.      password.
  19699.  
  19700. `-P port_num, --port=port_num'
  19701.      The TCP/IP port number to use for connecting to a host.  (This is
  19702.      used for connections to hosts other than `localhost', for which
  19703.      Unix sockets are used.)
  19704.  
  19705. `-r, --replace'
  19706.      The `--replace' and `--ignore' options control handling of input
  19707.      records that duplicate existing records on unique key values.  If
  19708.      you specify `--replace', new rows replace existing rows that have
  19709.      the same unique key value. If you specify `--ignore', input rows
  19710.      that duplicate an existing row on a unique key value are skipped.
  19711.      If you don't specify either option, an error occurs when a
  19712.      duplicate key value is found, and the rest of the text file is
  19713.      ignored.
  19714.  
  19715. `-s, --silent'
  19716.      Silent mode.  Write output only when errors occur.
  19717.  
  19718. `-S /path/to/socket, --socket=/path/to/socket'
  19719.      The socket file to use when connecting to `localhost' (which is the
  19720.      default host).
  19721.  
  19722. `-u user_name, --user=user_name'
  19723.      The MySQL user name to use when connecting to the server. The
  19724.      default value is your Unix login name.
  19725.  
  19726. `-v, --verbose'
  19727.      Verbose mode.  Print out more information what the program does.
  19728.  
  19729. `-V, --version'
  19730.      Print version information and exit.
  19731.  
  19732. Here is a sample run using `mysqlimport':
  19733.  
  19734.      $ mysql --version
  19735.      mysql  Ver 9.33 Distrib 3.22.25, for pc-linux-gnu (i686)
  19736.      $ uname -a
  19737.      Linux xxx.com 2.2.5-15 #1 Mon Apr 19 22:21:09 EDT 1999 i586 unknown
  19738.      $ mysql -e 'CREATE TABLE imptest(id INT, n VARCHAR(30))' test
  19739.      $ ed
  19740.      a
  19741.      100     Max Sydow
  19742.      101     Count Dracula
  19743.      .
  19744.      w imptest.txt
  19745.      32
  19746.      q
  19747.      $ od -c imptest.txt
  19748.      0000000   1   0   0  \t   M   a   x       S   y   d   o   w  \n   1   0
  19749.      0000020   1  \t   C   o   u   n   t       D   r   a   c   u   l   a  \n
  19750.      0000040
  19751.      $ mysqlimport --local test imptest.txt
  19752.      test.imptest: Records: 2  Deleted: 0  Skipped: 0  Warnings: 0
  19753.      $ mysql -e 'SELECT * FROM imptest' test
  19754.      +------+---------------+
  19755.      | id   | n             |
  19756.      +------+---------------+
  19757.      |  100 | Max Sydow     |
  19758.      |  101 | Count Dracula |
  19759.      +------+---------------+
  19760.  
  19761. 
  19762. File: mysql.info,  Node: mysqlshow,  Next: perror,  Prev: mysqlimport,  Up: Client-Side Scripts
  19763.  
  19764. Showing Databases, Tables, and Columns
  19765. --------------------------------------
  19766.  
  19767. `mysqlshow' can be used to quickly look at which databases exist, their
  19768. tables, and the table's columns.
  19769.  
  19770. With the `mysql' program you can get the same information with the
  19771. `SHOW' commands.  *Note SHOW::.
  19772.  
  19773. `mysqlshow' is invoked like this:
  19774.  
  19775.      shell> mysqlshow [OPTIONS] [database [table [column]]]
  19776.  
  19777.    * If no database is given, all matching databases are shown.
  19778.  
  19779.    * If no table is given, all matching tables in the database are
  19780.      shown.
  19781.  
  19782.    * If no column is given, all matching columns and column types in
  19783.      the table are shown.
  19784.  
  19785. Note that in newer MySQL versions, you only see those
  19786. database/tables/columns for which you have some privileges.
  19787.  
  19788. If the last argument contains a shell or SQL wild-card (`*', `?', `%'
  19789. or `_') then only what's matched by the wild card is shown.  This may
  19790. cause some confusion when you try to display the columns for a table
  19791. with a `_' as in this case `mysqlshow' only shows you the table names
  19792. that match the pattern.  This is easily fixed by adding an extra `%'
  19793. last on the command line (as a separate argument).
  19794.  
  19795. 
  19796. File: mysql.info,  Node: perror,  Next: Batch Commands,  Prev: mysqlshow,  Up: Client-Side Scripts
  19797.  
  19798. perror, Explaining Error Codes
  19799. ------------------------------
  19800.  
  19801. `perror' can be used to print error message(s). `perror' can be invoked
  19802. like this:
  19803.  
  19804.      shell> perror [OPTIONS] [ERRORCODE [ERRORCODE...]]
  19805.      
  19806.      For example:
  19807.      
  19808.      shell> perror 64 79
  19809.      Error code  64:  Machine is not on the network
  19810.      Error code  79:  Can not access a needed shared library
  19811.  
  19812. `perror' can be used to display a description for a system error code,
  19813. or an MyISAM/ISAM table handler error code. The error messages are
  19814. mostly system dependent.
  19815.  
  19816. 
  19817. File: mysql.info,  Node: Batch Commands,  Prev: perror,  Up: Client-Side Scripts
  19818.  
  19819. How to Run SQL Commands from a Text File
  19820. ----------------------------------------
  19821.  
  19822. The `mysql' client typically is used interactively, like this:
  19823.  
  19824.      shell> mysql database
  19825.  
  19826. However, it's also possible to put your SQL commands in a file and tell
  19827. `mysql' to read its input from that file.  To do so, create a text file
  19828. `text_file' that contains the commands you wish to execute.  Then
  19829. invoke `mysql' as shown below:
  19830.  
  19831.      shell> mysql database < text_file
  19832.  
  19833. You can also start your text file with a `USE db_name' statement.  In
  19834. this case, it is unnecessary to specify the database name on the command
  19835. line:
  19836.  
  19837.      shell> mysql < text_file
  19838.  
  19839. *Note Client-Side Scripts::.
  19840.  
  19841. 
  19842. File: mysql.info,  Node: Log Files,  Next: Replication,  Prev: Client-Side Scripts,  Up: MySQL Database Administration
  19843.  
  19844. The MySQL Log Files
  19845. ===================
  19846.  
  19847. MySQL has several different log files that can help you find out what's
  19848. going on inside `mysqld':
  19849.  
  19850. The error log          Problems encountering starting, running or
  19851.                        stopping `mysqld'.
  19852. The isam log           Logs all changes to the ISAM tables. Used only
  19853.                        for debugging the isam code.
  19854. The query log          Established connections and executed queries.
  19855. The update log         Deprecated: Stores all statements that changes
  19856.                        data
  19857. The binary log         Stores all statements that changes something.
  19858.                        Used also for replication
  19859. The slow log           Stores all queries that took more than
  19860.                        `long_query_time' to execute or didn't use
  19861.                        indexes.
  19862.  
  19863. All logs can be found in the `mysqld' data directory.  You can force
  19864. `mysqld' to reopen the log files (or in some cases switch to a new log)
  19865. by executing `FLUSH LOGS'. *Note FLUSH::.
  19866.  
  19867. * Menu:
  19868.  
  19869. * Error log::                   The Error Log
  19870. * Query log::                   The General Query Log
  19871. * Update log::                  The Update Log
  19872. * Binary log::                  The Binary Update Log
  19873. * Slow query log::              The Slow Query Log
  19874. * Log file maintenance::        Log File Maintenance
  19875.  
  19876. 
  19877. File: mysql.info,  Node: Error log,  Next: Query log,  Prev: Log Files,  Up: Log Files
  19878.  
  19879. The Error Log
  19880. -------------
  19881.  
  19882. `mysqld' writes all errors to the stderr, which the `safe_mysqld'
  19883. script redirects to a file called `'hostname'.err'.  (On Windows,
  19884. `mysqld' writes this directly to `\mysql\data\mysql.err').
  19885.  
  19886. This contains information indicating when `mysqld' was started and
  19887. stopped and also any critical errors found when running.  If `mysqld'
  19888. dies unexpectedly and `safe_mysqld' needs to restart `mysqld',
  19889. `safe_mysqld' will write a `restarted mysqld' row in this file.  This
  19890. log also holds a warning if `mysqld' notices a table that needs to be
  19891. automatically checked or repaired.
  19892.  
  19893. On some operating systems, the error log will contain a stack trace for
  19894. where `mysqld' died. This can be used to find out where `mysqld' died.
  19895. *Note Using stack trace::.
  19896.  
  19897. 
  19898. File: mysql.info,  Node: Query log,  Next: Update log,  Prev: Error log,  Up: Log Files
  19899.  
  19900. The General Query Log
  19901. ---------------------
  19902.  
  19903. If you want to know what happens within `mysqld', you should start it
  19904. with `--log[=file]'.  This will log all connections and queries to the
  19905. log file (by default named `'hostname'.log').  This log can be very
  19906. useful when you suspect an error in a client and want to know exactly
  19907. what `mysqld' thought the client sent to it.
  19908.  
  19909. By default, the `mysql.server' script starts the MySQL server with the
  19910. `-l' option.  If you need better performance when you start using MySQL
  19911. in a production environment, you can remove the `-l' option from
  19912. `mysql.server' or change it to `--log-bin'.
  19913.  
  19914. The entries in this log are written as `mysqld' receives the questions.
  19915. This may be different than the order in which the statements are
  19916. executed.  This is in contrast to the update log and the binary log
  19917. which are written after the query is executed, but before any locks are
  19918. released.
  19919.  
  19920. 
  19921. File: mysql.info,  Node: Update log,  Next: Binary log,  Prev: Query log,  Up: Log Files
  19922.  
  19923. The Update Log
  19924. --------------
  19925.  
  19926. *NOTE*: The update log is replaced by the binary log. *Note Binary
  19927. log::.  With this you can do anything that you can do with the update
  19928. log.
  19929.  
  19930. When started with the `--log-update[=file_name]' option, `mysqld'
  19931. writes a log file containing all SQL commands that update data. If no
  19932. filename is given, it defaults to the name of the host machine. If a
  19933. filename is given, but it doesn't contain a path, the file is written
  19934. in the data directory. If `file_name' doesn't have an extension,
  19935. `mysqld' will create log file names like so: `file_name.###', where
  19936. `###' is a number that is incremented each time you execute `mysqladmin
  19937. refresh', execute `mysqladmin flush-logs', execute the `FLUSH LOGS'
  19938. statement, or restart the server.
  19939.  
  19940. *NOTE:* For the above scheme to work, you should NOT create your own
  19941. files with the same filename as the update log + some extensions that
  19942. may be regarded as a number, in the directory used by the update log!
  19943.  
  19944. If you use the `--log' or `-l' options, `mysqld' writes a general log
  19945. with a filename of `hostname.log', and restarts and refreshes do not
  19946. cause a new log file to be generated (although it is closed and
  19947. reopened). In this case you can copy it (on Unix) by doing:
  19948.  
  19949.      mv hostname.log hostname-old.log
  19950.      mysqladmin flush-logs
  19951.      cp hostname-old.log to-backup-directory
  19952.      rm hostname-old.log
  19953.  
  19954. Update logging is smart because it logs only statements that really
  19955. update data. So an `UPDATE' or a `DELETE' with a `WHERE' that finds no
  19956. rows is not written to the log. It even skips `UPDATE' statements that
  19957. set a column to the value it already has.
  19958.  
  19959. The update logging is done immediately after a query completes but
  19960. before any locks are released or any commit is done. This ensures that
  19961. the log will be logged in the execution order.
  19962.  
  19963. If you want to update a database from update log files, you could do the
  19964. following (assuming your update logs have names of the form
  19965. `file_name.###'):
  19966.  
  19967.      shell> ls -1 -t -r file_name.[0-9]* | xargs cat | mysql
  19968.  
  19969. `ls' is used to get all the log files in the right order.
  19970.  
  19971. This can be useful if you have to revert to backup files after a crash
  19972. and you want to redo the updates that occurred between the time of the
  19973. backup and the crash.
  19974.  
  19975. 
  19976. File: mysql.info,  Node: Binary log,  Next: Slow query log,  Prev: Update log,  Up: Log Files
  19977.  
  19978. The Binary Update Log
  19979. ---------------------
  19980.  
  19981. The intention is that the binary log should replace the update log, so
  19982. we recommend you to switch to this log format as soon as possible!
  19983.  
  19984. The binary log contains all information that is available in the update
  19985. log in a more efficient format. It also contains information about how
  19986. long every query that updated the database took.
  19987.  
  19988. The binary log is also used when you are replicating a slave from a
  19989. master.  *Note Replication::.
  19990.  
  19991. When started with the `--log-bin[=file_name]' option, `mysqld' writes a
  19992. log file containing all SQL commands that update data. If no file name
  19993. is given, it defaults to the name of the host machine followed by
  19994. `-bin'. If file name is given, but it doesn't contain a path, the file
  19995. is written in the data directory.
  19996.  
  19997. If you supply an extension to `--log-bin=filename.extension', the
  19998. extension will be silenty removed.
  19999.  
  20000. To the binary log filename `mysqld' will append an extension that is a
  20001. number that is incremented each time you execute `mysqladmin refresh',
  20002. execute `mysqladmin flush-logs', execute the `FLUSH LOGS' statement or
  20003. restart the server.
  20004.  
  20005. You can use the following options to `mysqld' to affect what is logged
  20006. to the binary log:
  20007.  
  20008. `binlog-do-db=database_name'   Tells the master it should log updates
  20009.                               for the specified database, and exclude
  20010.                               all others not explicitly mentioned.
  20011.                               (Example: `binlog-do-db=some_database')
  20012. `binlog-ignore-db=database_name' Tells the master that updates to the
  20013.                               given database should not be logged to the
  20014.                               binary log (Example:
  20015.                               `binlog-ignore-db=some_database')
  20016.  
  20017. To be able to know which different binary log files have been used,
  20018. `mysqld' will also create a binary log index file that contains the
  20019. name of all used binary log files. By default this has the same name as
  20020. the binary log file, with the extension `'.index''.  You can change the
  20021. name of the binary log index file with the `--log-bin-index=[filename]'
  20022. option.
  20023.  
  20024. If you are using replication, you should not delete old binary log
  20025. files until you are sure that no slave will ever need to use them.  One
  20026. way to do this is to do `mysqladmin flush-logs' once a day and then
  20027. remove any logs that are more than 3 days old.
  20028.  
  20029. You can examine the binary log file with the `mysqlbinlog' command.
  20030. For example, you can update a MySQL server from the binary log as
  20031. follows:
  20032.  
  20033.      mysqlbinlog log-file | mysql -h server_name
  20034.  
  20035. You can also use the `mysqlbinlog' program to read the binary log
  20036. directly from a remote MySQL server!
  20037.  
  20038. `mysqlbinlog --help' will give you more information of how to use this
  20039. program!
  20040.  
  20041. If you are using `BEGIN [WORK]' or `SET AUTOCOMMIT=0', you must use the
  20042. MySQL binary log for backups instead of the old update log.
  20043.  
  20044. The binary logging is done immediately after a query completes but
  20045. before any locks are released or any commit is done. This ensures that
  20046. the log will be logged in the execution order.
  20047.  
  20048. All updates (`UPDATE', `DELETE' or `INSERT') that change a
  20049. transactional table (like BDB tables) are cached until a `COMMIT'.  Any
  20050. updates to a non-transactional table are stored in the binary log at
  20051. once.  Every thread will, on start, allocate a buffer of
  20052. `binlog_cache_size' to buffer queries.  If a query is bigger than this,
  20053. the thread will open a temporary file to handle the bigger cache.  The
  20054. temporary file will be deleted when the thread ends.
  20055.  
  20056. The `max_binlog_cache_size' can be used to restrict the total size used
  20057. to cache a multi-transaction query.
  20058.  
  20059. If you are using the update or binary log, concurrent inserts will not
  20060. work together with `CREATE ... INSERT' and `INSERT ... SELECT'.  This
  20061. is to ensure that you can recreate an exact copy of your tables by
  20062. applying the log on a backup.
  20063.  
  20064. 
  20065. File: mysql.info,  Node: Slow query log,  Next: Log file maintenance,  Prev: Binary log,  Up: Log Files
  20066.  
  20067. The Slow Query Log
  20068. ------------------
  20069.  
  20070. When started with the `--log-slow-queries[=file_name]' option, `mysqld'
  20071. writes a log file containing all SQL commands that took more than
  20072. `long_query_time' to execute. The time to get the initial table locks
  20073. are not counted as execution time.
  20074.  
  20075. The slow query log is logged after the query is executed and after all
  20076. locks has been released. This may be different than the order in which
  20077. the statements are executed.
  20078.  
  20079. If no file name is given, it defaults to the name of the host machine
  20080. suffixed with `-slow.log'. If a filename is given, but doesn't contain
  20081. a path, the file is written in the data directory.
  20082.  
  20083. The slow query log can be used to find queries that take a long time to
  20084. execute and are thus candidates for optimization. With a large log, that
  20085. can become a difficult task. You can pipe the slow query log through the
  20086. `mysqldumpslow' command to get a summary of the queries which appear in
  20087. the log.
  20088.  
  20089. You are using `--log-long-format' then also queries that are not using
  20090. indexes are printed. *Note Command-line options::.
  20091.  
  20092. 
  20093. File: mysql.info,  Node: Log file maintenance,  Prev: Slow query log,  Up: Log Files
  20094.  
  20095. Log File Maintenance
  20096. --------------------
  20097.  
  20098. MySQL has a lot of log files which make it easy to see what is going.
  20099. *Note Log Files::. One must however from time to time clean up after
  20100. `MysQL' to ensure that the logs don't take up too much disk space.
  20101.  
  20102. When using MySQL with log files, you will, from time to time, want to
  20103. remove/backup old log files and tell MySQL to start logging on new
  20104. files.  *Note Backup::.
  20105.  
  20106. On a Linux (`Redhat') installation, you can use the `mysql-log-rotate'
  20107. script for this. If you installed MySQL from an RPM distribution, the
  20108. script should have been installed automatically.  Note that you should
  20109. be careful with this if you are using the log for replication!
  20110.  
  20111. On other systems you must install a short script yourself that you
  20112. start from `cron' to handle log files.
  20113.  
  20114. You can force MySQL to start using new log files by using `mysqladmin
  20115. flush-logs' or by using the SQL command `FLUSH LOGS'.  If you are using
  20116. MySQL Version 3.21 you must use `mysqladmin refresh'.
  20117.  
  20118. The above command does the following:
  20119.  
  20120.    * If standard logging (`--log') or slow query logging
  20121.      (`--log-slow-queries') is used, closes and reopens the log file.
  20122.      (`mysql.log' and ``hostname`-slow.log' as default).
  20123.  
  20124.    * If update logging (`--log-update') is used, closes the update log
  20125.      and opens a new log file with a higher sequence number.
  20126.  
  20127. If you are using only an update log, you only have to flush the logs
  20128. and then move away the old update log files to a backup.  If you are
  20129. using the normal logging, you can do something like:
  20130.  
  20131.      shell> cd mysql-data-directory
  20132.      shell> mv mysql.log mysql.old
  20133.      shell> mysqladmin flush-logs
  20134.  
  20135. and then take a backup and remove `mysql.old'.
  20136.  
  20137. 
  20138. File: mysql.info,  Node: Replication,  Prev: Log Files,  Up: MySQL Database Administration
  20139.  
  20140. Replication in MySQL
  20141. ====================
  20142.  
  20143. * Menu:
  20144.  
  20145. * Replication Intro::           Introduction
  20146. * Replication Implementation::  Replication Implementation Overview
  20147. * Replication HOWTO::           How To Set Up Replication
  20148. * Replication Features::        Replication Features and Known Problems
  20149. * Replication Options::         Replication Options in my.cnf
  20150. * Replication SQL::             SQL Commands Related to Replication
  20151. * Replication FAQ::             Replication FAQ
  20152. * Replication Problems::        Troubleshooting Replication
  20153.  
  20154. This chapter describes the various replication features in MySQL.  It
  20155. serves as a reference to the options available with replication.  You
  20156. will be introduced to replication and learn how to implement it.
  20157. Towards the end, there are some frequently asked questions and
  20158. descriptions of problems and how to solve them.
  20159.  
  20160. 
  20161. File: mysql.info,  Node: Replication Intro,  Next: Replication Implementation,  Prev: Replication,  Up: Replication
  20162.  
  20163. Introduction
  20164. ------------
  20165.  
  20166. One way replication can be used is to increase both robustness and
  20167. speed. For robustness you can have two systems and can switch to the
  20168. backup if you have problems with the master. The extra speed is
  20169. achieved by sending a part of the non-updating queries to the replica
  20170. server. Of course this only works if non-updating queries dominate, but
  20171. that is the normal case.
  20172.  
  20173. Starting in Version 3.23.15, MySQL supports one-way replication
  20174. internally. One server acts as the master, while the other acts as the
  20175. slave. Note that one server could play the roles of master in one pair
  20176. and slave in the other. The master server keeps a binary log of updates
  20177. (*Note Binary log::.) and an index file to binary logs to keep track of
  20178. log rotation.  The slave, upon connecting, informs the master where it
  20179. left off since the last successfully propagated update, catches up on
  20180. the updates, and then blocks and waits for the master to notify it of
  20181. the new updates.
  20182.  
  20183. Note that if you are replicating a database, all updates to this
  20184. database should be done through the master!
  20185.  
  20186. Another benefit of using replication is that one can get live backups of
  20187. the system by doing a backup on a slave instead of doing it on the
  20188. master. *Note Backup::.
  20189.  
  20190. 
  20191. File: mysql.info,  Node: Replication Implementation,  Next: Replication HOWTO,  Prev: Replication Intro,  Up: Replication
  20192.  
  20193. Replication Implementation Overview
  20194. -----------------------------------
  20195.  
  20196. MySQL replication is based on the server keeping track of all changes
  20197. to your database (updates, deletes, etc) in the binary log. (*Note
  20198. Binary log::.) and the slave server(s) reading the saved queries from
  20199. the master server's binary log so that the slave can execute the same
  20200. queries on its copy of the data.
  20201.  
  20202. It is *very important* to realize that the binary log is simply a
  20203. record starting from a fixed point in time (the moment you enable binary
  20204. logging). Any slaves which you set up will need copies of all the data
  20205. from your master as it existed the moment that you enabled binary
  20206. logging on the master. If you start your slaves with data that doesn't
  20207. agree with what was on the master *when the binary log was started*,
  20208. your slaves may fail.
  20209.  
  20210. A future version (4.0) of MySQL will remove the need to keep a
  20211. (possibly large) snapshot of data for new slaves that you might wish to
  20212. set up through the live backup functionality with no locking required.
  20213. However, at this time, it is necessary to block all writes either with a
  20214. global read lock or by shutting down the master while taking a snapshot.
  20215.  
  20216. Once a slave is properly configured and running, it will simply connect
  20217. to the master and wait for updates to process. If the master goes away
  20218. or the slave loses connectivity with your master, it will keep trying to
  20219. connect every `master-connect-retry' seconds until it is able to
  20220. reconnect and resume listening for updates.
  20221.  
  20222. Each slave keeps track of where it left off. The master server has no
  20223. knowledge of how many slaves there are or which ones are up-to-date at
  20224. any given time.
  20225.  
  20226. The next section explains the master/slave setup process in more detail.
  20227.  
  20228. 
  20229. File: mysql.info,  Node: Replication HOWTO,  Next: Replication Features,  Prev: Replication Implementation,  Up: Replication
  20230.  
  20231. How To Set Up Replication
  20232. -------------------------
  20233.  
  20234. Below is a quick description of how to set up complete replication on
  20235. your current MySQL server. It assumes you want to replicate all your
  20236. databases and have not configured replication before. You will need to
  20237. shutdown your master server briefly to complete the steps outlined
  20238. below.
  20239.  
  20240.   1. Make sure you have a recent version of MySQL installed on the
  20241.      master and slave(s).
  20242.  
  20243.      Use Version 3.23.29 or higher. Previous releases used a different
  20244.      binary log format and had bugs which have been fixed in newer
  20245.      releases. Please, do not report bugs until you have verified that
  20246.      the problem is present in the latest release.
  20247.  
  20248.   2. Set up special a replication user on the master with the `FILE'
  20249.      privilege and permission to connect from all the slaves. If the
  20250.      user is only doing replication (which is recommended), you don't
  20251.      need to grant any additional privileges.
  20252.  
  20253.      For example, to create a user named `repl' which can access your
  20254.      master from any host, you might use this command:
  20255.  
  20256.           GRANT FILE ON *.* TO repl@"%" IDENTIFIED BY '<password>';
  20257.  
  20258.   3. Shut down MySQL on the master.
  20259.  
  20260.           mysqladmin -u root -p<password> shutdown
  20261.  
  20262.   4. Snapshot all the data on your master server.
  20263.  
  20264.      The easiest way to do this (on Unix) is to simply use *tar* to
  20265.      produce an archive of your entire data directory. The exact data
  20266.      directory location depends on your installation.
  20267.  
  20268.           tar -cvf /tmp/mysql-snapshot.tar /path/to/data-dir
  20269.  
  20270.      Windows users can use WinZip or similar software to create an
  20271.      archive of the data directory.
  20272.  
  20273.   5. In `my.cnf' on the master add `log-bin' and `server-id=unique
  20274.      number' to the `[mysqld]' section and restart it. It is very
  20275.      important that the id of the slave is different from the id of the
  20276.      master. Think of `server-id' as something similar to the IP
  20277.      address - it uniquely identifies the server instance in the
  20278.      community of replication partners.
  20279.  
  20280.           [mysqld]
  20281.           log-bin
  20282.           server-id=1
  20283.  
  20284.   6. Restart MySQL on the master.
  20285.  
  20286.   7. Add the following to `my.cnf' on the slave(s):
  20287.  
  20288.           master-host=<hostname of the master>
  20289.           master-user=<replication user name>
  20290.           master-password=<replication user password>
  20291.           master-port=<TCP/IP port for master>
  20292.           server-id=<some unique number between 2 and 2^32-1>
  20293.  
  20294.      replacing the values in <> with what is relevant to your system.
  20295.  
  20296.      `server-id' must be different for each server participating in
  20297.      replication.  If you don't specify a server-id, it will be set to
  20298.      1 if you have not defined `master-host', else it will be set to 2.
  20299.      Note that in the case of `server-id' omission the master will
  20300.      refuse connections from all slaves, and the slave will refuse to
  20301.      connect to a master. Thus, omitting `server-id' is only good for
  20302.      backup with a binary log.
  20303.  
  20304.   8. Copy the snapshot data into your data directory on your slave(s).
  20305.      Make sure that the privileges on the files and directories are
  20306.      correct. The user which MySQL runs as needs to be able to read and
  20307.      write to them, just as on the master.
  20308.  
  20309.   9. Restart the slave(s).
  20310.  
  20311.  
  20312. After you have done the above, the slave(s) should connect to the master
  20313. and catch up on any updates which happened since the snapshot was taken.
  20314.  
  20315. If you have forgotten to set `server-id' for the slave you will get the
  20316. following error in the error log file:
  20317.  
  20318.      Warning: one should set server_id to a non-0 value if master_host is set.
  20319.      The server will not act as a slave.
  20320.  
  20321. If you have forgot to do this for the master, the slaves will not be
  20322. able to connect to the master.
  20323.  
  20324. If a slave is not able to replicate for any reason, you will find error
  20325. messages in the error log on the slave.
  20326.  
  20327. Once a slave is replicating, you will find a file called `master.info'
  20328. in the same directory as your error log. The `master.info' file is used
  20329. by the slave to keep track of how much of the master's binary log is
  20330. has processed. *Do not* remove or edit the file, unless you really know
  20331. what you are doing. Even in that case, it is preferred that you use
  20332. `CHANGE MASTER TO' command.
  20333.  
  20334. * Menu:
  20335.  
  20336. * Replication Features::        Replication Features and Known Problems
  20337. * Replication Options::         Replication Options in my.cnf
  20338. * Replication SQL::             SQL Commands Related to Replication
  20339. * Replication FAQ::             Replication FAQ
  20340. * Replication Problems::        Troubleshooting Replication
  20341.  
  20342. 
  20343. File: mysql.info,  Node: Replication Features,  Next: Replication Options,  Prev: Replication HOWTO,  Up: Replication
  20344.  
  20345. Replication Features and Known Problems
  20346. ---------------------------------------
  20347.  
  20348. Below is an explanation of what is supported and what is not:
  20349.  
  20350.    * Replication will be done correctly with `AUTO_INCREMENT',
  20351.      `LAST_INSERT_ID', and `TIMESTAMP' values.
  20352.  
  20353.    * `RAND()' in updates does not replicate properly. Use
  20354.      `RAND(some_non_rand_expr)' if you are replicating updates with
  20355.      `RAND()'. You can, for example, use `UNIX_TIMESTAMP()' for the
  20356.      argument to `RAND()'.
  20357.  
  20358.    * You have to use the same character set (`--default-character-set')
  20359.      on the master and the slave. If not, you may get duplicate key
  20360.      errors on the slave, because a key that is regarded as unique on
  20361.      the master may not be that in the other character set.
  20362.  
  20363.    * `LOAD DATA INFILE' will be handled properly as long as the file
  20364.      still resides on the master server at the time of update
  20365.      propagation. `LOAD LOCAL DATA INFILE' will be skipped.
  20366.  
  20367.    * Update queries that use user variables are not replication-safe
  20368.      (yet).
  20369.  
  20370.    * `FLUSH' commands are not stored in the binary log and are because
  20371.      of this not replicated to the slaves. This is not normally a
  20372.      problem as `FLUSH' doesn't change anything. This does however mean
  20373.      that if you update the `MySQL' privilege tables directly without
  20374.      using `GRANT' statement and you replicate the `MySQL' privilege
  20375.      database, you must do a `FLUSH PRIVILEGES' on your slaves to put
  20376.      the new privileges into effect.
  20377.  
  20378.    * Temporary tables starting in 3.23.29 are replicated properly with
  20379.      the exception of the case when you shut down slave server ( not
  20380.      just slave thread), you have some temporary tables open, and the
  20381.      are used in subsequent updates.  To deal with this problem, to
  20382.      shut down the slave, do `SLAVE STOP', then check
  20383.      `Slave_open_temp_tables' variable to see if it is 0, then issue
  20384.      `mysqladmin shutdown'. If the number is not 0, restart the slave
  20385.      thread with `SLAVE START' and see if you have better luck next
  20386.      time. There will be a cleaner solution, but it has to wait until
  20387.      version 4.0.  In earlier versions temporary tables are not being
  20388.      replicated properly - we recommend that you either upgrade, or
  20389.      execute `SET SQL_LOG_BIN=0' on your clients before all queries
  20390.      with temp tables.
  20391.  
  20392.    * MySQL only supports one master and many slaves. We will in 4.x add
  20393.      a voting algorithm to automatically change master if something goes
  20394.      wrong with the current master. We will also introduce 'agent'
  20395.      processes to help doing load balancing by sending select queries
  20396.      to different slaves.
  20397.  
  20398.    * Starting in Version 3.23.26, it is safe to connect servers in a
  20399.      circular master-slave relationship with `log-slave-updates'
  20400.      enabled.  Note, however, that many queries will not work right in
  20401.      this kind of setup unless your client code is written to take care
  20402.      of the potential problems that can happen from updates that occur
  20403.      in different sequence on different servers.
  20404.  
  20405.      This means that you can do a setup like the following:
  20406.  
  20407.           A -> B -> C -> A
  20408.  
  20409.      This setup will only works if you only do non conflicting updates
  20410.      between the tables.  In other words, if you insert data in A and
  20411.      C, you should never insert a row in A that may have a conflicting
  20412.      key with a row insert in C.  You should also not update the sam
  20413.      rows on two servers if the order in which the updates are applied
  20414.      matters.
  20415.  
  20416.      Note that the log format has changed in Version 3.23.26 so that
  20417.      pre-3.23.26 slaves will not be able to read it.
  20418.  
  20419.    * If the query on the slave gets an error, the slave thread will
  20420.      terminate, and a message will appear in the `.err' file. You should
  20421.      then connect to the slave manually, fix the cause of the error (for
  20422.      example, non-existent table), and then run `SLAVE START' sql
  20423.      command (available starting in Version 3.23.16). In Version
  20424.      3.23.15, you will have to restart the server.
  20425.  
  20426.    * If connection to the master is lost, the slave will retry
  20427.      immediately, and then in case of failure every
  20428.      `master-connect-retry' (default 60) seconds. Because of this, it
  20429.      is safe to shut down the master, and then restart it after a
  20430.      while. The slave will also be able to deal with network
  20431.      connectivity outages.
  20432.  
  20433.    * Shutting down the slave (cleanly) is also safe, as it keeps track
  20434.      of where it left off.  Unclean shutdowns might produce problems,
  20435.      especially if disk cache was not synced before the system died.
  20436.      Your system fault tolerance will be greatly increased if you have
  20437.      a good UPS.
  20438.  
  20439.    * If the master is listening on a non-standard port, you will also
  20440.      need to specify this with `master-port' parameter in `my.cnf' .
  20441.  
  20442.    * In Version 3.23.15, all of the tables and databases will be
  20443.      replicated. Starting in Version 3.23.16, you can restrict
  20444.      replication to a set of databases with `replicate-do-db'
  20445.      directives in `my.cnf' or just exclude a set of databases with
  20446.      `replicate-ignore-db'. Note that up until Version 3.23.23, there
  20447.      was a bug that did not properly deal with `LOAD DATA INFILE' if
  20448.      you did it in a database that was excluded from replication.
  20449.  
  20450.    * Starting in Version 3.23.16, `SET SQL_LOG_BIN = 0' will turn off
  20451.      replication (binary) logging on the master, and `SET SQL_LOG_BIN =
  20452.      1' will turn in back on - you must have the process privilege to do
  20453.      this.
  20454.  
  20455.    * Starting in Version 3.23.19, you can clean up stale replication
  20456.      leftovers when something goes wrong and you want a clean start
  20457.      with `FLUSH MASTER' and `FLUSH SLAVE' commands. In Version 3.23.26
  20458.      we have renamed them to `RESET MASTER' and `RESET SLAVE'
  20459.      respectively to clarify what they do. The old `FLUSH' variants
  20460.      still work, though, for compatibility.
  20461.  
  20462.    * Starting in Version 3.23.21, you can use `LOAD TABLE FROM MASTER'
  20463.      for network backup and to set up replication initially. We have
  20464.      recently received a number of bug reports concerning it that we
  20465.      are investigating, so we recommend that you use it only in testing
  20466.      until we make it more stable.
  20467.  
  20468.    * Starting in Version 3.23.23, you can change masters and adjust log
  20469.      position with `CHANGE MASTER TO'.
  20470.  
  20471.    * Starting in Version 3.23.23, you tell the master that updates in
  20472.      certain databases should not be logged to the binary log with
  20473.      `binlog-ignore-db'.
  20474.  
  20475.    * Starting in Version 3.23.26, you can use `replicate-rewrite-db' to
  20476.      tell the slave to apply updates from one database on the master to
  20477.      the one with a different name on the slave.
  20478.  
  20479.    * Starting in Version 3.23.28, you can use `PURGE MASTER LOGS TO
  20480.      'log-name'' to get rid of old logs while the slave is running.
  20481.  
  20482. 
  20483. File: mysql.info,  Node: Replication Options,  Next: Replication SQL,  Prev: Replication Features,  Up: Replication
  20484.  
  20485. Replication Options in my.cnf
  20486. -----------------------------
  20487.  
  20488. If you are using replication, we recommend you to use MySQL Version
  20489. 3.23.30 or later. Older versions work, but they do have some bugs and
  20490. are missing some features.
  20491.  
  20492. On both master and slave you need to use the `server-id' option.  This
  20493. sets an unique replication id. You should pick a unique value in the
  20494. range between 1 to 2^32-1 for each master and slave.  Example:
  20495. `server-id=3'
  20496.  
  20497. The following table has the options you can use for the *MASTER*:
  20498.  
  20499. *Option*               *Description*
  20500. `log-bin=filename'      Write to a binary update log to the specified
  20501.                        location. Note that if you give it a parameter
  20502.                        with an extension (for example,
  20503.                        `log-bin=/mysql/logs/replication.log' ) versions
  20504.                        up to 3.23.24 will not work right during
  20505.                        replication if you do `FLUSH LOGS' . The problem
  20506.                        is fixed in Version 3.23.25. If you are using
  20507.                        this kind of log name, `FLUSH LOGS' will be
  20508.                        ignored on binlog. To clear the log, run `FLUSH
  20509.                        MASTER', and do not forget to run `FLUSH SLAVE'
  20510.                        on all slaves. In Version 3.23.26 and in later
  20511.                        versions you should use `RESET MASTER' and `RESET
  20512.                        SLAVE'
  20513. `log-bin-index=filename' Because the user could issue the `FLUSH LOGS'
  20514.                        command, we need to know which log is currently
  20515.                        active and which ones have been rotated out and
  20516.                        in what sequence. This information is stored in
  20517.                        the binary log index file.  The default is
  20518.                        `hostname`.index. You can use this option if you
  20519.                        want to be a rebel.
  20520.                        
  20521.                        Example: `log-bin-index=db.index'.
  20522. `sql-bin-update-same'   If set, setting `SQL_LOG_BIN' to a value will
  20523.                        automatically set `SQL_LOG_UPDATE' to the same
  20524.                        value and vice versa.
  20525. `binlog-do-db=database_name' Tells the master that it should log updates to
  20526.                        the binary log if the current database is
  20527.                        'database_name'. All others database are ignored.
  20528.                        Note that if you use this you should ensure that
  20529.                        you only do updates in the current database.
  20530.                        
  20531.                        Example: `binlog-do-db=some_database'.
  20532. `binlog-ignore-db=database_name' Tells the master that updates where the current
  20533.                        database is 'database_name' should not be stored
  20534.                        in the binary log.  Note that if you use this you
  20535.                        should ensure that you only do updates in the
  20536.                        current database.
  20537.                        
  20538.                        Example: `binlog-ignore-db=some_database'
  20539.  
  20540. The following table has the options you can use for the *SLAVE*:
  20541.  
  20542. *Option*               *Description*
  20543. `master-host=host'      Master hostname or IP address for replication.
  20544.                        If not set, the slave thread will not be started.
  20545.                        
  20546.                        Example: `master-host=db-master.mycompany.com'.
  20547. `master-user=username'  The user the slave thread will us for
  20548.                        authentication when connecting to the master. The
  20549.                        user must have `FILE' privilege. If the master
  20550.                        user is not set, user `test' is assumed.
  20551.                        
  20552.                        Example: `master-user=scott'.
  20553. `master-password=password' The password the slave thread will authenticate
  20554.                        with when connecting to the master. If not set,
  20555.                        an empty password is assumed.
  20556.                        
  20557.                        Example: `master-password=tiger'.
  20558. `master-port=portnumber' The port the master is listening on. If not set,
  20559.                        the compiled setting of `MYSQL_PORT' is assumed.
  20560.                        If you have not tinkered with `configure'
  20561.                        options, this should be 3306.
  20562.                        
  20563.                        Example: `master-port=3306'.
  20564. `master-connect-retry=seconds' The number of seconds the slave thread will
  20565.                        sleep before retrying to connect to the master in
  20566.                        case the master goes down or the connection is
  20567.                        lost.  Default is 60.
  20568.                        
  20569.                        Example: `master-connect-retry=60'.
  20570. `master-info-file=filename' The location of the file that remembers where we
  20571.                        left off on the master during the replication
  20572.                        process. The default is master.info in the data
  20573.                        directory.  Sasha: The only reason I see for ever
  20574.                        changing the default is the desire to be
  20575.                        rebelious.
  20576.                        
  20577.                        Example: `master-info-file=master.info'.
  20578. `replicate-do-table=db_name.table_name' Tells the slave thread to restrict replication
  20579.                        to the specified table.  To specify more than one
  20580.                        table, use the directive multiple times, once for
  20581.                        each table.  This will work for cross-database
  20582.                        updates, in contrast to `replicate-do-db'.
  20583.                        
  20584.                        Example: `replicate-do-table=some_db.some_table'.
  20585. `replicate-ignore-table=db_name.table_name' Tells the slave thread to not replicate to the
  20586.                        specified table. To specify more than one table
  20587.                        to ignore, use the directive multiple times, once
  20588.                        for each table. This will work for cross-datbase
  20589.                        updates, in contrast to `replicate-ignore-db'.
  20590.                        
  20591.                        Example:
  20592.                        `replicate-ignore-table=db_name.some_table'.
  20593. `replicate-wild-do-table=db_name.table_name' Tells the slave thread to restrict replication
  20594.                        to the tables that match the specified wildcard
  20595.                        pattern.  To specify more than one table, use the
  20596.                        directive multiple times, once for each table.
  20597.                        This will work for cross-database updates.
  20598.                        
  20599.                        Example: `replicate-wild-do-table=foo%.bar%' will
  20600.                        replicate only updates to tables in all databases
  20601.                        that start with foo and whose table names start
  20602.                        with bar.
  20603. `replicate-wild-ignore-table=db_name.table_name' Tells the slave thread to not replicate to the
  20604.                        tables that match the given wild card pattern. To
  20605.                        specify more than one table to ignore, use the
  20606.                        directive multiple times, once for each table.
  20607.                        This will work for cross-database updates.
  20608.                        
  20609.                        Example: `replicate-wild-ignore-table=foo%.bar%'
  20610.                        will not do updates to tables in databases that
  20611.                        start with foo and whose table names start with
  20612.                        bar.
  20613. `replicate-ignore-db=database_name' Tells the slave thread to not replicate to the
  20614.                        specified database. To specify more than one
  20615.                        database to ignore, use the directive multiple
  20616.                        times, once for each database. This option will
  20617.                        not work if you use cross database updates. If
  20618.                        you need cross database updates to work, make sure
  20619.                        you have 3.23.28 or later, and use
  20620.                        `replicate-wild-ignore-table=db_name.%'
  20621.                        
  20622.                        Example: `replicate-ignore-db=some_db'.
  20623. `replicate-do-db=database_name' Tells the slave thread to restrict replication
  20624.                        to the specified database.  To specify more than
  20625.                        one database, use the directive multiple times,
  20626.                        once for each database. Note that this will only
  20627.                        work if you do not use cross-database queries
  20628.                        such as `UPDATE some_db.some_table SET foo='bar''
  20629.                        while having selected a different or no database.
  20630.                        If you need cross database updates to work, make
  20631.                        sure you have 3.23.28 or later, and use
  20632.                        `replicate-wild-do-table=db_name.%'
  20633.                        
  20634.                        Example: `replicate-do-db=some_db'.
  20635. `log-slave-updates'     Tells the slave to log the updates from the
  20636.                        slave thread to the binary log. Off by default.
  20637.                        You will need to turn it on if you plan to
  20638.                        daisy-chain the slaves.
  20639. `replicate-rewrite-db=from_name->to_name' Updates to a database with a different name than
  20640.                        the original
  20641.                        
  20642.                        Example:
  20643.                        `replicate-rewrite-db=master_db_name->slave_db_name'.
  20644. `slave-skip-errors=err_code1,err_code2,..' Available only in 3.23.47 and later. Tells the
  20645.                        slave thread to continue replication when a query
  20646.                        returns an error from the provided list.
  20647.                        Normally, replication will discontinue when an
  20648.                        error is encountered giving the user a chance to
  20649.                        resolve the inconsistency in the data manually.
  20650.                        Do not use this option unless you fully
  20651.                        understand why you are getting the errors.  If
  20652.                        there are no bugs in your replication setup and
  20653.                        client programs, and no bugs in MySQL itself, you
  20654.                        should never get an abort with
  20655.                        error.Indiscriminate use of this option will
  20656.                        result in slaves being hopelessly out of sync
  20657.                        with the master and you having no idea how the
  20658.                        problem happened.
  20659.                        
  20660.                        For error codes, you should use the numbers
  20661.                        provided by the error message in your slave error
  20662.                        log and in the output of `SHOW SLAVE STATUS'.
  20663.                        Full list of error messages can be found in the
  20664.                        source distribution in `Docs/mysqld_error.txt'.
  20665.                        
  20666.                        You can ( but should not) also use a very
  20667.                        non-recommended value of `all' which will ignore
  20668.                        all error messages and keep barging along
  20669.                        regardless.  Needless to say, if you use it, we
  20670.                        make no promises regarding your data integrity.
  20671.                        Please do not complain if your data on the slave
  20672.                        is not anywhere close to what it is on the master
  20673.                        in this case - you have been warned.
  20674.                        
  20675.                        Example:
  20676.                        
  20677.                        `slave-skip-errors=1062,1053' or
  20678.                        `slave-skip-errors=all'
  20679. `skip-slave-start'      Tells the slave server not to start the slave on
  20680.                        the startup.  The user can start it later with
  20681.                        `SLAVE START'.
  20682. `slave_read_timeout=#'  Number of seconds to wait for more data from the
  20683.                        master before aborting the read.
  20684.  
  20685. 
  20686. File: mysql.info,  Node: Replication SQL,  Next: Replication FAQ,  Prev: Replication Options,  Up: Replication
  20687.  
  20688. SQL Commands Related to Replication
  20689. -----------------------------------
  20690.  
  20691. Replication can be controlled through the SQL interface. Below is the
  20692. summary of commands:
  20693.  
  20694. *Command*              *Description*
  20695. `SLAVE START'          Starts the slave thread. (Slave)
  20696. `SLAVE STOP'           Stops the slave thread. (Slave)
  20697. `SET SQL_LOG_BIN=0'    Disables update logging if the user has process
  20698.                        privilege.   Ignored otherwise. (Master)
  20699. `SET SQL_LOG_BIN=1'    Re-enables update logging if the user has process
  20700.                        privilege.   Ignored otherwise. (Master)
  20701. `SET                   Skip the next `n' events from the master. Only
  20702. SQL_SLAVE_SKIP_COUNTER=n'valid when the slave thread is not running,
  20703.                        otherwise, gives an error. Useful for recovering
  20704.                        from replication glitches.
  20705. `RESET MASTER'         Deletes all binary logs listed in the index file,
  20706.                        resetting the binlog index file to be empty. In
  20707.                        pre-3.23.26 versions, `FLUSH MASTER' (Master)
  20708. `RESET SLAVE'          Makes the slave forget its replication position
  20709.                        in the master logs. In pre 3.23.26 versions the
  20710.                        command was called `FLUSH SLAVE'(Slave)
  20711. `LOAD TABLE tblname    Downloads a copy of the table from master to the
  20712. FROM MASTER'           slave. (Slave)
  20713. `CHANGE MASTER TO      Changes the master parameters to the values
  20714. master_def_list'       specified in `master_def_list' and restarts the
  20715.                        slave thread. `master_def_list' is a
  20716.                        comma-separated list of `master_def' where
  20717.                        `master_def' is one of the following:
  20718.                        `MASTER_HOST', `MASTER_USER', `MASTER_PASSWORD',
  20719.                        `MASTER_PORT', `MASTER_CONNECT_RETRY',
  20720.                        `MASTER_LOG_FILE', `MASTER_LOG_POS'. Example:
  20721.                        
  20722.                        
  20723.                             CHANGE MASTER TO
  20724.                               MASTER_HOST='master2.mycompany.com',
  20725.                               MASTER_USER='replication',
  20726.                               MASTER_PASSWORD='bigs3cret',
  20727.                               MASTER_PORT=3306,
  20728.                               MASTER_LOG_FILE='master2-bin.001',
  20729.                               MASTER_LOG_POS=4;
  20730.                        You only need to specify the values that need to
  20731.                        be changed. The values that you omit will stay
  20732.                        the same with the exception of when you change
  20733.                        the host or the port. In that case, the slave
  20734.                        will assume that since you are connecting to a
  20735.                        different host or a different port, the master is
  20736.                        different. Therefore, the old values of log and
  20737.                        position are not applicable anymore, and will
  20738.                        automatically be reset to an empty string and 0,
  20739.                        respectively (the start values). Note that if you
  20740.                        restart the slave, it will remember its last
  20741.                        master.  If this is not desirable, you should
  20742.                        delete the `master.info' file before restarting,
  20743.                        and the slave will read its master from `my.cnf'
  20744.                        or the command line. (Slave)
  20745. `SHOW MASTER STATUS'   Provides status information on the binlog of the
  20746.                        master. (Master)
  20747. `SHOW SLAVE STATUS'    Provides status information on essential
  20748.                        parameters of the slave thread. (Slave)
  20749. `SHOW MASTER LOGS'     Only available starting in Version 3.23.28. Lists
  20750.                        the binary logs on the master. You should use
  20751.                        this command prior to `PURGE MASTER LOGS TO' to
  20752.                        find out how far you should go.
  20753. `PURGE MASTER LOGS TO  Available starting in Version 3.23.28. Deletes
  20754. 'logname''             all the replication logs that are listed in the
  20755.                        log index as being prior to the specified log,
  20756.                        and removed them from the log index, so that the
  20757.                        given log now becomes first. Example:
  20758.                        
  20759.                             PURGE MASTER LOGS TO 'mysql-bin.010'
  20760.                        This command will do nothing and fail with an
  20761.                        error if you have an active slave that is
  20762.                        currently reading one of the logs you are trying
  20763.                        to delete. However, if you have a dormant slave,
  20764.                        and happen to purge one of the logs it wants to
  20765.                        read, the slave will be unable to replicate once
  20766.                        it comes up.  The command is safe to run while
  20767.                        slaves are replicating - you do not need to stop
  20768.                        them.
  20769.                        
  20770.                        You must first check all the slaves with `SHOW
  20771.                        SLAVE STATUS' to see which log they are on, then
  20772.                        do a listing of the logs on the master with `SHOW
  20773.                        MASTER LOGS', find the earliest log among all the
  20774.                        slaves (if all the slaves are up to date, this
  20775.                        will be the last log on the list), backup all the
  20776.                        logs you are about to delete (optional) and purge
  20777.                        up to the target log.
  20778.  
  20779. 
  20780. File: mysql.info,  Node: Replication FAQ,  Next: Replication Problems,  Prev: Replication SQL,  Up: Replication
  20781.  
  20782. Replication FAQ
  20783. ---------------
  20784.  
  20785. *Q*: Why do I sometimes see more than one `Binlog_Dump' thread on the
  20786. master after I have restarted the slave?
  20787.  
  20788. *A*: `Binlog_Dump' is a continuous process that is handled by the
  20789. server in the following way:
  20790.  
  20791.    * Catch up on the updates.
  20792.  
  20793.    * Once there are no more updates left, go into `pthread_cond_wait()',
  20794.      from which we can be awakened either by an update or a kill.
  20795.  
  20796.    * On wake up, check the reason. If we are not supposed to die,
  20797.      continue the `Binlog_dump' loop.
  20798.  
  20799.    * If there is some fatal error, such as detecting a dead client,
  20800.      terminate the loop.
  20801.  
  20802. So if the slave thread stops on the slave, the corresponding
  20803. `Binlog_Dump' thread on the master will not notice it until after at
  20804. least one update to the master (or a kill), which is needed to wake it
  20805. up from `pthread_cond_wait()'.  In the meantime, the slave could have
  20806. opened another connection, which resulted in another `Binlog_Dump'
  20807. thread.
  20808.  
  20809. The above problem should not be present in Version 3.23.26 and later
  20810. versions.  In Version 3.23.26 we added `server-id' to each replication
  20811. server, and now all the old zombie threads are killed on the master
  20812. when a new replication thread connects from the same slave
  20813.  
  20814. *Q*: How do I rotate replication logs?
  20815.  
  20816. *A*: In Version 3.23.28 you should use `PURGE MASTER LOGS TO' command
  20817. after determining which logs can be deleted, and optionally backing
  20818. them up first. In earlier versions the process is much more painful,
  20819. and cannot be safely done without stopping all the slaves in the case
  20820. that you plan to re-use log names. You will need to stop the slave
  20821. threads, edit the binary log index file, delete all the old logs,
  20822. restart the master, start slave threads, and then remove the old log
  20823. files.
  20824.  
  20825. *Q*: How do I upgrade on a hot replication setup?
  20826.  
  20827. *A*: If you are upgrading  pre-3.23.26 versions, you should just lock
  20828. the master tables, let the slave catch up, then run `FLUSH MASTER' on
  20829. the master, and `FLUSH SLAVE' on the slave to reset the logs, then
  20830. restart new versions of the master and the slave. Note that the slave
  20831. can stay down for some time - since the master is logging all the
  20832. updates, the slave will be able to catch up once it is up and can
  20833. connect.
  20834.  
  20835. After 3.23.26, we have locked the replication protocol for
  20836. modifications, so you can upgrade masters and slave on the fly to a
  20837. newer 3.23 version and you can have different versions of MySQL running
  20838. on the slave and the master, as long as they are both newer than
  20839. 3.23.26.
  20840.  
  20841. *Q*: What issues should I be aware of when setting up two-way
  20842. replication?
  20843.  
  20844. *A*: MySQL replication currently does not support any locking protocol
  20845. between master and slave to guarantee the atomicity of a distributed
  20846. (cross-server) update. In in other words, it is possible for client A
  20847. to make an update to  co-master 1, and in the meantime, before it
  20848. propagates to co-master 2, client B could make an update to co-master 2
  20849. that will make the update of client A work differently than it did on
  20850. co-master 1. Thus when the update of client A will make it to co-master
  20851. 2, it will produce  tables that will be different than what you have on
  20852. co-master 1, even after all the updates from co-master 2 have also
  20853. propagated. So you should not co-chain two servers in a two-way
  20854. replication relationship, unless you are sure that you updates can
  20855. safely happen in any order, or unless you take care of mis-ordered
  20856. updates somehow in the client code.
  20857.  
  20858. You must also realize that two-way replication actually does not improve
  20859. performance very much, if at all, as far as updates are concerned. Both
  20860. servers need to do the same amount of updates each, as you would have
  20861. one server do. The only difference is that there will be a little less
  20862. lock contention, because the updates originating on another server will
  20863. be serialized in one slave thread. This benefit, though, might be
  20864. offset by network delays.
  20865.  
  20866. *Q*: How can I use replication to improve performance of my system?
  20867.  
  20868. *A*: You should set up one server as the master, and direct all writes
  20869. to it, and configure as many slaves as you have the money and rackspace
  20870. for, distributing the reads among the master and the slaves.  You can
  20871. also start the slaves with `--skip-bdb', `--low-priority-updates' and
  20872. `--delay-key-write-for-all-tables' to get speed improvements for the
  20873. slave.  In this case the slave will use non-transactional `MyISAM'
  20874. tables instead of `BDB' tables to get more speed.
  20875.  
  20876. *Q*: What should I do to prepare my client code to use
  20877. performance-enhancing replication?
  20878.  
  20879. *A*: If the part of your code that is responsible for database access
  20880. has been properly abstracted/modularized, converting it to run with the
  20881. replicated setup should be very smooth and easy - just change the
  20882. implementation of your database access to read from some slave or the
  20883. master, and to always write to the master. If your code does not have
  20884. this level of abstraction, setting up a replicated system will give you
  20885. an opportunity/motivation to it clean up.   You should start by
  20886. creating a wrapper library /module with the following functions:
  20887.  
  20888.    * `safe_writer_connect()'
  20889.  
  20890.    * `safe_reader_connect()'
  20891.  
  20892.    * `safe_reader_query()'
  20893.  
  20894.    * `safe_writer_query()'
  20895.  
  20896. `safe_' means that the function will take care of handling all the
  20897. error conditions.
  20898.  
  20899. You should then convert your client code to use the wrapper library.
  20900. It may be a painful and scary process at first, but it will pay off in
  20901. the long run. All applications that follow the above pattern will be
  20902. able to take advantage of one-master/many slaves solution.  The code
  20903. will be a lot easier to maintain, and adding troubleshooting options
  20904. will be trivial. You will just need to modify one or two functions, for
  20905. example, to log how long each query took, or which query, among your
  20906. many thousands, gave you an error. If you have written a lot of code
  20907. already, you may want to automate the conversion task by using Monty's
  20908. `replace' utility, which comes with the standard distribution of MySQL,
  20909. or just write your own Perl script. Hopefully, your code follows some
  20910. recognizable pattern. If not, then you are probably better off
  20911. re-writing it anyway, or at least going through and manually beating it
  20912. into a pattern.
  20913.  
  20914. Note that, of course, you can use different names for the functions.
  20915. What is important is having unified interface for connecting for reads,
  20916. connecting for writes, doing a read, and doing a write.
  20917.  
  20918. *Q*: When and how much can MySQL replication improve the performance of
  20919. my system?
  20920.  
  20921. *A*: MySQL replication is most beneficial for a system with frequent
  20922. reads and not so frequent writes. In theory, by using a one master/many
  20923. slaves setup you can scale by adding more slaves until you either run
  20924. out of network bandwidth, or your update load grows to the point that
  20925. the master cannot handle it.
  20926.  
  20927. In order to determine how many slaves you can get before the added
  20928. benefits begin to level out, and how much you can improve performance
  20929. of your site, you need to know your query patterns, and empirically
  20930. (by benchmarking) determine the relationship between the throughput on
  20931. reads (reads per second, or `max_reads') and on writes `max_writes') on
  20932. a typical master and a typical slave. The example below will show you a
  20933. rather simplified calculation of what you can get with replication for
  20934. our imagined system.
  20935.  
  20936. Let's say our system load consists of 10% writes and 90% reads, and we
  20937. have determined that `max_reads' = 1200 - 2 * `max_writes', or in other
  20938. words, our system can do 1200 reads per second with no writes, our
  20939. average write is twice as slow as average read, and the relationship is
  20940. linear. Let us suppose that our master and slave are of the same
  20941. capacity, and we have N slaves and 1 master. Then we have for each
  20942. server (master or slave):
  20943.  
  20944. `reads = 1200 - 2 * writes' (from bencmarks)
  20945.  
  20946. `reads = 9* writes / (N + 1) ' (reads split, but writes go to all
  20947. servers)
  20948.  
  20949. `9*writes/(N+1) + 2 * writes = 1200'
  20950.  
  20951. `writes = 1200/(2 + 9/(N+1)'
  20952.  
  20953. So if N = 0, which means we have no replication, our system can handle
  20954. 1200/11, about 109 writes per second (which means we will have 9 times
  20955. as many reads due to the nature of our application).
  20956.  
  20957. If N = 1, we can get up to 184 writes per second.
  20958.  
  20959. If N = 8, we get up to 400.
  20960.  
  20961. If N = 17, 480 writes.
  20962.  
  20963. Eventually as N approaches infinity (and our budget negative infinity),
  20964. we can get very close to 600 writes per second, increasing system
  20965. throughput about 5.5 times. However, with only 8 servers, we increased
  20966. it almost 4 times already.
  20967.  
  20968. Note that our computations assumed infinite network bandwidth, and
  20969. neglected several other factors that could turn out to be significant on
  20970. your system. In many cases, you may not be able to make a computation
  20971. similar to the one above that will accurately predict what will happen
  20972. on your system if you add N replication slaves. However, answering the
  20973. following questions should help you decided whether and how much, if at
  20974. all, the replication will improve the performance of your system:
  20975.  
  20976.    * What is the read/write ratio on your system?
  20977.  
  20978.    * How much more write load can one server handle if you reduce the
  20979.      reads?
  20980.  
  20981.    * How many slaves do you have bandwidth for on your network?
  20982.  
  20983. *Q*: How can I use replication to provide redundancy/high availability?
  20984.  
  20985. *A*: With the currently available features, you would have to set up a
  20986. master and a slave (or several slaves), and write a script that will
  20987. monitor the master to see if it is up, and instruct your applications
  20988. and the slaves of the master change in case of failure. Some
  20989. suggestions:
  20990.  
  20991.    * To tell a slave to change the master use the `CHANGE MASTER TO'
  20992.      command.
  20993.  
  20994.    * A good way to keep your applications informed where the master is
  20995.      by having a dynamic DNS entry for the master. With *bind* you can
  20996.      use `nsupdate' to dynamically update your DNS.
  20997.  
  20998.    * You should run your slaves with the `log-bin' option and without
  20999.      `log-slave-updates'. This way the slave will be ready to become a
  21000.      master as soon as you issue `STOP SLAVE'; `RESET MASTER', and
  21001.      `CHANGE MASTER TO' on the other slaves. It will also help you catch
  21002.      spurious updates that may happen because of misconfiguration of the
  21003.      slave (ideally, you want to configure access rights so that no
  21004.      client can update the slave, except for the slave thread) combined
  21005.      with the bugs in your client programs (they should never update
  21006.      the slave directly).
  21007.  
  21008.  
  21009. We are currently working on integrating an automatic master election
  21010. system into MySQL, but until it is ready, you will have to create your
  21011. own monitoring tools.
  21012.  
  21013. 
  21014. File: mysql.info,  Node: Replication Problems,  Prev: Replication FAQ,  Up: Replication
  21015.  
  21016. Troubleshooting Replication
  21017. ---------------------------
  21018.  
  21019. If you have followed the instructions, and your replication setup is not
  21020. working, first eliminate the user error factor by checking the
  21021. following:
  21022.  
  21023.    * Is the master logging to the binary log? Check with `SHOW MASTER
  21024.      STATUS'.  If it is, `Position' will be non-zero. If not, verify
  21025.      that you have given the master `log-bin' option and have set
  21026.      `server-id'.
  21027.  
  21028.    * Is the slave running? Check with `SHOW SLAVE STATUS'. The answer
  21029.      is found in `Slave_running' column. If not, verify slave options
  21030.      and check the error log for messages.
  21031.  
  21032.    * If the slave is running, did it establish connection with the
  21033.      master? Do `SHOW PROCESSLIST', find the thread with `system user'
  21034.      value in `User' column and `none' in the `Host' column, and check
  21035.      the `State' column. If it says `connecting to master', verify the
  21036.      privileges for the replication user on the master, master host
  21037.      name, your DNS setup, whether the master is actually running,
  21038.      whether it is reachable from the slave, and if all that seems ok,
  21039.      read the error logs.
  21040.  
  21041.    * If the slave was running, but then stopped, look at SHOW SLAVE
  21042.      STATUS output and check the error logs. It usually happens when
  21043.      some query that succeeded on the master fails on the slave. This
  21044.      should never happen if you have taken a proper snapshot of the
  21045.      master, and never modify the data on the slave outside of the
  21046.      slave thread. If it does, it is a bug, read below on how to report
  21047.      it.
  21048.  
  21049.    * If a query on that succeeded on the master refuses to run on the
  21050.      slave, and a full database resync ( the proper thing to do ) does
  21051.      not seem feasible, try the following:
  21052.         - First see if there is some stray record in the way.
  21053.           Understand how it got there, then delete it and run `SLAVE
  21054.           START'
  21055.  
  21056.         - If the above does not work or does not apply, try to
  21057.           understand if it would be safe to make the update manually (
  21058.           if needed) and then ignore the next query from the master.
  21059.  
  21060.         - If you have decided you can skip the next query, do `SET
  21061.           SQL_SLAVE_SKIP_COUNTER=1; SLAVE START;' to skip a query that
  21062.           does not use auto_increment, or last_insert_id  or `SET
  21063.           SQL_SLAVE_SKIP_COUNTER=2; SLAVE START;' otherwise. The reason
  21064.           auto_increment/last_insert_id queries are different is that
  21065.           they take two events in the binary log of the master.
  21066.  
  21067.         - If you are sure the slave started out perfectly in sync with
  21068.           the master, and no one has updated  the tables involved
  21069.           outside of slave thread, report the bug, so you will not have
  21070.           to do the above tricks again.
  21071.  
  21072.    * Make sure you are not running into an old bug by upgrading to the
  21073.      most recent version.
  21074.  
  21075.    * If all else fails, read the error logs. If they are big, `grep -i
  21076.      slave /path/to/your-log.err' on the slave. There is no generic
  21077.      pattern to search for on the master, as the only errors it logs
  21078.      are general system errors - if it can, it will send the error to
  21079.      the slave when things go wrong.
  21080.  
  21081. When you have determined that there is no user error involved, and
  21082. replication still either does not work at all or is unstable, it is
  21083. time to start working on a bug report. We need to get as much info as
  21084. possible from you to be able to track down the bug. Please do spend
  21085. some time and effort preparing a good bug report. Ideally, we would
  21086. like to have a test case in the format found in `mysql-test/t/rpl*'
  21087. directory of the source tree. If you submit a test case like that, you
  21088. can expect a patch within a day or two in most cases, although, of
  21089. course, you mileage may vary depending on a number of factors.
  21090.  
  21091. Second best option is a just program with easily configurable connection
  21092. arguments for the master and the slave that will demonstrate the
  21093. problem on our systems. You can write one in Perl or in C, depending on
  21094. which language you know better.
  21095.  
  21096. If you have one of the above ways to demonstrate the bug, use
  21097. `mysqlbug' to prepare a bug report and send it to
  21098. <bugs@lists.mysql.com>. If you have a phantom - a problem that does
  21099. occur but you cannot duplicate "at will":
  21100.  
  21101.    * Verify that there is no user error involved. For example, if you
  21102.      update the slave outside of the slave thread, the data will be out
  21103.      of sync, and you can have unique key violations on updates, in
  21104.      which case the slave thread will stop and wait for you to clean up
  21105.      the tables manually to bring them in sync.
  21106.  
  21107.    * Run slave with `log-slave-updates' and `log-bin' - this will keep
  21108.      a log of all updates on the slave.
  21109.  
  21110.    * Save all evidence before resetting the replication. If we have no
  21111.      or only sketchy information, it would take us a while to track
  21112.      down the problem. The evidence you should collect is:
  21113.         - All binary logs on the master
  21114.  
  21115.         - All binary log on the slave
  21116.  
  21117.         - The output of `SHOW MASTER STATUS' on the master at the time
  21118.           you have discovered the problem
  21119.  
  21120.         - The output of `SHOW SLAVE STATUS' on the master at the time
  21121.           you have discovered the problem
  21122.  
  21123.         - Error logs on the master and on the slave
  21124.  
  21125.    * Use `mysqlbinlog' to examine the binary logs. The following should
  21126.      be helpful to find the trouble query, for example:
  21127.           mysqlbinlog -j pos_from_slave_status /path/to/log_from_slave_status | head
  21128.  
  21129. Once you have collected the evidence on the phantom problem, try hard to
  21130. isolate it into a separate test case first. Then report the problem to
  21131. <bugs@lists.mysql.com> with as much info as possible.
  21132.  
  21133. 
  21134. File: mysql.info,  Node: MySQL Optimization,  Next: Reference,  Prev: MySQL Database Administration,  Up: Top
  21135.  
  21136. MySQL Optimization
  21137. ******************
  21138.  
  21139. * Menu:
  21140.  
  21141. * Optimize Overview::           Optimization Overview
  21142. * Query Speed::                 Optimizing `SELECT's and Other Queries
  21143. * Locking Issues::              Locking Issues
  21144. * Optimizing Database Structure::  Optimizing Database Structure
  21145. * Optimizing the Server::       Optimizing the MySQL Server
  21146. * Disk issues::                 Disk Issues
  21147.  
  21148. Optimization is a complicated task because it ultimately requires
  21149. understanding of the whole system. While it may be possible to do some
  21150. local optimizations with small knowledge of your system or application,
  21151. the more optimal you want your system to become the more you will have
  21152. to know about it.
  21153.  
  21154. This chapter will try to explain and give some examples of different
  21155. ways to optimize MySQL.  Remember, however, that there are always some
  21156. (increasingly harder) additional ways to make the system even faster.
  21157.  
  21158. 
  21159. File: mysql.info,  Node: Optimize Overview,  Next: Query Speed,  Prev: MySQL Optimization,  Up: MySQL Optimization
  21160.  
  21161. Optimization Overview
  21162. =====================
  21163.  
  21164. The most important part for getting a system fast is of course the basic
  21165. design. You also need to know what kinds of things your system will be
  21166. doing, and what your bottlenecks are.
  21167.  
  21168. The most common bottlenecks are:
  21169.    * Disk seeks.  It takes time for the disk to find a piece of data.
  21170.      With modern disks in 1999, the mean time for this is usually lower
  21171.      than 10ms, so we can in theory do about 1000 seeks a second. This
  21172.      time improves slowly with new disks and is very hard to optimize
  21173.      for a single table. The way to optimize this is to spread the data
  21174.      on more than one disk.
  21175.  
  21176.    * Disk reading/writing.  When the disk is at the correct position we
  21177.      need to read the data. With modern disks in 1999, one disk
  21178.      delivers something like 10-20Mb/s. This is easier to optimize than
  21179.      seeks because you can read in parallel from multiple disks.
  21180.  
  21181.    * CPU cycles.  When we have the data in main memory (or if it
  21182.      already were there) we need to process it to get to our result.
  21183.      Having small tables compared to the memory is the most common
  21184.      limiting factor. But then, with small tables speed is usually not
  21185.      the problem.
  21186.  
  21187.    * Memory bandwidth.  When the CPU needs more data than can fit in
  21188.      the CPU cache the main memory bandwidth becomes a bottleneck. This
  21189.      is an uncommon bottleneck for most systems, but one should be
  21190.      aware of it.
  21191.  
  21192. * Menu:
  21193.  
  21194. * Design Limitations::          MySQL Design Limitations/Tradeoffs
  21195. * Portability::                 Portability
  21196. * Internal use::                What Have We Used MySQL For?
  21197. * MySQL Benchmarks::            The MySQL Benchmark Suite
  21198. * Custom Benchmarks::           Using Your Own Benchmarks
  21199.  
  21200. 
  21201. File: mysql.info,  Node: Design Limitations,  Next: Portability,  Prev: Optimize Overview,  Up: Optimize Overview
  21202.  
  21203. MySQL Design Limitations/Tradeoffs
  21204. ----------------------------------
  21205.  
  21206. Because MySQL uses extremely fast table locking (multiple readers /
  21207. single writers) the biggest remaining problem is a mix of a steady
  21208. stream of inserts and slow selects on the same table.
  21209.  
  21210. We believe that for a huge number of systems the extremely fast
  21211. performance in other cases make this choice a win. This case is usually
  21212. also possible to solve by having multiple copies of the table, but it
  21213. takes more effort and hardware.
  21214.  
  21215. We are also working on some extensions to solve this problem for some
  21216. common application niches.
  21217.  
  21218. 
  21219. File: mysql.info,  Node: Portability,  Next: Internal use,  Prev: Design Limitations,  Up: Optimize Overview
  21220.  
  21221. Portability
  21222. -----------
  21223.  
  21224. Because all SQL servers implement different parts of SQL, it takes work
  21225. to write portable SQL applications. For very simple selects/inserts it
  21226. is very easy, but the more you need the harder it gets. If you want an
  21227. application that is fast with many databases it becomes even harder!
  21228.  
  21229. To make a complex application portable you need to choose a number of
  21230. SQL servers that it should work with.
  21231.  
  21232. You can use the MySQL crash-me program/web-page
  21233. `http://www.mysql.com/information/crash-me.php' to find functions,
  21234. types, and limits you can use with a selection of database servers.
  21235. Crash-me now tests far from everything possible, but it is still
  21236. comprehensive with about 450 things tested.
  21237.  
  21238. For example, you shouldn't have column names longer than 18 characters
  21239. if you want to be able to use Informix or DB2.
  21240.  
  21241. Both the MySQL benchmarks and crash-me programs are very
  21242. database-independent.  By taking a look at how we have handled this, you
  21243. can get a feeling for what you have to do to write your application
  21244. database-independent.  The benchmarks themselves can be found in the
  21245. `sql-bench' directory in the MySQL source distribution. They are
  21246. written in Perl with DBI database interface (which solves the access
  21247. part of the problem).
  21248.  
  21249. See `http://www.mysql.com/information/benchmarks.html' for the results
  21250. from this benchmark.
  21251.  
  21252. As you can see in these results, all databases have some weak points.
  21253. That is, they have different design compromises that lead to different
  21254. behavior.
  21255.  
  21256. If you strive for database independence, you need to get a good feeling
  21257. for each SQL server's bottlenecks. MySQL is VERY fast in retrieving and
  21258. updating things, but will have a problem in mixing slow readers/writers
  21259. on the same table. Oracle, on the other hand, has a big problem when
  21260. you try to access rows that you have recently updated (until they are
  21261. flushed to disk). Transaction databases in general are not very good at
  21262. generating summary tables from log tables, as in this case row locking
  21263. is almost useless.
  21264.  
  21265. To get your application _really_ database-independent, you need to
  21266. define an easy extendable interface through which you manipulate your
  21267. data. As C++ is available on most systems, it makes sense to use a C++
  21268. classes interface to the databases.
  21269.  
  21270. If you use some specific feature for some database (like the `REPLACE'
  21271. command in MySQL), you should code a method for the other SQL servers
  21272. to implement the same feature (but slower).  With MySQL you can use the
  21273. `/*!  */' syntax to add MySQL-specific keywords to a query.  The code
  21274. inside `/**/' will be treated as a comment (ignored) by most other SQL
  21275. servers.
  21276.  
  21277. If REAL high performance is more important than exactness, as in some
  21278. Web applications, a possibility is to create an application layer that
  21279. caches all results to give you even higher performance. By letting old
  21280. results 'expire' after a while, you can keep the cache reasonably
  21281. fresh.  This is quite nice in case of extremely high load, in which case
  21282. you can dynamically increase the cache and set the expire timeout higher
  21283. until things get back to normal.
  21284.  
  21285. In this case the table creation information should contain information
  21286. of the initial size of the cache and how often the table should normally
  21287. be refreshed.
  21288.  
  21289. 
  21290. File: mysql.info,  Node: Internal use,  Next: MySQL Benchmarks,  Prev: Portability,  Up: Optimize Overview
  21291.  
  21292. What Have We Used MySQL For?
  21293. ----------------------------
  21294.  
  21295. During MySQL initial development, the features of MySQL were made to
  21296. fit our largest customer. They handle data warehousing for a couple of
  21297. the biggest retailers in Sweden.
  21298.  
  21299. From all stores, we get weekly summaries of all bonus card transactions,
  21300. and we are expected to provide useful information for the store owners
  21301. to help them find how their advertisement campaigns are affecting their
  21302. customers.
  21303.  
  21304. The data is quite huge (about 7 million summary transactions per month),
  21305. and we have data for 4-10 years that we need to present to the users.
  21306. We got weekly requests from the customers that they want to get
  21307. 'instant' access to new reports from this data.
  21308.  
  21309. We solved this by storing all information per month in compressed
  21310. 'transaction' tables. We have a set of simple macros (script) that
  21311. generates summary tables grouped by different criteria (product group,
  21312. customer id, store ...) from the transaction tables.  The reports are
  21313. Web pages that are dynamically generated by a small Perl script that
  21314. parses a Web page, executes the SQL statements in it, and inserts the
  21315. results. We would have used PHP or mod_perl instead but they were not
  21316. available at that time.
  21317.  
  21318. For graphical data we wrote a simple tool in `C' that can produce GIFs
  21319. based on the result of a SQL query (with some processing of the
  21320. result). This is also dynamically executed from the Perl script that
  21321. parses the `HTML' files.
  21322.  
  21323. In most cases a new report can simply be done by copying an existing
  21324. script and modifying the SQL query in it.  In some cases, we will need
  21325. to add more fields to an existing summary table or generate a new one,
  21326. but this is also quite simple, as we keep all transactions tables on
  21327. disk.  (Currently we have at least 50G of transactions tables and 200G
  21328. of other customer data.)
  21329.  
  21330. We also let our customers access the summary tables directly with ODBC
  21331. so that the advanced users can themselves experiment with the data.
  21332.  
  21333. We haven't had any problems handling this with quite modest Sun Ultra
  21334. SPARCstation (2x200 Mhz). We recently upgraded one of our servers to a 2
  21335. CPU 400 Mhz UltraSPARC, and we are now planning to start handling
  21336. transactions on the product level, which would mean a ten-fold increase
  21337. of data. We think we can keep up with this by just adding more disk to
  21338. our systems.
  21339.  
  21340. We are also experimenting with Intel-Linux to be able to get more CPU
  21341. power cheaper. Now that we have the binary portable database format (new
  21342. in Version 3.23), we will start to use this for some parts of the
  21343. application.
  21344.  
  21345. Our initial feelings are that Linux will perform much better on
  21346. low-to-medium load and Solaris will perform better when you start to
  21347. get a high load because of extreme disk IO, but we don't yet have
  21348. anything conclusive about this. After some discussion with a Linux
  21349. Kernel developer, this might be a side effect of Linux giving so much
  21350. resources to the batch job that the interactive performance gets very
  21351. low. This makes the machine feel very slow and unresponsive while big
  21352. batches are going. Hopefully this will be better handled in future
  21353. Linux Kernels.
  21354.  
  21355. 
  21356. File: mysql.info,  Node: MySQL Benchmarks,  Next: Custom Benchmarks,  Prev: Internal use,  Up: Optimize Overview
  21357.  
  21358. The MySQL Benchmark Suite
  21359. -------------------------
  21360.  
  21361. This should contain a technical description of the MySQL benchmark
  21362. suite (and `crash-me'), but that description is not written yet.
  21363. Currently, you can get a good idea of the benchmark by looking at the
  21364. code and results in the `sql-bench' directory in any MySQL source
  21365. distributions.
  21366.  
  21367. This benchmark suite is meant to be a benchmark that will tell any user
  21368. what things a given SQL implementation performs well or poorly at.
  21369.  
  21370. Note that this benchmark is single threaded, so it measures the minimum
  21371. time for the operations. We plan to in the future add a lot of
  21372. multi-threaded tests to the benchmark suite.
  21373.  
  21374. For example, (run on the same NT 4.0 machine):
  21375.  
  21376. *Reading 2000000 rows by index* *Seconds*                                   *Seconds*      
  21377. mysql                                       367            249
  21378. mysql_odbc                                  464            
  21379. db2_odbc                                    1206           
  21380. informix_odbc                               121126         
  21381. ms-sql_odbc                                 1634           
  21382. oracle_odbc                                 20800          
  21383. solid_odbc                                  877            
  21384. sybase_odbc                                 17614          
  21385.  
  21386.  
  21387. *Inserting (350768) rows* *Seconds*                                   *Seconds*      
  21388. mysql                                       381            206
  21389. mysql_odbc                                  619            
  21390. db2_odbc                                    3460           
  21391. informix_odbc                               2692           
  21392. ms-sql_odbc                                 4012           
  21393. oracle_odbc                                 11291          
  21394. solid_odbc                                  1801           
  21395. sybase_odbc                                 4802           
  21396.  
  21397.  
  21398. In the above test MySQL was run with a 8M index cache.
  21399.  
  21400. We have gather some more benchmark results at
  21401. `http://www.mysql.com/information/benchmarks.html'.
  21402.  
  21403. Note that Oracle is not included because they asked to be removed. All
  21404. Oracle benchmarks have to be passed by Oracle! We believe that makes
  21405. Oracle benchmarks *VERY* biased because the above benchmarks are
  21406. supposed to show what a standard installation can do for a single
  21407. client.
  21408.  
  21409. To run the benchmark suite, you have to download a MySQL source
  21410. distribution, install the perl DBI driver, the perl DBD driver for the
  21411. database you want to test and then do:
  21412.  
  21413.      cd sql-bench
  21414.      perl run-all-tests --server=#
  21415.  
  21416. where # is one of supported servers. You can get a list of all options
  21417. and supported servers by doing `run-all-tests --help'.
  21418.  
  21419. `crash-me' tries to determine what features a database supports and
  21420. what its capabilities and limitations are by actually running queries.
  21421. For example, it determines:
  21422.  
  21423.    * What column types are supported
  21424.  
  21425.    * How many indexes are supported
  21426.  
  21427.    * What functions are supported
  21428.  
  21429.    * How big a query can be
  21430.  
  21431.    * How big a `VARCHAR' column can be
  21432.  
  21433. We can find the result from crash-me on a lot of different databases at
  21434. `http://www.mysql.com/information/crash-me.php'.
  21435.  
  21436. 
  21437. File: mysql.info,  Node: Custom Benchmarks,  Prev: MySQL Benchmarks,  Up: Optimize Overview
  21438.  
  21439. Using Your Own Benchmarks
  21440. -------------------------
  21441.  
  21442. You should definitely benchmark your application and database to find
  21443. out where the bottlenecks are.  By fixing it (or by replacing the
  21444. bottleneck with a 'dummy module') you can then easily identify the next
  21445. bottleneck (and so on).  Even if the overall performance for your
  21446. application is sufficient, you should at least make a plan for each
  21447. bottleneck, and decide how to solve it if someday you really need the
  21448. extra performance.
  21449.  
  21450. For an example of portable benchmark programs, look at the MySQL
  21451. benchmark suite. *Note MySQL Benchmarks: MySQL Benchmarks. You can take
  21452. any program from this suite and modify it for your needs. By doing
  21453. this, you can try different solutions to your problem and test which is
  21454. really the fastest solution for you.
  21455.  
  21456. It is very common that some problems only occur when the system is very
  21457. heavily loaded. We have had many customers who contact us when they
  21458. have a (tested) system in production and have encountered load
  21459. problems. In every one of these cases so far, it has been problems with
  21460. basic design (table scans are NOT good at high load) or OS/Library
  21461. issues. Most of this would be a *LOT* easier to fix if the systems were
  21462. not already in production.
  21463.  
  21464. To avoid problems like this, you should put some effort into
  21465. benchmarking your whole application under the worst possible load!  You
  21466. can use Super Smack for this, and it is available at:
  21467. `http://www.mysql.com/Downloads/super-smack/super-smack-1.0.tar.gz'.
  21468. As the name suggests, it can bring your system down to its knees if you
  21469. ask it, so make sure to use it only on your development systems.
  21470.  
  21471. 
  21472. File: mysql.info,  Node: Query Speed,  Next: Locking Issues,  Prev: Optimize Overview,  Up: MySQL Optimization
  21473.  
  21474. Optimizing `SELECT's and Other Queries
  21475. ======================================
  21476.  
  21477. First, one thing that affects all queries: The more complex permission
  21478. system setup you have, the more overhead you get.
  21479.  
  21480. If you do not have any `GRANT' statements done, MySQL will optimize the
  21481. permission checking somewhat. So if you have a very high volume it may
  21482. be worth the time to avoid grants. Otherwise more permission check
  21483. results in a larger overhead.
  21484.  
  21485. If your problem is with some explicit MySQL function, you can always
  21486. time this in the MySQL client:
  21487.  
  21488.      mysql> select benchmark(1000000,1+1);
  21489.      +------------------------+
  21490.      | benchmark(1000000,1+1) |
  21491.      +------------------------+
  21492.      |                      0 |
  21493.      +------------------------+
  21494.      1 row in set (0.32 sec)
  21495.  
  21496. The above shows that MySQL can execute 1,000,000 `+' expressions in
  21497. 0.32 seconds on a `PentiumII 400MHz'.
  21498.  
  21499. All MySQL functions should be very optimized, but there may be some
  21500. exceptions, and the `benchmark(loop_count,expression)' is a great tool
  21501. to find out if this is a problem with your query.
  21502.  
  21503. * Menu:
  21504.  
  21505. * EXPLAIN::                     `EXPLAIN' Syntax (Get Information About a `SELECT')
  21506. * Estimating performance::      Estimating query performance
  21507. * SELECT speed::                Speed of `SELECT' queries
  21508. * Where optimizations::         How MySQL optimizes `WHERE' clauses
  21509. * DISTINCT optimization::       How MySQL Optimizes `DISTINCT'
  21510. * LEFT JOIN optimization::      How MySQL optimizes `LEFT JOIN'
  21511. * LIMIT optimization::          How MySQL optimizes `LIMIT'
  21512. * Insert speed::                Speed of `INSERT' queries
  21513. * Update speed::                Speed of `UPDATE' queries
  21514. * Delete speed::                Speed of `DELETE' queries
  21515. * Tips::                        Other Optimization Tips
  21516.  
  21517. 
  21518. File: mysql.info,  Node: EXPLAIN,  Next: Estimating performance,  Prev: Query Speed,  Up: Query Speed
  21519.  
  21520. `EXPLAIN' Syntax (Get Information About a `SELECT')
  21521. ---------------------------------------------------
  21522.  
  21523.          EXPLAIN tbl_name
  21524.      or  EXPLAIN SELECT select_options
  21525.  
  21526. `EXPLAIN tbl_name' is a synonym for `DESCRIBE tbl_name' or `SHOW
  21527. COLUMNS FROM tbl_name'.
  21528.  
  21529. When you precede a `SELECT' statement with the keyword `EXPLAIN', MySQL
  21530. explains how it would process the `SELECT', providing information about
  21531. how tables are joined and in which order.
  21532.  
  21533. With the help of `EXPLAIN', you can see when you must add indexes to
  21534. tables to get a faster `SELECT' that uses indexes to find the records.
  21535. You can also see if the optimizer joins the tables in an optimal order.
  21536. To force the optimizer to use a specific join order for a `SELECT'
  21537. statement, add a `STRAIGHT_JOIN' clause.
  21538.  
  21539. For non-simple joins, `EXPLAIN' returns a row of information for each
  21540. table used in the `SELECT' statement. The tables are listed in the order
  21541. they would be read.  MySQL resolves all joins using a single-sweep
  21542. multi-join method. This means that MySQL reads a row from the first
  21543. table, then finds a matching row in the second table, then in the third
  21544. table and so on. When all tables are processed, it outputs the selected
  21545. columns and backtracks through the table list until a table is found
  21546. for which there are more matching rows. The next row is read from this
  21547. table and the process continues with the next table.
  21548.  
  21549. Output from `EXPLAIN' includes the following columns:
  21550.  
  21551. `table'
  21552.      The table to which the row of output refers.
  21553.  
  21554. `type'
  21555.      The join type.  Information about the various types is given below.
  21556.  
  21557. `possible_keys'
  21558.      The `possible_keys' column indicates which indexes MySQL could use
  21559.      to find the rows in this table. Note that this column is totally
  21560.      independent of the order of the tables. That means that some of
  21561.      the keys in possible_keys may not be usable in practice with the
  21562.      generated table order.
  21563.  
  21564.      If this column is empty, there are no relevant indexes. In this
  21565.      case, you may be able to improve the performance of your query by
  21566.      examining the `WHERE' clause to see if it refers to some column or
  21567.      columns that would be suitable for indexing.  If so, create an
  21568.      appropriate index and check the query with `EXPLAIN' again. *Note
  21569.      ALTER TABLE::.
  21570.  
  21571.      To see what indexes a table has, use `SHOW INDEX FROM tbl_name'.
  21572.  
  21573. `key'
  21574.      The `key' column indicates the key that MySQL actually decided to
  21575.      use. The key is `NULL' if no index was chosen.  If MySQL chooses
  21576.      the wrong index, you can probably force MySQL to use another index
  21577.      by using `myisamchk --analyze', *Note myisamchk syntax::, or by
  21578.      using `USE INDEX/IGNORE INDEX'.  *Note JOIN::.
  21579.  
  21580. `key_len'
  21581.      The `key_len' column indicates the length of the key that MySQL
  21582.      decided to use.  The length is `NULL' if the `key' is `NULL'. Note
  21583.      that this tells us how many parts of a multi-part key MySQL will
  21584.      actually use.
  21585.  
  21586. `ref'
  21587.      The `ref' column shows which columns or constants are used with the
  21588.      `key' to select rows from the table.
  21589.  
  21590. `rows'
  21591.      The `rows' column indicates the number of rows MySQL believes it
  21592.      must examine to execute the query.
  21593.  
  21594. `Extra'
  21595.      This column contains additional information of how MySQL will
  21596.      resolve the query. Here is an explanation of the different text
  21597.      strings that can be found in this column:
  21598.  
  21599.     `Distinct'
  21600.           MySQL will not continue searching for more rows for the
  21601.           current row combination after it has found the first matching
  21602.           row.
  21603.  
  21604.     `Not exists'
  21605.           MySQL was able to do a `LEFT JOIN' optimization on the query
  21606.           and will not examine more rows in this table for the previous
  21607.           row combination after it finds one row that matches the `LEFT
  21608.           JOIN' criteria.
  21609.  
  21610.           Here is an example for this:
  21611.  
  21612.                SELECT * FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.id IS NULL;
  21613.  
  21614.           Assume that `t2.id' is defined with `NOT NULL'.  In this case
  21615.           MySQL will scan `t1' and look up the rows in `t2' through
  21616.           `t1.id'. If MySQL finds a matching row in `t2', it knows that
  21617.           `t2.id' can never be `NULL', and will not scan through the
  21618.           rest of the rows in `t2' that has the same `id'.  In other
  21619.           words, for each row in `t1', MySQL only needs to do a single
  21620.           lookup in `t2', independent of how many matching rows there
  21621.           are in `t2'.
  21622.  
  21623.     ``range checked for each record (index map: #)''
  21624.           MySQL didn't find a real good index to use. It will, instead,
  21625.           for each row combination in the preceding tables, do a check
  21626.           on which index to use (if any), and use this index to
  21627.           retrieve the rows from the table.  This isn't very fast but
  21628.           is faster than having to do a join without an index.
  21629.  
  21630.     `Using filesort'
  21631.           MySQL will need to do an extra pass to find out how to
  21632.           retrieve the rows in sorted order.  The sort is done by going
  21633.           through all rows according to the `join type' and storing the
  21634.           sort key + pointer to the row for all rows that match the
  21635.           `WHERE'. Then the keys are sorted. Finally the rows are
  21636.           retrieved in sorted order.
  21637.  
  21638.     `Using index'
  21639.           The column information is retrieved from the table using only
  21640.           information in the index tree without having to do an
  21641.           additional seek to read the actual row.  This can be done
  21642.           when all the used columns for the table are part of the same
  21643.           index.
  21644.  
  21645.     `Using temporary'
  21646.           To resolve the query MySQL will need to create a temporary
  21647.           table to hold the result.  This typically happens if you do an
  21648.           `ORDER BY' on a different column set than you did a `GROUP
  21649.           BY' on.
  21650.  
  21651.     `Where used'
  21652.           A `WHERE' clause will be used to restrict which rows will be
  21653.           matched against the next table or sent to the client.  If you
  21654.           don't have this information and the table is of type `ALL' or
  21655.           `index', you may have something wrong in your query (if you
  21656.           don't intend to fetch/examine all rows from the table).
  21657.  
  21658.      If you want to get your queries as fast as possible, you should
  21659.      look out for `Using filesort' and `Using temporary'.
  21660.  
  21661. The different join types are listed below, ordered from best to worst
  21662. type:
  21663.  
  21664. `system'
  21665.      The table has only one row (= system table). This is a special
  21666.      case of the `const' join type.
  21667.  
  21668. `const'
  21669.      The table has at most one matching row, which will be read at the
  21670.      start of the query. Because there is only one row, values from the
  21671.      column in this row can be regarded as constants by the rest of the
  21672.      optimizer. `const' tables are very fast as they are read only once!
  21673.  
  21674. `eq_ref'
  21675.      One row will be read from this table for each combination of rows
  21676.      from the previous tables.  This is the best possible join type,
  21677.      other than the `const' types.  It is used when all parts of an
  21678.      index are used by the join and the index is `UNIQUE' or a `PRIMARY
  21679.      KEY'.
  21680.  
  21681. `ref'
  21682.      All rows with matching index values will be read from this table
  21683.      for each combination of rows from the previous tables.  `ref' is
  21684.      used if the join uses only a leftmost prefix of the key, or if the
  21685.      key is not `UNIQUE' or a `PRIMARY KEY' (in other words, if the
  21686.      join cannot select a single row based on the key value).  If the
  21687.      key that is used matches only a few rows, this join type is good.
  21688.  
  21689. `range'
  21690.      Only rows that are in a given range will be retrieved, using an
  21691.      index to select the rows.  The `key' column indicates which index
  21692.      is used.  The `key_len' contains the longest key part that was
  21693.      used.  The `ref' column will be NULL for this type.
  21694.  
  21695. `index'
  21696.      This is the same as `ALL', except that only the index tree is
  21697.      scanned.  This is usually faster than `ALL', as the index file is
  21698.      usually smaller than the data file.
  21699.  
  21700. `ALL'
  21701.      A full table scan will be done for each combination of rows from
  21702.      the previous tables.  This is normally not good if the table is
  21703.      the first table not marked `const', and usually *very* bad in all
  21704.      other cases. You normally can avoid `ALL' by adding more indexes,
  21705.      so that the row can be retrieved based on constant values or
  21706.      column values from earlier tables.
  21707.  
  21708. You can get a good indication of how good a join is by multiplying all
  21709. values in the `rows' column of the `EXPLAIN' output. This should tell
  21710. you roughly how many rows MySQL must examine to execute the query. This
  21711. number is also used when you restrict queries with the `max_join_size'
  21712. variable.  *Note Server parameters::.
  21713.  
  21714. The following example shows how a `JOIN' can be optimized progressively
  21715. using the information provided by `EXPLAIN'.
  21716.  
  21717. Suppose you have the `SELECT' statement shown below, that you examine
  21718. using `EXPLAIN':
  21719.  
  21720.      EXPLAIN SELECT tt.TicketNumber, tt.TimeIn,
  21721.                  tt.ProjectReference, tt.EstimatedShipDate,
  21722.                  tt.ActualShipDate, tt.ClientID,
  21723.                  tt.ServiceCodes, tt.RepetitiveID,
  21724.                  tt.CurrentProcess, tt.CurrentDPPerson,
  21725.                  tt.RecordVolume, tt.DPPrinted, et.COUNTRY,
  21726.                  et_1.COUNTRY, do.CUSTNAME
  21727.              FROM tt, et, et AS et_1, do
  21728.              WHERE tt.SubmitTime IS NULL
  21729.                  AND tt.ActualPC = et.EMPLOYID
  21730.                  AND tt.AssignedPC = et_1.EMPLOYID
  21731.                  AND tt.ClientID = do.CUSTNMBR;
  21732.  
  21733. For this example, assume that:
  21734.  
  21735.    * The columns being compared have been declared as follows:
  21736.  
  21737.      *Table* *Column*      *Column type*
  21738.      `tt'    `ActualPC'    `CHAR(10)'
  21739.      `tt'    `AssignedPC'  `CHAR(10)'
  21740.      `tt'    `ClientID'    `CHAR(10)'
  21741.      `et'    `EMPLOYID'    `CHAR(15)'
  21742.      `do'    `CUSTNMBR'    `CHAR(15)'
  21743.  
  21744.    * The tables have the indexes shown below:
  21745.  
  21746.      *Table* *Index*
  21747.      `tt'    `ActualPC'
  21748.      `tt'    `AssignedPC'
  21749.      `tt'    `ClientID'
  21750.      `et'    `EMPLOYID' (primary key)
  21751.      `do'    `CUSTNMBR' (primary key)
  21752.  
  21753.    * The `tt.ActualPC' values aren't evenly distributed.
  21754.  
  21755. Initially, before any optimizations have been performed, the `EXPLAIN'
  21756. statement produces the following information:
  21757.  
  21758.      table type possible_keys                key  key_len ref  rows  Extra
  21759.      et    ALL  PRIMARY                      NULL NULL    NULL 74
  21760.      do    ALL  PRIMARY                      NULL NULL    NULL 2135
  21761.      et_1  ALL  PRIMARY                      NULL NULL    NULL 74
  21762.      tt    ALL  AssignedPC,ClientID,ActualPC NULL NULL    NULL 3872
  21763.            range checked for each record (key map: 35)
  21764.  
  21765. Because `type' is `ALL' for each table, this output indicates that
  21766. MySQL is doing a full join for all tables!  This will take quite a long
  21767. time, as the product of the number of rows in each table must be
  21768. examined!  For the case at hand, this is `74 * 2135 * 74 * 3872 =
  21769. 45,268,558,720' rows.  If the tables were bigger, you can only imagine
  21770. how long it would take.
  21771.  
  21772. One problem here is that MySQL can't (yet) use indexes on columns
  21773. efficiently if they are declared differently.  In this context,
  21774. `VARCHAR' and `CHAR' are the same unless they are declared as different
  21775. lengths. Because `tt.ActualPC' is declared as `CHAR(10)' and
  21776. `et.EMPLOYID' is declared as `CHAR(15)', there is a length mismatch.
  21777.  
  21778. To fix this disparity between column lengths, use `ALTER TABLE' to
  21779. lengthen `ActualPC' from 10 characters to 15 characters:
  21780.  
  21781.      mysql> ALTER TABLE tt MODIFY ActualPC VARCHAR(15);
  21782.  
  21783. Now `tt.ActualPC' and `et.EMPLOYID' are both `VARCHAR(15)'.  Executing
  21784. the `EXPLAIN' statement again produces this result:
  21785.  
  21786.      table type   possible_keys   key     key_len ref         rows    Extra
  21787.      tt    ALL    AssignedPC,ClientID,ActualPC NULL NULL NULL 3872    where used
  21788.      do    ALL    PRIMARY         NULL    NULL    NULL        2135
  21789.            range checked for each record (key map: 1)
  21790.      et_1  ALL    PRIMARY         NULL    NULL    NULL        74
  21791.            range checked for each record (key map: 1)
  21792.      et    eq_ref PRIMARY         PRIMARY 15      tt.ActualPC 1
  21793.  
  21794. This is not perfect, but is much better (the product of the `rows'
  21795. values is now less by a factor of 74). This version is executed in a
  21796. couple of seconds.
  21797.  
  21798. A second alteration can be made to eliminate the column length
  21799. mismatches for the `tt.AssignedPC = et_1.EMPLOYID' and `tt.ClientID =
  21800. do.CUSTNMBR' comparisons:
  21801.  
  21802.      mysql> ALTER TABLE tt MODIFY AssignedPC VARCHAR(15),
  21803.                            MODIFY ClientID   VARCHAR(15);
  21804.  
  21805. Now `EXPLAIN' produces the output shown below:
  21806.  
  21807.      table type   possible_keys   key     key_len ref            rows     Extra
  21808.      et    ALL    PRIMARY         NULL    NULL    NULL           74
  21809.      tt    ref    AssignedPC,ClientID,ActualPC ActualPC 15 et.EMPLOYID 52 where used
  21810.      et_1  eq_ref PRIMARY         PRIMARY 15      tt.AssignedPC  1
  21811.      do    eq_ref PRIMARY         PRIMARY 15      tt.ClientID    1
  21812.  
  21813. This is almost as good as it can get.
  21814.  
  21815. The remaining problem is that, by default, MySQL assumes that values in
  21816. the `tt.ActualPC' column are evenly distributed, and that isn't the
  21817. case for the `tt' table.  Fortunately, it is easy to tell MySQL about
  21818. this:
  21819.  
  21820.      shell> myisamchk --analyze PATH_TO_MYSQL_DATABASE/tt
  21821.      shell> mysqladmin refresh
  21822.  
  21823. Now the join is perfect, and `EXPLAIN' produces this result:
  21824.  
  21825.      table type   possible_keys   key     key_len ref            rows    Extra
  21826.      tt    ALL    AssignedPC,ClientID,ActualPC NULL NULL NULL    3872    where used
  21827.      et    eq_ref PRIMARY         PRIMARY 15      tt.ActualPC    1
  21828.      et_1  eq_ref PRIMARY         PRIMARY 15      tt.AssignedPC  1
  21829.      do    eq_ref PRIMARY         PRIMARY 15      tt.ClientID    1
  21830.  
  21831. Note that the `rows' column in the output from `EXPLAIN' is an educated
  21832. guess from the MySQL join optimizer. To optimize a query, you should
  21833. check if the numbers are even close to the truth.  If not, you may get
  21834. better performance by using `STRAIGHT_JOIN' in your `SELECT' statement
  21835. and trying to list the tables in a different order in the `FROM' clause.
  21836.  
  21837. 
  21838. File: mysql.info,  Node: Estimating performance,  Next: SELECT speed,  Prev: EXPLAIN,  Up: Query Speed
  21839.  
  21840. Estimating Query Performance
  21841. ----------------------------
  21842.  
  21843. In most cases you can estimate the performance by counting disk seeks.
  21844. For small tables, you can usually find the row in 1 disk seek (as the
  21845. index is probably cached).  For bigger tables, you can estimate that
  21846. (using B++ tree indexes) you will need: `log(row_count) /
  21847. log(index_block_length / 3 * 2 / (index_length + data_pointer_length)) +
  21848. 1' seeks to find a row.
  21849.  
  21850. In MySQL an index block is usually 1024 bytes and the data pointer is
  21851. usually 4 bytes. A 500,000 row table with an index length of 3 (medium
  21852. integer) gives you: `log(500,000)/log(1024/3*2/(3+4)) + 1' = 4 seeks.
  21853.  
  21854. As the above index would require about 500,000 * 7 * 3/2 = 5.2M,
  21855. (assuming that the index buffers are filled to 2/3, which is typical)
  21856. you will probably have much of the index in memory and you will probably
  21857. only need 1-2 calls to read data from the OS to find the row.
  21858.  
  21859. For writes, however, you will need 4 seek requests (as above) to find
  21860. where to place the new index and normally 2 seeks to update the index
  21861. and write the row.
  21862.  
  21863. Note that the above doesn't mean that your application will slowly
  21864. degenerate by N log N!  As long as everything is cached by the OS or SQL
  21865. server things will only go marginally slower while the table gets
  21866. bigger. After the data gets too big to be cached, things will start to
  21867. go much slower until your applications is only bound by disk-seeks
  21868. (which increase by N log N). To avoid this, increase the index cache as
  21869. the data grows. *Note Server parameters::.
  21870.  
  21871. 
  21872. File: mysql.info,  Node: SELECT speed,  Next: Where optimizations,  Prev: Estimating performance,  Up: Query Speed
  21873.  
  21874. Speed of `SELECT' Queries
  21875. -------------------------
  21876.  
  21877. In general, when you want to make a slow `SELECT ... WHERE' faster, the
  21878. first thing to check is whether or not you can add an index. *Note
  21879. MySQL indexes: MySQL indexes. All references between different tables
  21880. should usually be done with indexes. You can use the `EXPLAIN' command
  21881. to determine which indexes are used for a `SELECT'.  *Note `EXPLAIN':
  21882. EXPLAIN.
  21883.  
  21884. Some general tips:
  21885.  
  21886.    * To help MySQL optimize queries better, run `myisamchk --analyze'
  21887.      on a table after it has been loaded with relevant data. This
  21888.      updates a value for each index part that indicates the average
  21889.      number of rows that have the same value.  (For unique indexes,
  21890.      this is always 1, of course.).  MySQL will use this to decide
  21891.      which index to choose when you connect two tables with 'a
  21892.      non-constant expression'.  You can check the result from the
  21893.      `analyze' run by doing `SHOW INDEX FROM table_name' and examining
  21894.      the `Cardinality' column.
  21895.  
  21896.    * To sort an index and data according to an index, use `myisamchk
  21897.      --sort-index --sort-records=1' (if you want to sort on index 1).
  21898.      If you have a unique index from which you want to read all records
  21899.      in order according to that index, this is a good way to make that
  21900.      faster.  Note, however, that this sorting isn't written optimally
  21901.      and will take a long time for a large table!
  21902.  
  21903. 
  21904. File: mysql.info,  Node: Where optimizations,  Next: DISTINCT optimization,  Prev: SELECT speed,  Up: Query Speed
  21905.  
  21906. How MySQL Optimizes `WHERE' Clauses
  21907. -----------------------------------
  21908.  
  21909. The `WHERE' optimizations are put in the `SELECT' part here because
  21910. they are mostly used with `SELECT', but the same optimizations apply for
  21911. `WHERE' in `DELETE' and `UPDATE' statements.
  21912.  
  21913. Also note that this section is incomplete. MySQL does many
  21914. optimizations, and we have not had time to document them all.
  21915.  
  21916. Some of the optimizations performed by MySQL are listed below:
  21917.  
  21918.    * Removal of unnecessary parentheses:
  21919.              ((a AND b) AND c OR (((a AND b) AND (c AND d))))
  21920.           -> (a AND b AND c) OR (a AND b AND c AND d)
  21921.  
  21922.    * Constant folding:
  21923.              (a<b AND b=c) AND a=5
  21924.           -> b>5 AND b=c AND a=5
  21925.  
  21926.    * Constant condition removal (needed because of constant folding):
  21927.              (B>=5 AND B=5) OR (B=6 AND 5=5) OR (B=7 AND 5=6)
  21928.           -> B=5 OR B=6
  21929.  
  21930.    * Constant expressions used by indexes are evaluated only once.
  21931.  
  21932.    * `COUNT(*)' on a single table without a `WHERE' is retrieved
  21933.      directly from the table information.  This is also done for any
  21934.      `NOT NULL' expression when used with only one table.
  21935.  
  21936.    * Early detection of invalid constant expressions. MySQL quickly
  21937.      detects that some `SELECT' statements are impossible and returns
  21938.      no rows.
  21939.  
  21940.    * `HAVING' is merged with `WHERE' if you don't use `GROUP BY' or
  21941.      group functions (`COUNT()', `MIN()'...).
  21942.  
  21943.    * For each sub-join, a simpler `WHERE' is constructed to get a fast
  21944.      `WHERE' evaluation for each sub-join and also to skip records as
  21945.      soon as possible.
  21946.  
  21947.    * All constant tables are read first, before any other tables in the
  21948.      query.  A constant table is:
  21949.         - An empty table or a table with 1 row.
  21950.  
  21951.         - A table that is used with a `WHERE' clause on a `UNIQUE'
  21952.           index, or a `PRIMARY KEY', where all index parts are used
  21953.           with constant expressions and the index parts are defined as
  21954.           `NOT NULL'.
  21955.      All the following tables are used as constant tables:
  21956.           mysql> SELECT * FROM t WHERE primary_key=1;
  21957.           mysql> SELECT * FROM t1,t2
  21958.                      WHERE t1.primary_key=1 AND t2.primary_key=t1.id;
  21959.  
  21960.    * The best join combination to join the tables is found by trying all
  21961.      possibilities. If all columns in `ORDER BY' and in `GROUP BY' come
  21962.      from the same table, then this table is preferred first when
  21963.      joining.
  21964.  
  21965.    * If there is an `ORDER BY' clause and a different `GROUP BY'
  21966.      clause, or if the `ORDER BY' or `GROUP BY' contains columns from
  21967.      tables other than the first table in the join queue, a temporary
  21968.      table is created.
  21969.  
  21970.    * If you use `SQL_SMALL_RESULT', MySQL will use an in-memory
  21971.      temporary table.
  21972.  
  21973.    * Each table index is queried, and the best index that spans fewer
  21974.      than 30% of the rows is used. If no such index can be found, a
  21975.      quick table scan is used.
  21976.  
  21977.    * In some cases, MySQL can read rows from the index without even
  21978.      consulting the data file.  If all columns used from the index are
  21979.      numeric, then only the index tree is used to resolve the query.
  21980.  
  21981.    * Before each record is output, those that do not match the `HAVING'
  21982.      clause are skipped.
  21983.  
  21984. Some examples of queries that are very fast:
  21985.  
  21986.      mysql> SELECT COUNT(*) FROM tbl_name;
  21987.      mysql> SELECT MIN(key_part1),MAX(key_part1) FROM tbl_name;
  21988.      mysql> SELECT MAX(key_part2) FROM tbl_name
  21989.                 WHERE key_part_1=constant;
  21990.      mysql> SELECT ... FROM tbl_name
  21991.                 ORDER BY key_part1,key_part2,... LIMIT 10;
  21992.      mysql> SELECT ... FROM tbl_name
  21993.                 ORDER BY key_part1 DESC,key_part2 DESC,... LIMIT 10;
  21994.  
  21995. The following queries are resolved using only the index tree (assuming
  21996. the indexed columns are numeric):
  21997.  
  21998.      mysql> SELECT key_part1,key_part2 FROM tbl_name WHERE key_part1=val;
  21999.      mysql> SELECT COUNT(*) FROM tbl_name
  22000.                 WHERE key_part1=val1 AND key_part2=val2;
  22001.      mysql> SELECT key_part2 FROM tbl_name GROUP BY key_part1;
  22002.  
  22003. The following queries use indexing to retrieve the rows in sorted order
  22004. without a separate sorting pass:
  22005.  
  22006.      mysql> SELECT ... FROM tbl_name ORDER BY key_part1,key_part2,... ;
  22007.      mysql> SELECT ... FROM tbl_name ORDER BY key_part1 DESC,key_part2 DESC,... ;
  22008.  
  22009. 
  22010. File: mysql.info,  Node: DISTINCT optimization,  Next: LEFT JOIN optimization,  Prev: Where optimizations,  Up: Query Speed
  22011.  
  22012. How MySQL Optimizes `DISTINCT'
  22013. ------------------------------
  22014.  
  22015. `DISTINCT' is converted to a `GROUP BY' on all columns, `DISTINCT'
  22016. combined with `ORDER BY' will in many cases also need a temporary table.
  22017.  
  22018. When combining `LIMIT #' with `DISTINCT', MySQL will stop as soon as it
  22019. finds `#' unique rows.
  22020.  
  22021. If you don't use columns from all used tables, MySQL will stop the
  22022. scanning of the not used tables as soon as it has found the first match.
  22023.  
  22024.      SELECT DISTINCT t1.a FROM t1,t2 where t1.a=t2.a;
  22025.  
  22026. In the case, assuming t1 is used before t2 (check with `EXPLAIN'), then
  22027. MySQL will stop reading from t2 (for that particular row in t1) when
  22028. the first row in t2 is found.
  22029.  
  22030. 
  22031. File: mysql.info,  Node: LEFT JOIN optimization,  Next: LIMIT optimization,  Prev: DISTINCT optimization,  Up: Query Speed
  22032.  
  22033. How MySQL Optimizes `LEFT JOIN' and `RIGHT JOIN'
  22034. ------------------------------------------------
  22035.  
  22036. `A LEFT JOIN B' in MySQL is implemented as follows:
  22037.  
  22038.    * The table `B' is set to be dependent on table `A' and all tables
  22039.      that `A' is dependent on.
  22040.  
  22041.    * The table `A' is set to be dependent on all tables (except `B')
  22042.      that are used in the `LEFT JOIN' condition.
  22043.  
  22044.    * All `LEFT JOIN' conditions are moved to the `WHERE' clause.
  22045.  
  22046.    * All standard join optimizations are done, with the exception that
  22047.      a table is always read after all tables it is dependent on.  If
  22048.      there is a circular dependence then MySQL will issue an error.
  22049.  
  22050.    * All standard `WHERE' optimizations are done.
  22051.  
  22052.    * If there is a row in `A' that matches the `WHERE' clause, but there
  22053.      wasn't any row in `B' that matched the `LEFT JOIN' condition, then
  22054.      an extra `B' row is generated with all columns set to `NULL'.
  22055.  
  22056.    * If you use `LEFT JOIN' to find rows that don't exist in some table
  22057.      and you have the following test: `column_name IS NULL' in the
  22058.      `WHERE' part, where column_name is a column that is declared as
  22059.      `NOT NULL', then MySQL will stop searching after more rows (for a
  22060.      particular key combination) after it has found one row that
  22061.      matches the `LEFT JOIN' condition.
  22062.  
  22063. `RIGHT JOIN' is implemented analogously as `LEFT JOIN'.
  22064.  
  22065. The table read order forced by `LEFT JOIN' and `STRAIGHT JOIN' will
  22066. help the join optimizer (which calculates in which order tables should
  22067. be joined) to do its work much more quickly, as there are fewer table
  22068. permutations to check.
  22069.  
  22070. Note that the above means that if you do a query of type:
  22071.  
  22072.      SELECT * FROM a,b LEFT JOIN c ON (c.key=a.key) LEFT JOIN d (d.key=a.key) WHERE b.key=d.key
  22073.  
  22074. MySQL will do a full scan on `b' as the `LEFT JOIN' will force it to be
  22075. read before `d'.
  22076.  
  22077. The fix in this case is to change the query to:
  22078.  
  22079.      SELECT * FROM b,a LEFT JOIN c ON (c.key=a.key) LEFT JOIN d (d.key=a.key) WHERE b.key=d.key
  22080.  
  22081. 
  22082. File: mysql.info,  Node: LIMIT optimization,  Next: Insert speed,  Prev: LEFT JOIN optimization,  Up: Query Speed
  22083.  
  22084. How MySQL Optimizes `LIMIT'
  22085. ---------------------------
  22086.  
  22087. In some cases MySQL will handle the query differently when you are
  22088. using `LIMIT #' and not using `HAVING':
  22089.  
  22090.    * If you are selecting only a few rows with `LIMIT', MySQL will use
  22091.      indexes in some cases when it normally would prefer to do a full
  22092.      table scan.
  22093.  
  22094.    * If you use `LIMIT #' with `ORDER BY', MySQL will end the sorting
  22095.      as soon as it has found the first `#' lines instead of sorting the
  22096.      whole table.
  22097.  
  22098.    * When combining `LIMIT #' with `DISTINCT', MySQL will stop as soon
  22099.      as it finds `#' unique rows.
  22100.  
  22101.    * In some cases a `GROUP BY' can be resolved by reading the key in
  22102.      order (or do a sort on the key) and then calculate summaries until
  22103.      the key value changes.  In this case `LIMIT #' will not calculate
  22104.      any unnecessary `GROUP BY''s.
  22105.  
  22106.    * As soon as MySQL has sent the first `#' rows to the client, it
  22107.      will abort the query.
  22108.  
  22109.    * `LIMIT 0' will always quickly return an empty set.  This is useful
  22110.      to check the query and to get the column types of the result
  22111.      columns.
  22112.  
  22113.    * The size of temporary tables uses the `LIMIT #' to calculate how
  22114.      much space is needed to resolve the query.
  22115.  
  22116. 
  22117. File: mysql.info,  Node: Insert speed,  Next: Update speed,  Prev: LIMIT optimization,  Up: Query Speed
  22118.  
  22119. Speed of `INSERT' Queries
  22120. -------------------------
  22121.  
  22122. The time to insert a record consists approximately of:
  22123.  
  22124.    * Connect:                 (3)
  22125.  
  22126.    * Sending query to server: (2)
  22127.  
  22128.    * Parsing query:           (2)
  22129.  
  22130.    * Inserting record:        (1 x size of record)
  22131.  
  22132.    * Inserting indexes:       (1 x number of indexes)
  22133.  
  22134.    * Close:                   (1)
  22135.  
  22136. where the numbers are somewhat proportional to the overall time. This
  22137. does not take into consideration the initial overhead to open tables
  22138. (which is done once for each concurrently running query).
  22139.  
  22140. The size of the table slows down the insertion of indexes by N log N
  22141. (B-trees).
  22142.  
  22143. Some ways to speed up inserts:
  22144.  
  22145.    * If you are inserting many rows from the same client at the same
  22146.      time, use multiple value lists `INSERT' statements. This is much
  22147.      faster (many times in some cases) than using separate `INSERT'
  22148.      statements.
  22149.  
  22150.    * If you are inserting a lot of rows from different clients, you can
  22151.      get higher speed by using the `INSERT DELAYED' statement. *Note
  22152.      `INSERT': INSERT.
  22153.  
  22154.    * Note that with `MyISAM' you can insert rows at the same time
  22155.      `SELECT's are running if there are no deleted rows in the tables.
  22156.  
  22157.    * When loading a table from a text file, use `LOAD DATA INFILE'. This
  22158.      is usually 20 times faster than using a lot of `INSERT' statements.
  22159.      *Note `LOAD DATA': LOAD DATA.
  22160.  
  22161.    * It is possible with some extra work to make `LOAD DATA INFILE' run
  22162.      even faster when the table has many indexes. Use the following
  22163.      procedure:
  22164.  
  22165.        1. Optionally create the table with `CREATE TABLE'. For example,
  22166.           using `mysql' or Perl-DBI.
  22167.  
  22168.        2. Execute a `FLUSH TABLES' statement or the shell command
  22169.           `mysqladmin flush-tables'.
  22170.  
  22171.        3. Use `myisamchk --keys-used=0 -rq /path/to/db/tbl_name'. This
  22172.           will remove all usage of all indexes from the table.
  22173.  
  22174.        4. Insert data into the table with `LOAD DATA INFILE'. This will
  22175.           not update any indexes and will therefore be very fast.
  22176.  
  22177.        5. If you are going to only read the table in the future, run
  22178.           `myisampack' on it to make it smaller. *Note Compressed
  22179.           format::.
  22180.  
  22181.        6. Re-create the indexes with `myisamchk -r -q
  22182.           /path/to/db/tbl_name'. This will create the index tree in
  22183.           memory before writing it to disk, which is much faster
  22184.           because it avoids lots of disk seeks. The resulting index
  22185.           tree is also perfectly balanced.
  22186.  
  22187.        7. Execute a `FLUSH TABLES' statement or the shell command
  22188.           `mysqladmin flush-tables'.
  22189.  
  22190.      This procedure will be built into `LOAD DATA INFILE' in some future
  22191.      version of MySQL.
  22192.  
  22193.    * You can speed up insertions by locking your tables:
  22194.  
  22195.           mysql> LOCK TABLES a WRITE;
  22196.           mysql> INSERT INTO a VALUES (1,23),(2,34),(4,33);
  22197.           mysql> INSERT INTO a VALUES (8,26),(6,29);
  22198.           mysql> UNLOCK TABLES;
  22199.  
  22200.      The main speed difference is that the index buffer is flushed to
  22201.      disk only once, after all `INSERT' statements have completed.
  22202.      Normally there would be as many index buffer flushes as there are
  22203.      different `INSERT' statements. Locking is not needed if you can
  22204.      insert all rows with a single statement.
  22205.  
  22206.      Locking will also lower the total time of multi-connection tests,
  22207.      but the maximum wait time for some threads will go up (because
  22208.      they wait for locks).  For example:
  22209.  
  22210.           thread 1 does 1000 inserts
  22211.           thread 2, 3, and 4 does 1 insert
  22212.           thread 5 does 1000 inserts
  22213.  
  22214.      If you don't use locking, 2, 3, and 4 will finish before 1 and 5.
  22215.      If you use locking, 2, 3, and 4 probably will not finish before 1
  22216.      or 5, but the total time should be about 40% faster.
  22217.  
  22218.      As `INSERT', `UPDATE', and `DELETE' operations are very fast in
  22219.      MySQL, you will obtain better overall performance by adding locks
  22220.      around everything that does more than about 5 inserts or updates
  22221.      in a row.  If you do very many inserts in a row, you could do a
  22222.      `LOCK TABLES' followed by an `UNLOCK TABLES' once in a while
  22223.      (about each 1000 rows) to allow other threads access to the table.
  22224.      This would still result in a nice performance gain.
  22225.  
  22226.      Of course, `LOAD DATA INFILE' is much faster for loading data.
  22227.  
  22228. To get some more speed for both `LOAD DATA INFILE' and `INSERT',
  22229. enlarge the key buffer. *Note Server parameters::.
  22230.  
  22231. 
  22232. File: mysql.info,  Node: Update speed,  Next: Delete speed,  Prev: Insert speed,  Up: Query Speed
  22233.  
  22234. Speed of `UPDATE' Queries
  22235. -------------------------
  22236.  
  22237. Update queries are optimized as a `SELECT' query with the additional
  22238. overhead of a write. The speed of the write is dependent on the size of
  22239. the data that is being updated and the number of indexes that are
  22240. updated.  Indexes that are not changed will not be updated.
  22241.  
  22242. Also, another way to get fast updates is to delay updates and then do
  22243. many updates in a row later. Doing many updates in a row is much quicker
  22244. than doing one at a time if you lock the table.
  22245.  
  22246. Note that, with dynamic record format, updating a record to a longer
  22247. total length may split the record.  So if you do this often, it is very
  22248. important to `OPTIMIZE TABLE' sometimes.  *Note `OPTIMIZE TABLE':
  22249. OPTIMIZE TABLE.
  22250.  
  22251. 
  22252. File: mysql.info,  Node: Delete speed,  Next: Tips,  Prev: Update speed,  Up: Query Speed
  22253.  
  22254. Speed of `DELETE' Queries
  22255. -------------------------
  22256.  
  22257. If you want to delete all rows in the table, you should use `TRUNCATE
  22258. TABLE table_name'. *Note TRUNCATE::.
  22259.  
  22260. The time to delete a record is exactly proportional to the number of
  22261. indexes. To delete records more quickly, you can increase the size of
  22262. the index cache. *Note Server parameters::.
  22263.  
  22264. 
  22265. File: mysql.info,  Node: Tips,  Prev: Delete speed,  Up: Query Speed
  22266.  
  22267. Other Optimization Tips
  22268. -----------------------
  22269.  
  22270. Unsorted tips for faster systems:
  22271.  
  22272.    * Use persistent connections to the database to avoid the connection
  22273.      overhead. If you can't use persistent connections and you are
  22274.      doing a lot of new connections to the database, you may want to
  22275.      change the value of the `thread_cache_size' variable. *Note Server
  22276.      parameters::.
  22277.  
  22278.    * Always check that all your queries really use the indexes you have
  22279.      created in the tables. In MySQL you can do this with the `EXPLAIN'
  22280.      command. *Note Explain: (manual)EXPLAIN.
  22281.  
  22282.    * Try to avoid complex `SELECT' queries on tables that are updated a
  22283.      lot. This is to avoid problems with table locking.
  22284.  
  22285.    * The new `MyISAM' tables can insert rows in a table without deleted
  22286.      rows at the same time another table is reading from it.  If this
  22287.      is important for you, you should consider methods where you don't
  22288.      have to delete rows or run `OPTIMIZE TABLE' after you have deleted
  22289.      a lot of rows.
  22290.  
  22291.    * Use `ALTER TABLE ... ORDER BY expr1,expr2...' if you mostly
  22292.      retrieve rows in expr1,expr2.. order.  By using this option after
  22293.      big changes to the table, you may be able to get higher
  22294.      performance.
  22295.  
  22296.    * In some cases it may make sense to introduce a column that is
  22297.      'hashed' based on information from other columns. If this column
  22298.      is short and reasonably unique it may be much faster than a big
  22299.      index on many columns. In MySQL it's very easy to use this extra
  22300.      column: `SELECT * FROM table_name WHERE hash=MD5(concat(col1,col2))
  22301.      AND col_1='constant' AND col_2='constant''
  22302.  
  22303.    * For tables that change a lot you should try to avoid all `VARCHAR'
  22304.      or `BLOB' columns. You will get dynamic row length as soon as you
  22305.      are using a single `VARCHAR' or `BLOB' column. *Note Table types::.
  22306.  
  22307.    * It's not normally useful to split a table into different tables
  22308.      just because the rows gets 'big'. To access a row, the biggest
  22309.      performance hit is the disk seek to find the first byte of the
  22310.      row. After finding the data most new disks can read the whole row
  22311.      fast enough for most applications. The only cases where it really
  22312.      matters to split up a table is if it's a dynamic row size table
  22313.      (see above) that you can change to a fixed row size, or if you
  22314.      very often need to scan the table and don't need most of the
  22315.      columns. *Note Table types::.
  22316.  
  22317.    * If you very often need to calculate things based on information
  22318.      from a lot of rows (like counts of things), it's probably much
  22319.      better to introduce a new table and update the counter in real
  22320.      time. An update of type `UPDATE table set count=count+1 where
  22321.      index_column=constant' is very fast!
  22322.  
  22323.      This is really important when you use databases like MySQL that
  22324.      only have table locking (multiple readers / single writers). This
  22325.      will also give better performance with most databases, as the row
  22326.      locking manager in this case will have less to do.
  22327.  
  22328.    * If you need to collect statistics from big log tables, use summary
  22329.      tables instead of scanning the whole table. Maintaining the
  22330.      summaries should be much faster than trying to do statistics
  22331.      'live'. It's much faster to regenerate new summary tables from the
  22332.      logs when things change (depending on business decisions) than to
  22333.      have to change the running application!
  22334.  
  22335.    * If possible, one should classify reports as 'live' or
  22336.      'statistical', where data needed for statistical reports are only
  22337.      generated based on summary tables that are generated from the
  22338.      actual data.
  22339.  
  22340.    * Take advantage of the fact that columns have default values. Insert
  22341.      values explicitly only when the value to be inserted differs from
  22342.      the default. This reduces the parsing that MySQL need to do and
  22343.      improves the insert speed.
  22344.  
  22345.    * In some cases it's convenient to pack and store data into a blob.
  22346.      In this case you have to add some extra code in your application
  22347.      to pack/unpack things in the blob, but this may save a lot of
  22348.      accesses at some stage.  This is practical when you have data that
  22349.      doesn't conform to a static table structure.
  22350.  
  22351.    * Normally you should try to keep all data non-redundant (what is
  22352.      called 3rd normal form in database theory), but you should not be
  22353.      afraid of duplicating things or creating summary tables if you
  22354.      need these to gain more speed.
  22355.  
  22356.    * Stored procedures or UDF (user-defined functions) may be a good
  22357.      way to get more performance.  In this case you should, however,
  22358.      always have a way to do this some other (slower) way if you use
  22359.      some database that doesn't support this.
  22360.  
  22361.    * You can always gain something by caching queries/answers in your
  22362.      application and trying to do many inserts/updates at the same
  22363.      time.  If your database supports lock tables (like MySQL and
  22364.      Oracle), this should help to ensure that the index cache is only
  22365.      flushed once after all updates.
  22366.  
  22367.    * Use `INSERT /*! DELAYED */' when you do not need to know when your
  22368.      data is written. This speeds things up because many records can be
  22369.      written with a single disk write.
  22370.  
  22371.    * Use `INSERT /*! LOW_PRIORITY */' when you want your selects to be
  22372.      more important.
  22373.  
  22374.    * Use `SELECT /*! HIGH_PRIORITY */' to get selects that jump the
  22375.      queue. That is, the select is done even if there is somebody
  22376.      waiting to do a write.
  22377.  
  22378.    * Use the multi-line `INSERT' statement to store many rows with one
  22379.      SQL command (many SQL servers supports this).
  22380.  
  22381.    * Use `LOAD DATA INFILE' to load bigger amounts of data. This is
  22382.      faster than normal inserts and will be even faster when `myisamchk'
  22383.      is integrated in `mysqld'.
  22384.  
  22385.    * Use `AUTO_INCREMENT' columns to make unique values.
  22386.  
  22387.    * Use `OPTIMIZE TABLE' once in a while to avoid fragmentation when
  22388.      using dynamic table format. *Note `OPTIMIZE TABLE': OPTIMIZE TABLE.
  22389.  
  22390.    * Use `HEAP' tables to get more speed when possible. *Note Table
  22391.      types::.
  22392.  
  22393.    * When using a normal Web server setup, images should be stored as
  22394.      files. That is, store only a file reference in the database.  The
  22395.      main reason for this is that a normal Web server is much better at
  22396.      caching files than database contents. So it it's much easier to
  22397.      get a fast system if you are using files.
  22398.  
  22399.    * Use in memory tables for non-critical data that are accessed often
  22400.      (like information about the last shown banner for users that don't
  22401.      have cookies).
  22402.  
  22403.    * Columns with identical information in different tables should be
  22404.      declared identical and have identical names. Before Version 3.23
  22405.      you got slow joins otherwise.
  22406.  
  22407.      Try to keep the names simple (use `name' instead of
  22408.      `customer_name' in the customer table). To make your names portable
  22409.      to other SQL servers you should keep them shorter than 18
  22410.      characters.
  22411.  
  22412.    * If you need REALLY high speed, you should take a look at the
  22413.      low-level interfaces for data storage that the different SQL
  22414.      servers support!  For example, by accessing the MySQL `MyISAM'
  22415.      directly, you could get a speed increase of 2-5 times compared to
  22416.      using the SQL interface.  To be able to do this the data must be
  22417.      on the same server as the application, and usually it should only
  22418.      be accessed by one process (because external file locking is
  22419.      really slow).  One could eliminate the above problems by
  22420.      introducing low-level `MyISAM' commands in the MySQL server (this
  22421.      could be one easy way to get more performance if needed).  By
  22422.      carefully designing the database interface, it should be quite
  22423.      easy to support this types of optimization.
  22424.  
  22425.    * In many cases it's faster to access data from a database (using a
  22426.      live connection) than accessing a text file, just because the
  22427.      database is likely to be more compact than the text file (if you
  22428.      are using numerical data), and this will involve fewer disk
  22429.      accesses.  You will also save code because you don't have to parse
  22430.      your text files to find line and column boundaries.
  22431.  
  22432.    * You can also use replication to speed things up. *Note
  22433.      Replication::.
  22434.  
  22435.    * Declaring a table with `DELAY_KEY_WRITE=1' will make the updating
  22436.      of indexes faster, as these are not logged to disk until the file
  22437.      is closed.  The downside is that you should run `myisamchk' on
  22438.      these tables before you start `mysqld' to ensure that they are
  22439.      okay if something killed `mysqld' in the middle.  As the key
  22440.      information can always be generated from the data, you should not
  22441.      lose anything by using `DELAY_KEY_WRITE'.
  22442.  
  22443. 
  22444. File: mysql.info,  Node: Locking Issues,  Next: Optimizing Database Structure,  Prev: Query Speed,  Up: MySQL Optimization
  22445.  
  22446. Locking Issues
  22447. ==============
  22448.  
  22449. * Menu:
  22450.  
  22451. * Internal locking::            How MySQL Locks Tables
  22452. * Table locking::               Table Locking Issues
  22453.  
  22454. 
  22455. File: mysql.info,  Node: Internal locking,  Next: Table locking,  Prev: Locking Issues,  Up: Locking Issues
  22456.  
  22457. How MySQL Locks Tables
  22458. ----------------------
  22459.  
  22460. You can find a discussion about different locking methods in the
  22461. appendix.  *Note Locking methods::.
  22462.  
  22463. All locking in MySQL is deadlock-free.  This is managed by always
  22464. requesting all needed locks at once at the beginning of a query and
  22465. always locking the tables in the same order.
  22466.  
  22467. The locking method MySQL uses for `WRITE' locks works as follows:
  22468.  
  22469.    * If there are no locks on the table, put a write lock on it.
  22470.  
  22471.    * Otherwise, put the lock request in the write lock queue.
  22472.  
  22473. The locking method MySQL uses for `READ' locks works as follows:
  22474.  
  22475.    * If there are no write locks on the table, put a read lock on it.
  22476.  
  22477.    * Otherwise, put the lock request in the read lock queue.
  22478.  
  22479. When a lock is released, the lock is made available to the threads in
  22480. the write lock queue, then to the threads in the read lock queue.
  22481.  
  22482. This means that if you have many updates on a table, `SELECT'
  22483. statements will wait until there are no more updates.
  22484.  
  22485. To work around this for the case where you want to do many `INSERT' and
  22486. `SELECT' operations on a table, you can insert rows in a temporary
  22487. table and update the real table with the records from the temporary
  22488. table once in a while.
  22489.  
  22490. This can be done with the following code:
  22491.      mysql> LOCK TABLES real_table WRITE, insert_table WRITE;
  22492.      mysql> insert into real_table select * from insert_table;
  22493.      mysql> TRUNCATE TABLE insert_table;
  22494.      mysql> UNLOCK TABLES;
  22495.  
  22496. You can use the `LOW_PRIORITY' options with `INSERT', `UPDATE' or
  22497. `DELETE' or `HIGH_PRIORITY' with `SELECT' if you want to prioritize
  22498. retrieval in some specific cases.  You can also start `mysqld' with
  22499. `--low-priority-updates' to get the same behaveour.
  22500.  
  22501. Using `SQL_BUFFER_RESULT' can also help making table locks shorter.
  22502. *Note SELECT::.
  22503.  
  22504. You could also change the locking code in `mysys/thr_lock.c' to use a
  22505. single queue.  In this case, write locks and read locks would have the
  22506. same priority, which might help some applications.
  22507.  
  22508. 
  22509. File: mysql.info,  Node: Table locking,  Prev: Internal locking,  Up: Locking Issues
  22510.  
  22511. Table Locking Issues
  22512. --------------------
  22513.  
  22514. The table locking code in MySQL is deadlock free.
  22515.  
  22516. MySQL uses table locking (instead of row locking or column locking) on
  22517. all table types, except `BDB' tables, to achieve a very high lock
  22518. speed.  For large tables, table locking is MUCH better than row locking
  22519. for most applications, but there are, of course, some pitfalls.
  22520.  
  22521. For `BDB' and `InnoDB' tables, MySQL only uses table locking if you
  22522. explicitely lock the table with `LOCK TABLES' or execute a command that
  22523. will modify every row in the table, like `ALTER TABLE'.  For these
  22524. table types we recommend you to not use `LOCK TABLES' at all.
  22525.  
  22526. In MySQL Version 3.23.7 and above, you can insert rows into `MyISAM'
  22527. tables at the same time other threads are reading from the table.  Note
  22528. that currently this only works if there are no holes after deleted rows
  22529. in the table at the time the insert is made. When all holes has been
  22530. filled with new data, concurrent inserts will automatically be enabled
  22531. again.
  22532.  
  22533. Table locking enables many threads to read from a table at the same
  22534. time, but if a thread wants to write to a table, it must first get
  22535. exclusive access.  During the update, all other threads that want to
  22536. access this particular table will wait until the update is ready.
  22537.  
  22538. As updates on tables normally are considered to be more important than
  22539. `SELECT', all statements that update a table have higher priority than
  22540. statements that retrieve information from a table. This should ensure
  22541. that updates are not 'starved' because one issues a lot of heavy
  22542. queries against a specific table. (You can change this by using
  22543. LOW_PRIORITY with the statement that does the update or `HIGH_PRIORITY'
  22544. with the `SELECT' statement.)
  22545.  
  22546. Starting from MySQL Version 3.23.7 one can use the
  22547. `max_write_lock_count' variable to force MySQL to temporary give all
  22548. `SELECT' statements, that wait for a table, a higher priority after a
  22549. specific number of inserts on a table.
  22550.  
  22551. Table locking is, however, not very good under the following senario:
  22552.  
  22553.    * A client issues a `SELECT' that takes a long time to run.
  22554.  
  22555.    * Another client then issues an `UPDATE' on a used table. This client
  22556.      will wait until the `SELECT' is finished.
  22557.  
  22558.    * Another client issues another `SELECT' statement on the same
  22559.      table. As `UPDATE' has higher priority than `SELECT', this `SELECT'
  22560.      will wait for the `UPDATE' to finish.  It will also wait for the
  22561.      first `SELECT' to finish!
  22562.  
  22563.    * A thread is waiting for something like `full disk', in which case
  22564.      all threads that wants to access the problem table will also be
  22565.      put in a waiting state until more disk space is made available.
  22566.  
  22567. Some possible solutions to this problem are:
  22568.  
  22569.    * Try to get the `SELECT' statements to run faster. You may have to
  22570.      create some summary tables to do this.
  22571.  
  22572.    * Start `mysqld' with `--low-priority-updates'.  This will give all
  22573.      statements that update (modify) a table lower priority than a
  22574.      `SELECT' statement. In this case the last `SELECT' statement in
  22575.      the previous scenario would execute before the `INSERT' statement.
  22576.  
  22577.    * You can give a specific `INSERT', `UPDATE', or `DELETE' statement
  22578.      lower priority with the `LOW_PRIORITY' attribute.
  22579.  
  22580.    * Start `mysqld' with a low value for *max_write_lock_count* to give
  22581.      `READ' locks after a certain number of `WRITE' locks.
  22582.  
  22583.    * You can specify that all updates from a specific thread should be
  22584.      done with low priority by using the SQL command: `SET
  22585.      SQL_LOW_PRIORITY_UPDATES=1'.  *Note `SET OPTION': SET OPTION.
  22586.  
  22587.    * You can specify that a specific `SELECT' is very important with the
  22588.      `HIGH_PRIORITY' attribute. *Note `SELECT': SELECT.
  22589.  
  22590.    * If you have problems with `INSERT' combined with `SELECT', switch
  22591.      to use the new `MyISAM' tables as these support concurrent
  22592.      `SELECT's and `INSERT's.
  22593.  
  22594.    * If you mainly mix `INSERT' and `SELECT' statements, the `DELAYED'
  22595.      attribute to `INSERT' will probably solve your problems.  *Note
  22596.      `INSERT': INSERT.
  22597.  
  22598.    * If you have problems with `SELECT' and `DELETE', the `LIMIT'
  22599.      option to `DELETE' may help. *Note `DELETE': DELETE.
  22600.  
  22601. 
  22602. File: mysql.info,  Node: Optimizing Database Structure,  Next: Optimizing the Server,  Prev: Locking Issues,  Up: MySQL Optimization
  22603.  
  22604. Optimizing Database Structure
  22605. =============================
  22606.  
  22607. * Menu:
  22608.  
  22609. * Design::                      Design Choices
  22610. * Data size::                   Get Your Data as Small as Possible
  22611. * MySQL indexes::               How MySQL Uses Indexes
  22612. * Indexes::                     Column Indexes
  22613. * Multiple-column indexes::     Multiple-Column Indexes
  22614. * Table cache::                 How MySQL Opens and Closes Tables
  22615. * Creating many tables::        Drawbacks to Creating Large Numbers of Tables in the Same Database
  22616. * Open tables::                 Why So Many Open tables?
  22617.  
  22618. 
  22619. File: mysql.info,  Node: Design,  Next: Data size,  Prev: Optimizing Database Structure,  Up: Optimizing Database Structure
  22620.  
  22621. Design Choices
  22622. --------------
  22623.  
  22624. MySQL keeps row data and index data in separate files. Many (almost
  22625. all) other databases mix row and index data in the same file. We
  22626. believe that the MySQL choice is better for a very wide range of modern
  22627. systems.
  22628.  
  22629. Another way to store the row data is to keep the information for each
  22630. column in a separate area (examples are SDBM and Focus). This will
  22631. cause a performance hit for every query that accesses more than one
  22632. column. Because this degenerates so quickly when more than one column
  22633. is accessed, we believe that this model is not good for general purpose
  22634. databases.
  22635.  
  22636. The more common case is that the index and data are stored together
  22637. (like in Oracle/Sybase et al). In this case you will find the row
  22638. information at the leaf page of the index. The good thing with this
  22639. layout is that it, in many cases, depending on how well the index is
  22640. cached, saves a disk read.  The bad things with this layout are:
  22641.  
  22642.    * Table scanning is much slower because you have to read through the
  22643.      indexes to get at the data.
  22644.  
  22645.    * You can't use only the index table to retrieve data for a query.
  22646.  
  22647.    * You lose a lot of space, as you must duplicate indexes from the
  22648.      nodes (as you can't store the row in the nodes).
  22649.  
  22650.    * Deletes will degenerate the table over time (as indexes in nodes
  22651.      are usually not updated on delete).
  22652.  
  22653.    * It's harder to cache ONLY the index data.
  22654.  
  22655. 
  22656. File: mysql.info,  Node: Data size,  Next: MySQL indexes,  Prev: Design,  Up: Optimizing Database Structure
  22657.  
  22658. Get Your Data as Small as Possible
  22659. ----------------------------------
  22660.  
  22661. One of the most basic optimization is to get your data (and indexes) to
  22662. take as little space on the disk (and in memory) as possible. This can
  22663. give huge improvements because disk reads are faster and normally less
  22664. main memory will be used. Indexing also takes less resources if done on
  22665. smaller columns.
  22666.  
  22667. MySQL supports a lot of different table types and row formats.
  22668. Choosing the right table format may give you a big performance gain.
  22669. *Note Table types::.
  22670.  
  22671. You can get better performance on a table and minimize storage space
  22672. using the techniques listed below:
  22673.  
  22674.    * Use the most efficient (smallest) types possible. MySQL has many
  22675.      specialized types that save disk space and memory.
  22676.  
  22677.    * Use the smaller integer types if possible to get smaller tables.
  22678.      For example, `MEDIUMINT' is often better than `INT'.
  22679.  
  22680.    * Declare columns to be `NOT NULL' if possible. It makes everything
  22681.      faster and you save one bit per column. Note that if you really
  22682.      need `NULL' in your application you should definitely use it. Just
  22683.      avoid having it on all columns by default.
  22684.  
  22685.    * If you don't have any variable-length columns (`VARCHAR', `TEXT',
  22686.      or `BLOB' columns), a fixed-size record format is used. This is
  22687.      faster but unfortunately may waste some space.  *Note MyISAM table
  22688.      formats::.
  22689.  
  22690.    * The primary index of a table should be as short as possible. This
  22691.      makes identification of one row easy and efficient.
  22692.  
  22693.    * For each table, you have to decide which storage/index method to
  22694.      use. *Note Table types::.
  22695.  
  22696.    * Only create the indexes that you really need. Indexes are good for
  22697.      retrieval but bad when you need to store things fast. If you mostly
  22698.      access a table by searching on a combination of columns, make an
  22699.      index on them. The first index part should be the most used
  22700.      column. If you are ALWAYS using many columns, you should use the
  22701.      column with more duplicates first to get better compression of the
  22702.      index.
  22703.  
  22704.    * If it's very likely that a column has a unique prefix on the first
  22705.      number of characters, it's better to only index this prefix. MySQL
  22706.      supports an index on a part of a character column. Shorter indexes
  22707.      are faster not only because they take less disk space but also
  22708.      because they will give you more hits in the index cache and thus
  22709.      fewer disk seeks. *Note Server parameters::.
  22710.  
  22711.    * In some circumstances it can be beneficial to split into two a
  22712.      table that is scanned very often. This is especially true if it is
  22713.      a dynamic format table and it is possible to use a smaller static
  22714.      format table that can be used to find the relevant rows when
  22715.      scanning the table.
  22716.  
  22717. 
  22718. File: mysql.info,  Node: MySQL indexes,  Next: Indexes,  Prev: Data size,  Up: Optimizing Database Structure
  22719.  
  22720. How MySQL Uses Indexes
  22721. ----------------------
  22722.  
  22723. Indexes are used to find rows with a specific value of one column fast.
  22724. Without an index MySQL has to start with the first record and then read
  22725. through the whole table until it finds the relevant rows. The bigger
  22726. the table, the more this costs. If the table has an index for the
  22727. columns in question, MySQL can quickly get a position to seek to in the
  22728. middle of the data file without having to look at all the data. If a
  22729. table has 1000 rows, this is at least 100 times faster than reading
  22730. sequentially. Note that if you need to access almost all 1000 rows it
  22731. is faster to read sequentially because we then avoid disk seeks.
  22732.  
  22733. All MySQL indexes (`PRIMARY', `UNIQUE', and `INDEX') are stored in
  22734. B-trees. Strings are automatically prefix- and end-space compressed.
  22735. *Note `CREATE INDEX': CREATE INDEX.
  22736.  
  22737. Indexes are used to:
  22738.    * Quickly find the rows that match a `WHERE' clause.
  22739.  
  22740.    * Retrieve rows from other tables when performing joins.
  22741.  
  22742.    * Find the `MAX()' or `MIN()' value for a specific indexed column.
  22743.      This is optimized by a preprocessor that checks if you are using
  22744.      `WHERE' key_part_# = constant on all key parts < N.  In this case
  22745.      MySQL will do a single key lookup and replace the `MIN()'
  22746.      expression with a constant.  If all expressions are replaced with
  22747.      constants, the query will return at once:
  22748.  
  22749.           SELECT MIN(key_part2),MAX(key_part2) FROM table_name where key_part1=10
  22750.  
  22751.    * Sort or group a table if the sorting or grouping is done on a
  22752.      leftmost prefix of a usable key (for example, `ORDER BY
  22753.      key_part_1,key_part_2 '). The key is read in reverse order if all
  22754.      key parts are followed by `DESC'.
  22755.  
  22756.      The index can also be used even if the `ORDER BY' doesn't match
  22757.      the index exactly, as long as all the unused index parts and all
  22758.      the extra are `ORDER BY' columns are constants in the `WHERE'
  22759.      clause. The following queries will use the index to resolve the
  22760.      `ORDER BY' part:
  22761.  
  22762.           SELECT * FROM foo ORDER BY key_part1,key_part2,key_part3;
  22763.           SELECT * FROM foo WHERE column=constant ORDER BY column, key_part1;
  22764.           SELECT * FROM foo WHERE key_part1=const GROUP BY key_part2;
  22765.  
  22766.    * In some cases a query can be optimized to retrieve values without
  22767.      consulting the data file. If all used columns for some table are
  22768.      numeric and form a leftmost prefix for some key, the values may be
  22769.      retrieved from the index tree for greater speed:
  22770.  
  22771.           SELECT key_part3 FROM table_name WHERE key_part1=1
  22772.  
  22773.  
  22774. Suppose you issue the following `SELECT' statement:
  22775.  
  22776.      mysql> SELECT * FROM tbl_name WHERE col1=val1 AND col2=val2;
  22777.  
  22778. If a multiple-column index exists on `col1' and `col2', the appropriate
  22779. rows can be fetched directly. If separate single-column indexes exist
  22780. on `col1' and `col2', the optimizer tries to find the most restrictive
  22781. index by deciding which index will find fewer rows and using that index
  22782. to fetch the rows.
  22783.  
  22784. If the table has a multiple-column index, any leftmost prefix of the
  22785. index can be used by the optimizer to find rows. For example, if you
  22786. have a three-column index on `(col1,col2,col3)', you have indexed
  22787. search capabilities on `(col1)', `(col1,col2)', and `(col1,col2,col3)'.
  22788.  
  22789. MySQL can't use a partial index if the columns don't form a leftmost
  22790. prefix of the index.  Suppose you have the `SELECT' statements shown
  22791. below:
  22792.  
  22793.      mysql> SELECT * FROM tbl_name WHERE col1=val1;
  22794.      mysql> SELECT * FROM tbl_name WHERE col2=val2;
  22795.      mysql> SELECT * FROM tbl_name WHERE col2=val2 AND col3=val3;
  22796.  
  22797. If an index exists on `(col1,col2,col3)', only the first query shown
  22798. above uses the index. The second and third queries do involve indexed
  22799. columns, but `(col2)' and `(col2,col3)' are not leftmost prefixes of
  22800. `(col1,col2,col3)'.
  22801.  
  22802. MySQL also uses indexes for `LIKE' comparisons if the argument to
  22803. `LIKE' is a constant string that doesn't start with a wild-card
  22804. character.  For example, the following `SELECT' statements use indexes:
  22805.  
  22806.      mysql> select * from tbl_name where key_col LIKE "Patrick%";
  22807.      mysql> select * from tbl_name where key_col LIKE "Pat%_ck%";
  22808.  
  22809. In the first statement, only rows with `"Patrick" <= key_col <
  22810. "Patricl"' are considered.  In the second statement, only rows with
  22811. `"Pat" <= key_col < "Pau"' are considered.
  22812.  
  22813. The following `SELECT' statements will not use indexes:
  22814.      mysql> select * from tbl_name where key_col LIKE "%Patrick%";
  22815.      mysql> select * from tbl_name where key_col LIKE other_col;
  22816.  
  22817. In the first statement, the `LIKE' value begins with a wild-card
  22818. character.  In the second statement, the `LIKE' value is not a constant.
  22819.  
  22820. Searching using `column_name IS NULL' will use indexes if column_name
  22821. is an index.
  22822.  
  22823. MySQL normally uses the index that finds the least number of rows. An
  22824. index is used for columns that you compare with the following operators:
  22825. `=', `>', `>=', `<', `<=', `BETWEEN', and a `LIKE' with a non-wild-card
  22826. prefix like `'something%''.
  22827.  
  22828. Any index that doesn't span all `AND' levels in the `WHERE' clause is
  22829. not used to optimize the query. In other words:  To be able to use an
  22830. index, a prefix of the index must be used in every `AND' group.
  22831.  
  22832. The following `WHERE' clauses use indexes:
  22833.      ... WHERE index_part1=1 AND index_part2=2 AND other_column=3
  22834.      ... WHERE index=1 OR A=10 AND index=2      /* index = 1 OR index = 2 */
  22835.      ... WHERE index_part1='hello' AND index_part_3=5
  22836.                /* optimized like "index_part1='hello'" */
  22837.      ... WHERE index1=1 and index2=2 or index1=3 and index3=3;
  22838.                /* Can use index on index1 but not on index2 or index 3 */
  22839.  
  22840. These `WHERE' clauses do *NOT* use indexes:
  22841.      ... WHERE index_part2=1 AND index_part3=2  /* index_part_1 is not used */
  22842.      ... WHERE index=1 OR A=10                  /* Index is not used in both AND parts */
  22843.      ... WHERE index_part1=1 OR index_part2=10  /* No index spans all rows */
  22844.  
  22845. Note that in some cases MySQL will not use an index, even if one would
  22846. be available.  Some of the cases where this happens are:
  22847.  
  22848.    * If the use of the index would require MySQL to access more than 30
  22849.      % of the rows in the table.  (In this case a table scan is
  22850.      probably much faster, as this will require us to do much fewer
  22851.      seeks).  Note that if such a query uses `LIMIT' to only retrieve
  22852.      part of the rows, MySQL will use an index anyway, as it can much
  22853.      more quickly find the few rows to return in the result.
  22854.  
  22855. * Menu:
  22856.  
  22857. * Indexes::                     Column Indexes
  22858. * Multiple-column indexes::     Multiple-Column Indexes
  22859. * Table cache::                 How MySQL Opens and Closes Tables
  22860. * Creating many tables::        Drawbacks to Creating Large Numbers of Tables in the Same Database
  22861. * Open tables::                 Why So Many Open tables?
  22862.  
  22863. 
  22864. File: mysql.info,  Node: Indexes,  Next: Multiple-column indexes,  Prev: MySQL indexes,  Up: Optimizing Database Structure
  22865.  
  22866. Column Indexes
  22867. --------------
  22868.  
  22869. All MySQL column types can be indexed.  Use of indexes on the relevant
  22870. columns is the best way to improve the performance of `SELECT'
  22871. operations.
  22872.  
  22873. The maximum number of keys and the maximum index length is defined per
  22874. table handler. *Note Table types::. You can with all table handlers have
  22875. at least 16 keys and a total index length of at least 256 bytes.
  22876.  
  22877. For `CHAR' and `VARCHAR' columns, you can index a prefix of a column.
  22878. This is much faster and requires less disk space than indexing the
  22879. whole column.  The syntax to use in the `CREATE TABLE' statement to
  22880. index a column prefix looks like this:
  22881.  
  22882.      KEY index_name (col_name(length))
  22883.  
  22884. The example below creates an index for the first 10 characters of the
  22885. `name' column:
  22886.  
  22887.      mysql> CREATE TABLE test (
  22888.                 name CHAR(200) NOT NULL,
  22889.                 KEY index_name (name(10)));
  22890.  
  22891. For `BLOB' and `TEXT' columns, you must index a prefix of the column.
  22892. You cannot index the entire column.
  22893.  
  22894. In MySQL Version 3.23.23 or later, you can also create special
  22895. *FULLTEXT* indexes. They are used for full-text search. Only the
  22896. `MyISAM' table type supports `FULLTEXT' indexes. They can be created
  22897. only from `VARCHAR' and `TEXT' columns.  Indexing always happens over
  22898. the entire column and partial indexing is not supported. See *Note
  22899. Fulltext Search:: for details.
  22900.  
  22901. 
  22902. File: mysql.info,  Node: Multiple-column indexes,  Next: Table cache,  Prev: Indexes,  Up: Optimizing Database Structure
  22903.  
  22904. Multiple-Column Indexes
  22905. -----------------------
  22906.  
  22907. MySQL can create indexes on multiple columns.  An index may consist of
  22908. up to 15 columns. (On `CHAR' and `VARCHAR' columns you can also use a
  22909. prefix of the column as a part of an index).
  22910.  
  22911. A multiple-column index can be considered a sorted array containing
  22912. values that are created by concatenating the values of the indexed
  22913. columns.
  22914.  
  22915. MySQL uses multiple-column indexes in such a way that queries are fast
  22916. when you specify a known quantity for the first column of the index in a
  22917. `WHERE' clause, even if you don't specify values for the other columns.
  22918.  
  22919. Suppose a table is created using the following specification:
  22920.  
  22921.      mysql> CREATE TABLE test (
  22922.                 id INT NOT NULL,
  22923.                 last_name CHAR(30) NOT NULL,
  22924.                 first_name CHAR(30) NOT NULL,
  22925.                 PRIMARY KEY (id),
  22926.                 INDEX name (last_name,first_name));
  22927.  
  22928. Then the index `name' is an index over `last_name' and `first_name'.
  22929. The index will be used for queries that specify values in a known range
  22930. for `last_name', or for both `last_name' and `first_name'.  Therefore,
  22931. the `name' index will be used in the following queries:
  22932.  
  22933.      mysql> SELECT * FROM test WHERE last_name="Widenius";
  22934.      
  22935.      mysql> SELECT * FROM test WHERE last_name="Widenius"
  22936.                                AND first_name="Michael";
  22937.      
  22938.      mysql> SELECT * FROM test WHERE last_name="Widenius"
  22939.                                AND (first_name="Michael" OR first_name="Monty");
  22940.      
  22941.      mysql> SELECT * FROM test WHERE last_name="Widenius"
  22942.                                AND first_name >="M" AND first_name < "N";
  22943.  
  22944. However, the `name' index will NOT be used in the following queries:
  22945.  
  22946.      mysql> SELECT * FROM test WHERE first_name="Michael";
  22947.      
  22948.      mysql> SELECT * FROM test WHERE last_name="Widenius"
  22949.                                OR first_name="Michael";
  22950.  
  22951. For more information on the manner in which MySQL uses indexes to
  22952. improve query performance, see *Note MySQL indexes: MySQL indexes.
  22953.  
  22954. 
  22955. File: mysql.info,  Node: Table cache,  Next: Creating many tables,  Prev: Multiple-column indexes,  Up: Optimizing Database Structure
  22956.  
  22957. How MySQL Opens and Closes Tables
  22958. ---------------------------------
  22959.  
  22960. `table_cache', `max_connections', and `max_tmp_tables' affect the
  22961. maximum number of files the server keeps open.  If you increase one or
  22962. both of these values, you may run up against a limit imposed by your
  22963. operating system on the per-process number of open file descriptors.
  22964. However, you can increase the limit on many systems.  Consult your OS
  22965. documentation to find out how to do this, because the method for
  22966. changing the limit varies widely from system to system.
  22967.  
  22968. `table_cache' is related to `max_connections'.  For example, for 200
  22969. concurrent running connections, you should have a table cache of at
  22970. least `200 * n', where `n' is the maximum number of tables in a join.
  22971. You also need to reserve some extra file descriptors for temporary
  22972. tables and files.
  22973.  
  22974. The cache of open tables can grow to a maximum of `table_cache'
  22975. (default 64; this can be changed with the `-O table_cache=#' option to
  22976. `mysqld').  A table is never closed, except when the cache is full and
  22977. another thread tries to open a table or if you use `mysqladmin refresh'
  22978. or `mysqladmin flush-tables'.
  22979.  
  22980. When the table cache fills up, the server uses the following procedure
  22981. to locate a cache entry to use:
  22982.  
  22983.    * Tables that are not currently in use are released, in
  22984.      least-recently-used order.
  22985.  
  22986.    * If the cache is full and no tables can be released, but a new
  22987.      table needs to be opened, the cache is temporarily extended as
  22988.      necessary.
  22989.  
  22990.    * If the cache is in a temporarily-extended state and a table goes
  22991.      from in-use to not-in-use state, the table is closed and released
  22992.      from the cache.
  22993.  
  22994. A table is opened for each concurrent access. This means that if you
  22995. have two threads accessing the same table or access the table twice in
  22996. the same query (with `AS') the table needs to be opened twice.  The
  22997. first open of any table takes two file descriptors; each additional use
  22998. of the table takes only one file descriptor.  The extra descriptor for
  22999. the first open is used for the index file; this descriptor is shared
  23000. among all threads.
  23001.  
  23002. You can check if your table cache is too small by checking the mysqld
  23003. variable `opened_tables'.  If this is quite big, even if you haven't
  23004. done a lot of `FLUSH TABLES', you should increase your table cache.
  23005. *Note SHOW STATUS::.
  23006.  
  23007. 
  23008. File: mysql.info,  Node: Creating many tables,  Next: Open tables,  Prev: Table cache,  Up: Optimizing Database Structure
  23009.  
  23010. Drawbacks to Creating Large Numbers of Tables in the Same Database
  23011. ------------------------------------------------------------------
  23012.  
  23013. If you have many files in a directory, open, close, and create
  23014. operations will be slow.  If you execute `SELECT' statements on many
  23015. different tables, there will be a little overhead when the table cache
  23016. is full, because for every table that has to be opened, another must be
  23017. closed. You can reduce this overhead by making the table cache larger.
  23018.  
  23019. 
  23020. File: mysql.info,  Node: Open tables,  Prev: Creating many tables,  Up: Optimizing Database Structure
  23021.  
  23022. Why So Many Open tables?
  23023. ------------------------
  23024.  
  23025. When you run `mysqladmin status', you'll see something like this:
  23026.  
  23027.      Uptime: 426 Running threads: 1 Questions: 11082 Reloads: 1 Open tables: 12
  23028.  
  23029. This can be somewhat perplexing if you only have 6 tables.
  23030.  
  23031. MySQL is multithreaded, so it may have many queries on the same table
  23032. simultaneously. To minimize the problem with two threads having
  23033. different states on the same file, the table is opened independently by
  23034. each concurrent thread. This takes some memory and one extra file
  23035. descriptor for the data file. The index file descriptor is shared
  23036. between all threads.
  23037.  
  23038. 
  23039. File: mysql.info,  Node: Optimizing the Server,  Next: Disk issues,  Prev: Optimizing Database Structure,  Up: MySQL Optimization
  23040.  
  23041. Optimizing the MySQL Server
  23042. ===========================
  23043.  
  23044. * Menu:
  23045.  
  23046. * System::                      System/Compile Time and Startup Parameter Tuning
  23047. * Server parameters::           Tuning Server Parameters
  23048. * Compile and link options::    How Compiling and Linking Affects the Speed of MySQL
  23049. * Memory use::                  How MySQL Uses Memory
  23050. * DNS::                         How MySQL uses DNS
  23051. * SET OPTION::                  `SET' Syntax
  23052.  
  23053. 
  23054. File: mysql.info,  Node: System,  Next: Server parameters,  Prev: Optimizing the Server,  Up: Optimizing the Server
  23055.  
  23056. System/Compile Time and Startup Parameter Tuning
  23057. ------------------------------------------------
  23058.  
  23059. We start with the system level things since some of these decisions have
  23060. to be made very early. In other cases a fast look at this part may
  23061. suffice because it not that important for the big gains. However, it is
  23062. always nice to have a feeling about how much one could gain by changing
  23063. things at this level.
  23064.  
  23065. The default OS to use is really important!  To get the most use of
  23066. multiple CPU machines one should use Solaris (because the threads works
  23067. really nice) or Linux (because the 2.2 kernel has really good SMP
  23068. support). Also on 32-bit machines Linux has a 2G file size limit by
  23069. default. Hopefully this will be fixed soon when new filesystems are
  23070. released (XFS/Reiserfs).  If you have a desperate need for files bigger
  23071. than 2G on Linux-intel 32 bit, you should get the LFS patch for the ext2
  23072. file system.
  23073.  
  23074. Because we have not run MySQL in production on that many platforms, we
  23075. advice you to test your intended platform before choosing it, if
  23076. possible.
  23077.  
  23078. Other tips:
  23079.    * If you have enough RAM, you could remove all swap devices. Some
  23080.      operating systems will use a swap device in some contexts even if
  23081.      you have free memory.
  23082.  
  23083.    * Use the `--skip-locking' MySQL option to avoid external locking.
  23084.      Note that this will not impact MySQL's functionality as long as
  23085.      you only run one server. Just remember to take down the server (or
  23086.      lock relevant parts) before you run `myisamchk'. On some system
  23087.      this switch is mandatory because the external locking does not
  23088.      work in any case.
  23089.  
  23090.      The `--skip-locking' option is on by default when compiling with
  23091.      MIT-pthreads, because `flock()' isn't fully supported by
  23092.      MIT-pthreads on all platforms.  It's also on default for Linux as
  23093.      Linux file locking are not yet safe.
  23094.  
  23095.      The only case when you can't use `--skip-locking' is if you run
  23096.      multiple MySQL _servers_ (not clients) on the same data, or run
  23097.      `myisamchk' on the table without first flushing and locking the
  23098.      `mysqld' server tables first.
  23099.  
  23100.      You can still use `LOCK TABLES'/`UNLOCK TABLES' even if you are
  23101.      using `--skip-locking'
  23102.  
  23103. 
  23104. File: mysql.info,  Node: Server parameters,  Next: Compile and link options,  Prev: System,  Up: Optimizing the Server
  23105.  
  23106. Tuning Server Parameters
  23107. ------------------------
  23108.  
  23109. You can get the default buffer sizes used by the `mysqld' server with
  23110. this command:
  23111.  
  23112.      shell> mysqld --help
  23113.  
  23114. This command produces a list of all `mysqld' options and configurable
  23115. variables. The output includes the default values and looks something
  23116. like this:
  23117.  
  23118.      Possible variables for option --set-variable (-O) are:
  23119.      back_log              current value: 5
  23120.      bdb_cache_size        current value: 1048540
  23121.      binlog_cache_size     current_value: 32768
  23122.      connect_timeout       current value: 5
  23123.      delayed_insert_timeout  current value: 300
  23124.      delayed_insert_limit  current value: 100
  23125.      delayed_queue_size    current value: 1000
  23126.      flush_time            current value: 0
  23127.      interactive_timeout   current value: 28800
  23128.      join_buffer_size      current value: 131072
  23129.      key_buffer_size       current value: 1048540
  23130.      lower_case_table_names  current value: 0
  23131.      long_query_time       current value: 10
  23132.      max_allowed_packet    current value: 1048576
  23133.      max_binlog_cache_size current_value: 4294967295
  23134.      max_connections       current value: 100
  23135.      max_connect_errors    current value: 10
  23136.      max_delayed_threads   current value: 20
  23137.      max_heap_table_size   current value: 16777216
  23138.      max_join_size         current value: 4294967295
  23139.      max_sort_length       current value: 1024
  23140.      max_tmp_tables        current value: 32
  23141.      max_write_lock_count  current value: 4294967295
  23142.      myisam_sort_buffer_size  current value: 8388608
  23143.      net_buffer_length     current value: 16384
  23144.      net_retry_count       current value: 10
  23145.      net_read_timeout      current value: 30
  23146.      net_write_timeout     current value: 60
  23147.      query_buffer_size     current value: 0
  23148.      record_buffer         current value: 131072
  23149.      record_rnd_buffer     current value: 131072
  23150.      slow_launch_time      current value: 2
  23151.      sort_buffer           current value: 2097116
  23152.      table_cache           current value: 64
  23153.      thread_concurrency    current value: 10
  23154.      tmp_table_size        current value: 1048576
  23155.      thread_stack          current value: 131072
  23156.      wait_timeout          current value: 28800
  23157.  
  23158. If there is a `mysqld' server currently running, you can see what
  23159. values it actually is using for the variables by executing this command:
  23160.  
  23161.      shell> mysqladmin variables
  23162.  
  23163. You can find a full description for all variables in the `SHOW
  23164. VARIABLES' section in this manual. *Note SHOW VARIABLES::.
  23165.  
  23166. You can also see some statistics from a running server by issuing the
  23167. command `SHOW STATUS'. *Note SHOW STATUS::.
  23168.  
  23169. MySQL uses algorithms that are very scalable, so you can usually run
  23170. with very little memory. If you, however, give MySQL more memory, you
  23171. will normally also get better performance.
  23172.  
  23173. When tuning a MySQL server, the two most important variables to use are
  23174. `key_buffer_size' and `table_cache'.  You should first feel confident
  23175. that you have these right before trying to change any of the other
  23176. variables.
  23177.  
  23178. If you have much memory (>=256M) and many tables and want maximum
  23179. performance with a moderate number of clients, you should use something
  23180. like this:
  23181.  
  23182.      shell> safe_mysqld -O key_buffer=64M -O table_cache=256 \
  23183.                 -O sort_buffer=4M -O record_buffer=1M &
  23184.  
  23185. If you have only 128M and only a few tables, but you still do a lot of
  23186. sorting, you can use something like:
  23187.  
  23188.      shell> safe_mysqld -O key_buffer=16M -O sort_buffer=1M
  23189.  
  23190. If you have little memory and lots of connections, use something like
  23191. this:
  23192.  
  23193.      shell> safe_mysqld -O key_buffer=512k -O sort_buffer=100k \
  23194.                 -O record_buffer=100k &
  23195.  
  23196. or even:
  23197.  
  23198.      shell> safe_mysqld -O key_buffer=512k -O sort_buffer=16k \
  23199.                 -O table_cache=32 -O record_buffer=8k -O net_buffer=1K &
  23200.  
  23201. If you are doing a `GROUP BY' or `ORDER BY' on files that are much
  23202. bigger than your available memory you should increase the value of
  23203. `record_rnd_buffer' to speed up the reading of rows after the sorting
  23204. is done.
  23205.  
  23206. When you have installed MySQL, the `support-files' directory will
  23207. contain some different `my.cnf' example files, `my-huge.cnf',
  23208. `my-large.cnf', `my-medium.cnf', and `my-small.cnf', you can use as a
  23209. base to optimize your system.
  23210.  
  23211. If there are very many connections, "swapping problems" may occur unless
  23212. `mysqld' has been configured to use very little memory for each
  23213. connection. `mysqld' performs better if you have enough memory for all
  23214. connections, of course.
  23215.  
  23216. Note that if you change an option to `mysqld', it remains in effect only
  23217. for that instance of the server.
  23218.  
  23219. To see the effects of a parameter change, do something like this:
  23220.  
  23221.      shell> mysqld -O key_buffer=32m --help
  23222.  
  23223. Make sure that the `--help' option is last; otherwise, the effect of any
  23224. options listed after it on the command line will not be reflected in the
  23225. output.
  23226.  
  23227. 
  23228. File: mysql.info,  Node: Compile and link options,  Next: Memory use,  Prev: Server parameters,  Up: Optimizing the Server
  23229.  
  23230. How Compiling and Linking Affects the Speed of MySQL
  23231. ----------------------------------------------------
  23232.  
  23233. Most of the following tests are done on Linux with the MySQL
  23234. benchmarks, but they should give some indication for other operating
  23235. systems and workloads.
  23236.  
  23237. You get the fastest executable when you link with `-static'.
  23238.  
  23239. On Linux, you will get the fastest code when compiling with `pgcc' and
  23240. `-O3'. To compile `sql_yacc.cc' with these options, you need about 200M
  23241. memory because `gcc/pgcc' needs a lot of memory to make all functions
  23242. inline. You should also set `CXX=gcc' when configuring MySQL to avoid
  23243. inclusion of the `libstdc++' library (it is not needed). Note that with
  23244. some versions of `pgcc', the resulting code will only run on true
  23245. Pentium processors, even if you use the compiler option that you want
  23246. the resulting code to be working on all x586 type processors (like AMD).
  23247.  
  23248. By just using a better compiler and/or better compiler options you can
  23249. get a 10-30 % speed increase in your application.  This is particularly
  23250. important if you compile the SQL server yourself!
  23251.  
  23252. We have tested both the Cygnus CodeFusion and Fujitsu compilers, but
  23253. when we tested them, neither was sufficiently bug free to allow MySQL
  23254. to be compiled with optimizations on.
  23255.  
  23256. When you compile MySQL you should only include support for the
  23257. character sets that you are going to use. (Option `--with-charset=xxx').
  23258. The standard MySQL binary distributions are compiled with support for
  23259. all character sets.
  23260.  
  23261. Here is a list of some measurements that we have done:
  23262.    * If you use `pgcc' and compile everything with `-O6', the `mysqld'
  23263.      server is 1% faster than with `gcc' 2.95.2.
  23264.  
  23265.    * If you link dynamically (without `-static'), the result is 13%
  23266.      slower on Linux.  Note that you still can use a dynamic linked
  23267.      MySQL library. It is only the server that is critical for
  23268.      performance.
  23269.  
  23270.    * If you strip your `mysqld' binary with `strip libexec/mysqld', the
  23271.      resulting binary can be up to 4 % faster.
  23272.  
  23273.    * If you connect using TCP/IP rather than Unix sockets, the result
  23274.      is 7.5% slower on the same computer. (If you are connection to
  23275.      `localhost', MySQL will, by default, use sockets).
  23276.  
  23277.    * If you connect using TCP/IP from another computer over a 100M
  23278.      Ethernet, things will be 8-11 % slower.
  23279.  
  23280.    * If you compile with `--with-debug=full', then you will loose 20 %
  23281.      for most queries, but some queries may take substantially longer
  23282.      (The MySQL benchmarks ran 35 % slower) If you use `--with-debug',
  23283.      then you will only loose 15 %.  By starting a `mysqld' version
  23284.      compiled with `--with-debug=full' with `--skip-safemalloc' the end
  23285.      result should be close to when configuring with `--with-debug'.
  23286.  
  23287.    * On a Sun SPARCstation 20, SunPro C++ 4.2 is 5 % faster than `gcc'
  23288.      2.95.2.
  23289.  
  23290.    * Compiling with `gcc' 2.95.2 for ultrasparc with the option
  23291.      `-mcpu=v8 -Wa,-xarch=v8plusa' gives 4 % more performance.
  23292.  
  23293.    * On Solaris 2.5.1, MIT-pthreads is 8-12% slower than Solaris native
  23294.      threads on a single processor. With more load/CPUs the difference
  23295.      should get bigger.
  23296.  
  23297.    * Running with `--log-bin' makes *[MySQL* 1 % slower.
  23298.  
  23299.    * Compiling on Linux-x86 using gcc without frame pointers
  23300.      `-fomit-frame-pointer' or `-fomit-frame-pointer -ffixed-ebp'
  23301.      `mysqld' 1-4% faster.
  23302.  
  23303. The MySQL-Linux distribution provided by MySQL AB used to be compiled
  23304. with `pgcc', but we had to go back to regular gcc because of a bug in
  23305. `pgcc' that would generate the code that does not run on AMD. We will
  23306. continue using gcc until that bug is resolved.  In the meantime, if you
  23307. have a non-AMD machine, you can get a faster binary by compiling with
  23308. `pgcc'.  The standard MySQL Linux binary is linked statically to get it
  23309. faster and more portable.
  23310.  
  23311. 
  23312. File: mysql.info,  Node: Memory use,  Next: DNS,  Prev: Compile and link options,  Up: Optimizing the Server
  23313.  
  23314. How MySQL Uses Memory
  23315. ---------------------
  23316.  
  23317. The list below indicates some of the ways that the `mysqld' server uses
  23318. memory.  Where applicable, the name of the server variable relevant to
  23319. the memory use is given:
  23320.  
  23321.    * The key buffer (variable `key_buffer_size') is shared by all
  23322.      threads; Other buffers used by the server are allocated as needed.
  23323.      *Note Server parameters::.
  23324.  
  23325.    * Each connection uses some thread-specific space: A stack (default
  23326.      64K, variable `thread_stack'), a connection buffer (variable
  23327.      `net_buffer_length'), and a result buffer (variable
  23328.      `net_buffer_length'). The connection buffer and result buffer are
  23329.      dynamically enlarged up to `max_allowed_packet' when needed.  When
  23330.      a query is running, a copy of the current query string is also
  23331.      allocated.
  23332.  
  23333.    * All threads share the same base memory.
  23334.  
  23335.    * Only the compressed ISAM / MyISAM tables are memory mapped.  This
  23336.      is because the 32-bit memory space of 4GB is not large enough for
  23337.      most big tables. When systems with a 64-bit address space become
  23338.      more common we may add general support for memory mapping.
  23339.  
  23340.    * Each request doing a sequential scan over a table allocates a read
  23341.      buffer (variable `record_buffer').
  23342.  
  23343.    * When reading rows in 'random' order (for example after a sort) a
  23344.      random-read buffer is allocated to avoid disk seeks.  (variable
  23345.      `record_rnd_buffer').
  23346.  
  23347.    * All joins are done in one pass, and most joins can be done without
  23348.      even using a temporary table. Most temporary tables are
  23349.      memory-based (HEAP) tables.  Temporary tables with a big record
  23350.      length (calculated as the sum of all column lengths) or that
  23351.      contain `BLOB' columns are stored on disk.
  23352.  
  23353.      One problem in MySQL versions before Version 3.23.2 is that if a
  23354.      HEAP table exceeds the size of `tmp_table_size', you get the error
  23355.      `The table tbl_name is full'. In newer versions this is handled by
  23356.      automatically changing the in-memory (HEAP) table to a disk-based
  23357.      (MyISAM) table as necessary. To work around this problem, you can
  23358.      increase the temporary table size by setting the `tmp_table_size'
  23359.      option to `mysqld', or by setting the SQL option `SQL_BIG_TABLES'
  23360.      in the client program.  *Note `SET OPTION': SET OPTION. In MySQL
  23361.      Version 3.20, the maximum size of the temporary table was
  23362.      `record_buffer*16', so if you are using this version, you have to
  23363.      increase the value of `record_buffer'. You can also start `mysqld'
  23364.      with the `--big-tables' option to always store temporary tables on
  23365.      disk. However, this will affect the speed of many complicated
  23366.      queries.
  23367.  
  23368.    * Most requests doing a sort allocates a sort buffer and 0-2
  23369.      temporary files depending on the result set size. *Note Temporary
  23370.      files::.
  23371.  
  23372.    * Almost all parsing and calculating is done in a local memory
  23373.      store. No memory overhead is needed for small items and the normal
  23374.      slow memory allocation and freeing is avoided. Memory is allocated
  23375.      only for unexpectedly large strings (this is done with `malloc()'
  23376.      and `free()').
  23377.  
  23378.    * Each index file is opened once and the data file is opened once
  23379.      for each concurrently running thread. For each concurrent thread,
  23380.      a table structure, column structures for each column, and a buffer
  23381.      of size `3 * n' is allocated (where `n' is the maximum row length,
  23382.      not counting `BLOB' columns). A `BLOB' uses 5 to 8 bytes plus the
  23383.      length of the `BLOB' data. The `ISAM'/`MyISAM' table handlers will
  23384.      use one extra row buffer for internal usage.
  23385.  
  23386.    * For each table having `BLOB' columns, a buffer is enlarged
  23387.      dynamically to read in larger `BLOB' values. If you scan a table,
  23388.      a buffer as large as the largest `BLOB' value is allocated.
  23389.  
  23390.    * Table handlers for all in-use tables are saved in a cache and
  23391.      managed as a FIFO. Normally the cache has 64 entries. If a table
  23392.      has been used by two running threads at the same time, the cache
  23393.      contains two entries for the table. *Note Table cache::.
  23394.  
  23395.    * A `mysqladmin flush-tables' command closes all tables that are not
  23396.      in use and marks all in-use tables to be closed when the currently
  23397.      executing thread finishes. This will effectively free most in-use
  23398.      memory.
  23399.  
  23400. `ps' and other system status programs may report that `mysqld' uses a
  23401. lot of memory. This may be caused by thread-stacks on different memory
  23402. addresses. For example, the Solaris version of `ps' counts the unused
  23403. memory between stacks as used memory. You can verify this by checking
  23404. available swap with `swap -s'. We have tested `mysqld' with commercial
  23405. memory-leakage detectors, so there should be no memory leaks.
  23406.  
  23407. 
  23408. File: mysql.info,  Node: DNS,  Next: SET OPTION,  Prev: Memory use,  Up: Optimizing the Server
  23409.  
  23410. How MySQL uses DNS
  23411. ------------------
  23412.  
  23413. When a new thread connects to `mysqld', `mysqld' will span a new thread
  23414. to handle the request.  This thread will first check if the hostname is
  23415. in the hostname cache. If not the thread will call `gethostbyaddr_r()'
  23416. and `gethostbyname_r()' to resolve the hostname.
  23417.  
  23418. If the operating system doesn't support the above thread-safe calls, the
  23419. thread will lock a mutex and call `gethostbyaddr()' and
  23420. `gethostbyname()' instead. Note that in this case no other thread can
  23421. resolve other hostnames that is not in the hostname cache until the
  23422. first thread is ready.
  23423.  
  23424. You can disable DNS host lookup by starting `mysqld' with
  23425. `--skip-name-resolve'.  In this case you can however only use IP names
  23426. in the MySQL privilege tables.
  23427.  
  23428. If you have a very slow DNS and many hosts, you can get more
  23429. performance by either disabling DNS lookop with `--skip-name-resolve'
  23430. or by increasing the `HOST_CACHE_SIZE' define (default: 128) and
  23431. recompile `mysqld'.
  23432.  
  23433. You can disable the hostname cache with `--skip-host-cache'. You can
  23434. clear the hostname cache with `FLUSH HOSTS' or `mysqladmin flush-hosts'.
  23435.  
  23436. If you don't want to allow connections over `TCP/IP', you can do this
  23437. by starting `mysqld' with `--skip-networking'.
  23438.  
  23439. 
  23440. File: mysql.info,  Node: SET OPTION,  Prev: DNS,  Up: Optimizing the Server
  23441.  
  23442. `SET' Syntax
  23443. ------------
  23444.  
  23445.      SET [OPTION] SQL_VALUE_OPTION= value, ...
  23446.  
  23447. `SET OPTION' sets various options that affect the operation of the
  23448. server or your client.  Any option you set remains in effect until the
  23449. current session ends, or until you set the option to a different value.
  23450.  
  23451. `CHARACTER SET character_set_name | DEFAULT'
  23452.      This maps all strings from and to the client with the given
  23453.      mapping.  Currently the only option for `character_set_name' is
  23454.      `cp1251_koi8', but you can easily add new mappings by editing the
  23455.      `sql/convert.cc' file in the MySQL source distribution.  The
  23456.      default mapping can be restored by using a `character_set_name'
  23457.      value of `DEFAULT'.
  23458.  
  23459.      Note that the syntax for setting the `CHARACTER SET' option differs
  23460.      from the syntax for setting the other options.
  23461.  
  23462. `PASSWORD = PASSWORD('some password')'
  23463.      Set the password for the current user. Any non-anonymous user can
  23464.      change his own password!
  23465.  
  23466. `PASSWORD FOR user = PASSWORD('some password')'
  23467.      Set the password for a specific user on the current server host.
  23468.      Only a user with access to the `mysql' database can do this.  The
  23469.      user should be given in `user@hostname' format, where `user' and
  23470.      `hostname' are exactly as they are listed in the `User' and `Host'
  23471.      columns of the `mysql.user' table entry.  For example, if you had
  23472.      an entry with `User' and `Host' fields of `'bob'' and
  23473.      `'%.loc.gov'', you would write:
  23474.  
  23475.           mysql> SET PASSWORD FOR bob@"%.loc.gov" = PASSWORD("newpass");
  23476.           
  23477.           or
  23478.           
  23479.           mysql> UPDATE mysql.user SET password=PASSWORD("newpass") where user="bob' and host="%.loc.gov";
  23480.  
  23481. `SQL_AUTO_IS_NULL = 0 | 1'
  23482.      If set to `1' (default) then one can find the last inserted row
  23483.      for a table with an auto_increment row with the following
  23484.      construct: `WHERE auto_increment_column IS NULL'.  This is used by
  23485.      some ODBC programs like Access.
  23486.  
  23487. `AUTOCOMMIT= 0 | 1'
  23488.      If set to `1' all changes to a table will be done at once. To start
  23489.      a multi-command transaction, you have to use the `BEGIN'
  23490.      statement. *Note COMMIT::. If set to `0' you have to use `COMMIT' /
  23491.      `ROLLBACK' to accept/revoke that transaction. *Note COMMIT::.  Note
  23492.      that when you change from not `AUTOCOMMIT' mode to `AUTOCOMMIT'
  23493.      mode, MySQL will do an automatic `COMMIT' on any open transactions.
  23494.  
  23495. `SQL_BIG_TABLES = 0 | 1'
  23496.      If set to `1', all temporary tables are stored on disk rather than
  23497.      in memory.  This will be a little slower, but you will not get the
  23498.      error `The table tbl_name is full' for big `SELECT' operations that
  23499.      require a large temporary table.  The default value for a new
  23500.      connection is `0' (that is, use in-memory temporary tables).
  23501.  
  23502. `SQL_BIG_SELECTS = 0 | 1'
  23503.      If set to `0', MySQL will abort if a `SELECT' is attempted that
  23504.      probably will take a very long time. This is useful when an
  23505.      inadvisable `WHERE' statement has been issued. A big query is
  23506.      defined as a `SELECT' that probably will have to examine more than
  23507.      `max_join_size' rows.  The default value for a new connection is
  23508.      `1' (which will allow all `SELECT' statements).
  23509.  
  23510. `SQL_BUFFER_RESULT = 0 | 1'
  23511.      `SQL_BUFFER_RESULT' will force the result from `SELECT''s to be
  23512.      put into a temporary table. This will help MySQL free the table
  23513.      locks early and will help in cases where it takes a long time to
  23514.      send the result set to the client.
  23515.  
  23516. `SQL_LOW_PRIORITY_UPDATES = 0 | 1'
  23517.      If set to `1', all `INSERT', `UPDATE', `DELETE', and and `LOCK
  23518.      TABLE WRITE' statements wait until there is no pending `SELECT' or
  23519.      `LOCK TABLE READ' on the affected table.
  23520.  
  23521. `SQL_MAX_JOIN_SIZE = value | DEFAULT'
  23522.      Don't allow `SELECT's that will probably need to examine more than
  23523.      `value' row combinations.  By setting this value, you can catch
  23524.      `SELECT's where keys are not used properly and that would probably
  23525.      take a long time. Setting this to a value other than `DEFAULT'
  23526.      will reset the `SQL_BIG_SELECTS' flag.  If you set the
  23527.      `SQL_BIG_SELECTS' flag again, the `SQL_MAX_JOIN_SIZE' variable
  23528.      will be ignored.  You can set a default value for this variable by
  23529.      starting `mysqld' with `-O max_join_size=#'.
  23530.  
  23531. `SQL_SAFE_UPDATES = 0 | 1'
  23532.      If set to `1', MySQL will abort if an `UPDATE' or `DELETE' is
  23533.      attempted that doesn't use a key or `LIMIT' in the `WHERE' clause.
  23534.      This makes it possible to catch wrong updates when creating SQL
  23535.      commands by hand.
  23536.  
  23537. `SQL_SELECT_LIMIT = value | DEFAULT'
  23538.      The maximum number of records to return from `SELECT' statements.
  23539.      If a `SELECT' has a `LIMIT' clause, the `LIMIT' takes precedence
  23540.      over the value of `SQL_SELECT_LIMIT'.  The default value for a new
  23541.      connection is "unlimited." If you have changed the limit, the
  23542.      default value can be restored by using a `SQL_SELECT_LIMIT' value
  23543.      of `DEFAULT'.
  23544.  
  23545. `SQL_LOG_OFF = 0 | 1'
  23546.      If set to `1', no logging will be done to the standard log for this
  23547.      client, if the client has the *process* privilege.  This does not
  23548.      affect the update log!
  23549.  
  23550. `SQL_LOG_UPDATE = 0 | 1'
  23551.      If set to `0', no logging will be done to the update log for the
  23552.      client, if the client has the *process* privilege.  This does not
  23553.      affect the standard log!
  23554.  
  23555. `SQL_QUOTE_SHOW_CREATE = 0 | 1'
  23556.      If set to `1', `SHOW CREATE TABLE' will quote table and column
  23557.      names. This is *on* by default, for replication of tables with
  23558.      fancy column names to work.  *Note `SHOW CREATE TABLE': SHOW
  23559.      CREATE TABLE.
  23560.  
  23561. `TIMESTAMP = timestamp_value | DEFAULT'
  23562.      Set the time for this client.  This is used to get the original
  23563.      timestamp if you use the update log to restore rows.
  23564.      `timestamp_value' should be a UNIX Epoch timestamp, not a MySQL
  23565.      timestamp.
  23566.  
  23567. `LAST_INSERT_ID = #'
  23568.      Set the value to be returned from `LAST_INSERT_ID()'. This is
  23569.      stored in the update log when you use `LAST_INSERT_ID()' in a
  23570.      command that updates a table.
  23571.  
  23572. `INSERT_ID = #'
  23573.      Set the value to be used by the following `INSERT' or `ALTER TABLE'
  23574.      command when inserting an `AUTO_INCREMENT' value.  This is mainly
  23575.      used with the update log.
  23576.  
  23577. * Menu:
  23578.  
  23579. * SET TRANSACTION::             `SET TRANSACTION' Syntax
  23580.  
  23581. 
  23582. File: mysql.info,  Node: Disk issues,  Prev: Optimizing the Server,  Up: MySQL Optimization
  23583.  
  23584. Disk Issues
  23585. ===========
  23586.  
  23587.    * As mentioned before, disks seeks are a big performance bottleneck.
  23588.      This problems gets more and more apparent when the data starts to
  23589.      grow so large that effective caching becomes impossible. For large
  23590.      databases, where you access data more or less randomly, you can be
  23591.      sure that you will need at least one disk seek to read and a
  23592.      couple of disk seeks to write things. To minimize this problem,
  23593.      use disks with low seek times.
  23594.  
  23595.    * Increase the number of available disk spindles (and thereby reduce
  23596.      the seek overhead) by either symlink files to different disks or
  23597.      striping the disks.
  23598.  
  23599.     *Using symbolic links*
  23600.           This means that you symlink the index and/or data file(s)
  23601.           from the normal data directory to another disk (that may also
  23602.           be striped). This makes both the seek and read times better
  23603.           (if the disks are not used for other things). *Note Symbolic
  23604.           links::.
  23605.  
  23606.     *Striping*
  23607.           Striping means that you have many disks and put the first
  23608.           block on the first disk, the second block on the second disk,
  23609.           and the Nth on the (N mod number_of_disks) disk, and so on.
  23610.           This means if your normal data size is less than the stripe
  23611.           size (or perfectly aligned) you will get much better
  23612.           performance. Note that striping is very dependent on the OS
  23613.           and stripe-size. So benchmark your application with different
  23614.           stripe-sizes. *Note Custom Benchmarks::.
  23615.  
  23616.           Note that the speed difference for striping is *very*
  23617.           dependent on the parameters. Depending on how you set the
  23618.           striping parameters and number of disks you may get a
  23619.           difference in orders of magnitude. Note that you have to
  23620.           choose to optimize for random or sequential access.
  23621.  
  23622.    * For reliability you may want to use RAID 0+1 (striping +
  23623.      mirroring), but in this case you will need 2*N drives to hold N
  23624.      drives of data. This is probably the best option if you have the
  23625.      money for it!  You may, however, also have to invest in some
  23626.      volume-management software to handle it efficiently.
  23627.  
  23628.    * A good option is to have semi-important data (that can be
  23629.      regenerated) on RAID 0 disk while storing really important data
  23630.      (like host information and logs) on a RAID 0+1 or RAID N disk.
  23631.      RAID N can be a problem if you have many writes because of the
  23632.      time to update the parity bits.
  23633.  
  23634.    * You may also set the parameters for the file system that the
  23635.      database uses. One easy change is to mount the file system with
  23636.      the noatime option. That makes it skip the updating of the last
  23637.      access time in the inode and by this will avoid some disk seeks.
  23638.  
  23639.    * On Linux, you can get much more performance (up to 100 % under
  23640.      load is not uncommon) by using hdpram to configure your disk's
  23641.      interface!  The following should be quite good hdparm options for
  23642.      MySQL (and probably many other applications):
  23643.  
  23644.           hdparm -m 16 -d 1
  23645.  
  23646.      Note that the performance/reliability when using the above depends
  23647.      on your hardware, so we strongly suggest that you test your system
  23648.      thoroughly after using `hdparm'!  Please consult the `hdparm' man
  23649.      page for more information!  If `hdparm' is not used wisely,
  23650.      filesystem corruption may result.  Backup everything before
  23651.      experimenting!
  23652.  
  23653.    * On many operating systems you can mount the disks with the 'async'
  23654.      flag to set the file system to be updated asynchronously.  If your
  23655.      computer is reasonable stable, this should give you more
  23656.      performance without sacrificing too much reliability.  (This flag
  23657.      is on by default on Linux.)
  23658.  
  23659.    * If you don't need to know when a file was last accessed (which is
  23660.      not really useful on a database server), you can mount your file
  23661.      systems with the noatime flag.
  23662.  
  23663. * Menu:
  23664.  
  23665. * Symbolic links::              Using Symbolic Links
  23666.  
  23667. 
  23668. File: mysql.info,  Node: Symbolic links,  Prev: Disk issues,  Up: Disk issues
  23669.  
  23670. Using Symbolic Links
  23671. --------------------
  23672.  
  23673. You can move tables and databases from the database directory to other
  23674. locations and replace them with symbolic links to the new locations.
  23675. You might want to do this, for example, to move a database to a file
  23676. system with more free space or increase the speed of your system by
  23677. spreading your tables to different disk.
  23678.  
  23679. The recommended may to do this, is to just symlink databases to
  23680. different disk and only symlink tables as a last resort.
  23681.  
  23682. * Menu:
  23683.  
  23684. * Symbolic links to databases::  Using Symbolic Links for Databases
  23685. * Symbolic links to tables::    Using Symbolic Links for Tables
  23686.  
  23687. 
  23688. File: mysql.info,  Node: Symbolic links to databases,  Next: Symbolic links to tables,  Prev: Symbolic links,  Up: Symbolic links
  23689.  
  23690. Using Symbolic Links for Databases
  23691. ..................................
  23692.  
  23693. The way to symlink a database is to first create a directory on some
  23694. disk where you have free space and then create a symlink to it from the
  23695. MySQL database directory.
  23696.  
  23697.      shell> mkdir /dr1/databases/test
  23698.      shell> ln -s /dr1/databases/test mysqld-datadir
  23699.  
  23700. MySQL doesn't support that you link one directory to multiple
  23701. databases.  Replacing a database directory with a symbolic link will
  23702. work fine as long as you don't make a symbolic link between databases.
  23703. Suppose you have a database `db1' under the MySQL data directory, and
  23704. then make a symlink `db2' that points to `db1':
  23705.  
  23706.      shell> cd /path/to/datadir
  23707.      shell> ln -s db1 db2
  23708.  
  23709. Now, for any table `tbl_a' in `db1', there also appears to be a table
  23710. `tbl_a' in `db2'.  If one thread updates `db1.tbl_a' and another thread
  23711. updates `db2.tbl_a', there will be problems.
  23712.  
  23713. If you really need this, you must change the following code in
  23714. `mysys/mf_format.c':
  23715.  
  23716.      if (flag & 32 || (!lstat(to,&stat_buff) && S_ISLNK(stat_buff.st_mode)))
  23717.  
  23718. to
  23719.  
  23720.      if (1)
  23721.  
  23722. On Windows you can use internal symbolic links to directories by
  23723. compiling MySQL with `-DUSE_SYMDIR'. This allows you to put different
  23724. databases on different disks. *Note Windows symbolic links::.
  23725.  
  23726. 
  23727. File: mysql.info,  Node: Symbolic links to tables,  Prev: Symbolic links to databases,  Up: Symbolic links
  23728.  
  23729. Using Symbolic Links for Tables
  23730. ...............................
  23731.  
  23732. Before MySQL 4.0 you should not symlink tables, if you are not very
  23733. carefully with them. The problem is that if you run `ALTER TABLE',
  23734. `REPAIR TABLE' or `OPTIMIZE TABLE' on a symlinked table, the symlinks
  23735. will be removed and replaced by the original files. This happens
  23736. because the above command works by creating a temporary file in the
  23737. database directory and when the command is complete, replace the
  23738. original file with the temporary file.
  23739.  
  23740. You should not symlink tables on system that doesn't have a fully
  23741. working `realpath()' call. (At least Linux and Solaris support
  23742. `realpath()')
  23743.  
  23744. In MySQL 4.0 symlinks is only fully supported for `MyISAM' tables.  For
  23745. other table types you will probably get strange problems when doing any
  23746. of the above mentioned commands.
  23747.  
  23748. The handling of symbolic links in MySQL 4.0 works the following way
  23749. (this is mostly relevant only for `MyISAM' tables).
  23750.  
  23751.    * In the data directory you will always have the table definition
  23752.      file and the data/index files.
  23753.  
  23754.    * You can symlink the index file and the data file to different
  23755.      directories independent of the other.
  23756.  
  23757.    * The symlinking can be done from the operating system (if `mysqld'
  23758.      is not running) or with the `INDEX/DATA DIRECTORY="path-to-dir"'
  23759.      command in `CREATE TABLE'. *Note CREATE TABLE::.
  23760.  
  23761.    * `myisamchk' will not replace a symlink with the index/file but
  23762.      work directly on the files the symlinks points to. Any temporary
  23763.      files will be created in the same directory where the data/index
  23764.      file is.
  23765.  
  23766.    * When you drop a table that is using symlinks, both the symlink and
  23767.      the file the symlink points to is dropped.  This is a good reason
  23768.      to why you should NOT run `mysqld' as root and not allow persons
  23769.      to have write access to the MySQL database directories.
  23770.  
  23771.    * If you rename a table with `ALTER TABLE RENAME' and you don't
  23772.      change database, the symlink in the database directory will be
  23773.      renamed to the new name and the data/index file will be renamed
  23774.      accordingly.
  23775.  
  23776.    * If you use `ALTER TABLE RENAME' to move a table to another
  23777.      database, then the table will be moved to the other database
  23778.      directory and the old symlinks and the files they pointed to will
  23779.      be deleted.
  23780.  
  23781.    * If you are not using symlinks you should use the `--skip-symlink'
  23782.      option to `mysqld' to ensure that no one can drop or rename a file
  23783.      outside of the `mysqld' data directory.
  23784.  
  23785. Things that are not yet supported:
  23786.  
  23787.    * `ALTER TABLE' ignores all `INDEX/DATA DIRECTORY="path"' options.
  23788.  
  23789.    * `CREATE TABLE' doesn't report if the table has symbolic links.
  23790.  
  23791.    * `mysqldump' doesn't include the symbolic links information in the
  23792.      output.
  23793.  
  23794.    * `BACKUP TABLE' and `RESTORE TABLE' don't respect symbolic links.
  23795.  
  23796. 
  23797. File: mysql.info,  Node: Reference,  Next: Table types,  Prev: MySQL Optimization,  Up: Top
  23798.  
  23799. MySQL Language Reference
  23800. ************************
  23801.  
  23802. * Menu:
  23803.  
  23804. * Language Structure::          Language Structure
  23805. * Column types::                Column types
  23806. * Functions::                   Functions
  23807. * Data Manipulation::           Data Manipulation: `SELECT', `INSERT', `UPDATE', `DELETE'
  23808. * Data Definition::             Data Definition: `CREATE', `DROP', `ALTER'
  23809. * Basic User Commands::         Basic MySQL User Utility Commands
  23810. * Transactional Commands::      MySQL Transactional and Locking Commands
  23811. * Fulltext Search::             MySQL Full-text Search
  23812.  
  23813. MySQL has a very complex, but intuitive and easy to learn SQL
  23814. interface.  This chapter describes the various commands, types, and
  23815. functions you will need to know in order to use MySQL efficiently and
  23816. effectively.  This chapter also serves as a reference to all
  23817. functionality included in MySQL.  In order to use this chapter
  23818. effectively, you may find it useful to refer to the various indexes.
  23819.  
  23820. 
  23821. File: mysql.info,  Node: Language Structure,  Next: Column types,  Prev: Reference,  Up: Reference
  23822.  
  23823. Language Structure
  23824. ==================
  23825.  
  23826. * Menu:
  23827.  
  23828. * Literals::                    Literals: How to Write Strings and Numbers
  23829. * Legal names::                 Database, Table, Index, Column, and Alias Names
  23830. * Name case sensitivity::       Case Sensitivity in Names
  23831. * Variables::                   User Variables
  23832. * Comments::                    Comment Syntax
  23833. * Reserved words::              Is MySQL Picky About Reserved Words?
  23834.  
  23835. 
  23836. File: mysql.info,  Node: Literals,  Next: Legal names,  Prev: Language Structure,  Up: Language Structure
  23837.  
  23838. Literals: How to Write Strings and Numbers
  23839. ------------------------------------------
  23840.  
  23841. * Menu:
  23842.  
  23843. * String syntax::               Strings
  23844. * Number syntax::               Numbers
  23845. * Hexadecimal values::          Hexadecimal values
  23846. * NULL values::                 `NULL' values
  23847.  
  23848. This section describes the various ways to write strings and numbers in
  23849. MySQL.  It also covers the various nuances and "gotchas" that you may
  23850. run into when dealing with these basic types in MySQL.
  23851.  
  23852. 
  23853. File: mysql.info,  Node: String syntax,  Next: Number syntax,  Prev: Literals,  Up: Literals
  23854.  
  23855. Strings
  23856. .......
  23857.  
  23858. A string is a sequence of characters, surrounded by either single quote
  23859. (`'') or double quote (`"') characters (only the single quote if you
  23860. run in ANSI mode).  Examples:
  23861.  
  23862.      'a string'
  23863.      "another string"
  23864.  
  23865. Within a string, certain sequences have special meaning.  Each of these
  23866. sequences begins with a backslash (`\'), known as the _escape
  23867. character_.  MySQL recognizes the following escape sequences:
  23868.  
  23869. `\0'
  23870.      An ASCII 0 (`NUL') character.
  23871.  
  23872. `\''
  23873.      A single quote (`'') character.
  23874.  
  23875. `\"'
  23876.      A double quote (`"') character.
  23877.  
  23878. `\b'
  23879.      A backspace character.
  23880.  
  23881. `\n'
  23882.      A newline character.
  23883.  
  23884. `\r'
  23885.      A carriage return character.
  23886.  
  23887. `\t'
  23888.      A tab character.
  23889.  
  23890. `\z'
  23891.      ASCII(26) (Control-Z).  This character can be encoded to allow you
  23892.      to go around the problem that ASCII(26) stands for END-OF-FILE on
  23893.      Windows.  (ASCII(26) will cause problems if you try to use `mysql
  23894.      database < filename').
  23895.  
  23896. `\\'
  23897.      A backslash (`\') character.
  23898.  
  23899. `\%'
  23900.      A `%' character. This is used to search for literal instances of
  23901.      `%' in contexts where `%' would otherwise be interpreted as a
  23902.      wild-card character. *Note String comparison functions::.
  23903.  
  23904. `\_'
  23905.      A `_' character. This is used to search for literal instances of
  23906.      `_' in contexts where `_' would otherwise be interpreted as a
  23907.      wild-card character. *Note String comparison functions::.
  23908.  
  23909. Note that if you use `\%' or `\_' in some string contexts, these will
  23910. return the strings `\%' and `\_' and not `%' and `_'.
  23911.  
  23912. There are several ways to include quotes within a string:
  23913.  
  23914.    * A `'' inside a string quoted with `'' may be written as `'''.
  23915.  
  23916.    * A `"' inside a string quoted with `"' may be written as `""'.
  23917.  
  23918.    * You can precede the quote character with an escape character (`\').
  23919.  
  23920.    * A `'' inside a string quoted with `"' needs no special treatment
  23921.      and need not be doubled or escaped.  In the same way, `"' inside a
  23922.      string quoted with `'' needs no special treatment.
  23923.  
  23924. The `SELECT' statements shown below demonstrate how quoting and
  23925. escaping work:
  23926.  
  23927.      mysql> SELECT 'hello', '"hello"', '""hello""', 'hel''lo', '\'hello';
  23928.      +-------+---------+-----------+--------+--------+
  23929.      | hello | "hello" | ""hello"" | hel'lo | 'hello |
  23930.      +-------+---------+-----------+--------+--------+
  23931.      
  23932.      mysql> SELECT "hello", "'hello'", "''hello''", "hel""lo", "\"hello";
  23933.      +-------+---------+-----------+--------+--------+
  23934.      | hello | 'hello' | ''hello'' | hel"lo | "hello |
  23935.      +-------+---------+-----------+--------+--------+
  23936.      
  23937.      mysql> SELECT "This\nIs\nFour\nlines";
  23938.      +--------------------+
  23939.      | This
  23940.      Is
  23941.      Four
  23942.      lines |
  23943.      +--------------------+
  23944.  
  23945. If you want to insert binary data into a `BLOB' column, the following
  23946. characters must be represented by escape sequences:
  23947. `NUL'
  23948.      ASCII 0. You should represent this by `\0' (a backslash and an
  23949.      ASCII `0' character).
  23950.  
  23951. `\'
  23952.      ASCII 92, backslash.  Represent this by `\\'.
  23953.  
  23954. `''
  23955.      ASCII 39, single quote.  Represent this by `\''.
  23956.  
  23957. `"'
  23958.      ASCII 34, double quote.  Represent this by `\"'.
  23959.  
  23960. If you write C code, you can use the C API function
  23961. `mysql_escape_string()' to escape characters for the `INSERT'
  23962. statement.  *Note C API function overview::.  In Perl, you can use the
  23963. `quote' method of the `DBI' package to convert special characters to
  23964. the proper escape sequences.  *Note Perl `DBI' Class: Perl DBI Class.
  23965.  
  23966. You should use an escape function on any string that might contain any
  23967. of the special characters listed above!
  23968.  
  23969. 
  23970. File: mysql.info,  Node: Number syntax,  Next: Hexadecimal values,  Prev: String syntax,  Up: Literals
  23971.  
  23972. Numbers
  23973. .......
  23974.  
  23975. Integers are represented as a sequence of digits. Floats use `.' as a
  23976. decimal separator.  Either type of number may be preceded by `-' to
  23977. indicate a negative value.
  23978.  
  23979. Examples of valid integers:
  23980.  
  23981.      1221
  23982.      0
  23983.      -32
  23984.  
  23985. Examples of valid floating-point numbers:
  23986.  
  23987.      294.42
  23988.      -32032.6809e+10
  23989.      148.00
  23990.  
  23991. An integer may be used in a floating-point context; it is interpreted
  23992. as the equivalent floating-point number.
  23993.  
  23994. 
  23995. File: mysql.info,  Node: Hexadecimal values,  Next: NULL values,  Prev: Number syntax,  Up: Literals
  23996.  
  23997. Hexadecimal Values
  23998. ..................
  23999.  
  24000. MySQL supports hexadecimal values.  In number context these act like an
  24001. integer (64-bit precision). In string context these act like a binary
  24002. string where each pair of hex digits is converted to a character:
  24003.  
  24004.      mysql> SELECT 0xa+0;
  24005.             -> 10
  24006.      mysql> select 0x5061756c;
  24007.             -> Paul
  24008.  
  24009. Hexadecimal strings are often used by ODBC to give values for BLOB
  24010. columns.
  24011.  
  24012. 
  24013. File: mysql.info,  Node: NULL values,  Prev: Hexadecimal values,  Up: Literals
  24014.  
  24015. `NULL' Values
  24016. .............
  24017.  
  24018. The `NULL' value means "no data" and is different from values such as
  24019. `0' for numeric types or the empty string for string types.  *Note
  24020. Problems with `NULL': Problems with NULL.
  24021.  
  24022. `NULL' may be represented by `\N' when using the text file import or
  24023. export formats (`LOAD DATA INFILE', `SELECT ... INTO OUTFILE').  *Note
  24024. `LOAD DATA': LOAD DATA.
  24025.  
  24026. 
  24027. File: mysql.info,  Node: Legal names,  Next: Name case sensitivity,  Prev: Literals,  Up: Language Structure
  24028.  
  24029. Database, Table, Index, Column, and Alias Names
  24030. -----------------------------------------------
  24031.  
  24032. * Menu:
  24033.  
  24034. * Name case sensitivity::       Case sensitivity in names
  24035.  
  24036. Database, table, index, column, and alias names all follow the same
  24037. rules in MySQL.
  24038.  
  24039. Note that the rules changed starting with MySQL Version 3.23.6 when we
  24040. introduced quoting of identifiers (database, table, and column names)
  24041. with ``'. `"' will also work to quote identifiers if you run in ANSI
  24042. mode. *Note ANSI mode::.
  24043.  
  24044. *Identifier**Max        *Allowed characters*
  24045.             length*     
  24046. Database    64          Any character that is allowed in a directory name
  24047.                         except `/' or `.'.
  24048. Table       64          Any character that is allowed in a file name,
  24049.                         except `/' or `.'.
  24050. Column      64          All characters.
  24051. Alias       255         All characters.
  24052.  
  24053. Note that in addition to the above, you can't have ASCII(0) or
  24054. ASCII(255) or the quoting character in an identifier.
  24055.  
  24056. Note that if the identifier is a restricted word or contains special
  24057. characters you must always quote it with ``' when you use it:
  24058.  
  24059.      SELECT * from `select` where `select`.id > 100;
  24060.  
  24061. In previous versions of MySQL, the name rules are as follows:
  24062.  
  24063.    * A name may consist of alphanumeric characters from the current
  24064.      character set and also `_' and `$'. The default character set is
  24065.      ISO-8859-1 Latin1; this may be changed with the
  24066.      `--default-character-set' option to `mysqld'.  *Note Character
  24067.      sets::.
  24068.  
  24069.    * A name may start with any character that is legal in a name.  In
  24070.      particular, a name may start with a number (this differs from many
  24071.      other database systems!).  However, a name cannot consist _only_
  24072.      of numbers.
  24073.  
  24074.    * You cannot use the `.' character in names because it is used to
  24075.      extend the format by which you can refer to columns (see
  24076.      immediately below).
  24077.  
  24078. It is recommended that you do not use names like `1e', because an
  24079. expression like `1e+1' is ambiguous. It may be interpreted as the
  24080. expression `1e + 1' or as the number `1e+1'.
  24081.  
  24082. In MySQL you can refer to a column using any of the following forms:
  24083.  
  24084. *Column reference*        *Meaning*
  24085. `col_name'                Column `col_name' from whichever table used in
  24086.                           the query contains a column of that name.
  24087. `tbl_name.col_name'       Column `col_name' from table `tbl_name' of the
  24088.                           current database.
  24089. `db_name.tbl_name.col_name'Column `col_name' from table `tbl_name' of the
  24090.                           database `db_name'.  This form is available in
  24091.                           MySQL Version 3.22 or later.
  24092. ``column_name`'           A column that is a keyword or contains special
  24093.                           characters.
  24094.  
  24095. You need not specify a `tbl_name' or `db_name.tbl_name' prefix for a
  24096. column reference in a statement unless the reference would be ambiguous.
  24097. For example, suppose tables `t1' and `t2' each contain a column `c',
  24098. and you retrieve `c' in a `SELECT' statement that uses both `t1' and
  24099. `t2'.  In this case, `c' is ambiguous because it is not unique among
  24100. the tables used in the statement, so you must indicate which table you
  24101. mean by writing `t1.c' or `t2.c'.  Similarly, if you are retrieving
  24102. from a table `t' in database `db1' and from a table `t' in database
  24103. `db2', you must refer to columns in those tables as `db1.t.col_name'
  24104. and `db2.t.col_name'.
  24105.  
  24106. The syntax `.tbl_name' means the table `tbl_name' in the current
  24107. database.  This syntax is accepted for ODBC compatibility, because some
  24108. ODBC programs prefix table names with a `.' character.
  24109.  
  24110. 
  24111. File: mysql.info,  Node: Name case sensitivity,  Next: Variables,  Prev: Legal names,  Up: Language Structure
  24112.  
  24113. Case Sensitivity in Names
  24114. -------------------------
  24115.  
  24116. In MySQL, databases and tables correspond to directories and files
  24117. within those directories.  Consequently, the case sensitivity of the
  24118. underlying operating system determines the case sensitivity of database
  24119. and table names.  This means database and table names are case
  24120. sensitive in Unix and case insensitive in Windows. *Note Extensions to
  24121. ANSI::.
  24122.  
  24123. *NOTE:* Although database and table names are case insensitive for
  24124. Windows, you should not refer to a given database or table using
  24125. different cases within the same query.  The following query would not
  24126. work because it refers to a table both as `my_table' and as `MY_TABLE':
  24127.  
  24128.      mysql> SELECT * FROM my_table WHERE MY_TABLE.col=1;
  24129.  
  24130. Column names are case insensitive in all cases.
  24131.  
  24132. Aliases on tables are case sensitive.  The following query would not
  24133. work because it refers to the alias both as `a' and as `A':
  24134.  
  24135.      mysql> SELECT col_name FROM tbl_name AS a
  24136.                 WHERE a.col_name = 1 OR A.col_name = 2;
  24137.  
  24138. Aliases on columns are case insensitive.
  24139.  
  24140. If you have a problem remembering the used cases for a table names,
  24141. adopt a consistent convention, such as always creating databases and
  24142. tables using lowercase names.
  24143.  
  24144. One way to avoid this problem is to start `mysqld' with `-O
  24145. lower_case_table_names=1'. By default this option is 1 on Windows and 0
  24146. on Unix.
  24147.  
  24148. If `lower_case_table_names' is 1 MySQL will convert all table names to
  24149. lower case on storage and lookup.  Note that if you change this option,
  24150. you need to first convert your old table names to lower case before
  24151. starting `mysqld'.
  24152.  
  24153. 
  24154. File: mysql.info,  Node: Variables,  Next: Comments,  Prev: Name case sensitivity,  Up: Language Structure
  24155.  
  24156. User Variables
  24157. --------------
  24158.  
  24159. MySQL supports thread-specific variables with the `@variablename'
  24160. syntax.  A variable name may consist of alphanumeric characters from
  24161. the current character set and also `_', `$', and `.' . The default
  24162. character set is ISO-8859-1 Latin1; this may be changed with the
  24163. `--default-character-set' option to `mysqld'. *Note Character sets::.
  24164.  
  24165. Variables don't have to be initialized.  They contain `NULL' by default
  24166. and can store an integer, real, or string value.  All variables for a
  24167. thread are automatically freed when the thread exits.
  24168.  
  24169. You can set a variable with the `SET' syntax:
  24170.  
  24171.      SET @variable= { integer expression | real expression | string expression }
  24172.      [,@variable= ...].
  24173.  
  24174. You can also set a variable in an expression with the `@variable:=expr'
  24175. syntax:
  24176.  
  24177.      select @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
  24178.      +----------------------+------+------+------+
  24179.      | @t1:=(@t2:=1)+@t3:=4 | @t1  | @t2  | @t3  |
  24180.      +----------------------+------+------+------+
  24181.      |                    5 |    5 |    1 |    4 |
  24182.      +----------------------+------+------+------+
  24183.  
  24184. (We had to use the `:=' syntax here, because `=' was reserved for
  24185. comparisons.)
  24186.  
  24187. User variables may be used where expressions are allowed.  Note that
  24188. this does not currently include use in contexts where a number is
  24189. explicitly required, such as in the `LIMIT' clause of a `SELECT'
  24190. statement, or the `IGNORE number LINES' clause of a `LOAD DATA'
  24191. statement.
  24192.  
  24193. *NOTE:*  In a `SELECT' statement, each expression is only evaluated
  24194. when it's sent to the client.  This means that in the `HAVING', `GROUP
  24195. BY', or `ORDER BY' clause, you can't refer to an expression that
  24196. involves variables that are set in the `SELECT' part. For example, the
  24197. following statement will NOT work as expected:
  24198.  
  24199.      SELECT (@aa:=id) AS a, (@aa+3) AS b FROM table_name HAVING b=5;
  24200.  
  24201. The reason is that `@aa' will not contain the value of the current row,
  24202. but the value of `id' for the previous accepted row.
  24203.  
  24204. * Menu:
  24205.  
  24206. * Comments::                    Comment Syntax
  24207. * Reserved words::              Is MySQL Picky About Reserved Words?
  24208.  
  24209. 
  24210. File: mysql.info,  Node: Comments,  Next: Reserved words,  Prev: Variables,  Up: Language Structure
  24211.  
  24212. Comment Syntax
  24213. --------------
  24214.  
  24215. The MySQL server supports the `# to end of line', `-- to end of line'
  24216. and `/* in-line or multiple-line */' comment styles:
  24217.  
  24218.      mysql> select 1+1;     # This comment continues to the end of line
  24219.      mysql> select 1+1;     -- This comment continues to the end of line
  24220.      mysql> select 1 /* this is an in-line comment */ + 1;
  24221.      mysql> select 1+
  24222.      /*
  24223.      this is a
  24224.      multiple-line comment
  24225.      */
  24226.      1;
  24227.  
  24228. Note that the `--' comment style requires you to have at least one space
  24229. after the `--'!
  24230.  
  24231. Although the server understands the comment syntax just described,
  24232. there are some limitations on the way that the `mysql' client parses
  24233. `/* ... */' comments:
  24234.  
  24235.    * Single-quote and double-quote characters are taken to indicate the
  24236.      beginning of a quoted string, even within a comment.  If the quote
  24237.      is not matched by a second quote within the comment, the parser
  24238.      doesn't realize the comment has ended.  If you are running `mysql'
  24239.      interactively, you can tell that it has gotten confused like this
  24240.      because the prompt changes from `mysql>' to `'>' or `">'.
  24241.  
  24242.    * A semicolon is taken to indicate the end of the current SQL
  24243.      statement and anything following it to indicate the beginning of
  24244.      the next statement.
  24245.  
  24246. These limitations apply both when you run `mysql' interactively and
  24247. when you put commands in a file and tell `mysql' to read its input from
  24248. that file with `mysql < some-file'.
  24249.  
  24250. MySQL doesn't support the `--' ANSI SQL comment style.  *Note Missing
  24251. comments::.
  24252.  
  24253. 
  24254. File: mysql.info,  Node: Reserved words,  Prev: Comments,  Up: Language Structure
  24255.  
  24256. Is MySQL Picky About Reserved Words?
  24257. ------------------------------------
  24258.  
  24259. A common problem stems from trying to create a table with column names
  24260. that use the names of datatypes or functions built into MySQL, such as
  24261. `TIMESTAMP' or `GROUP'.  You're allowed to do it (for example, `ABS' is
  24262. an allowed column name), but whitespace is not allowed between a
  24263. function name and the `(' when using functions whose names are also
  24264. column names.
  24265.  
  24266. The following words are explicitly reserved in MySQL. Most of them are
  24267. forbidden by ANSI SQL92 as column and/or table names (for example,
  24268. `group').  A few are reserved because MySQL needs them and is
  24269. (currently) using a `yacc' parser:
  24270.  
  24271. `action'           `add'              `aggregate'        `all'
  24272. `alter'            `after'            `and'              `as'
  24273. `asc'              `avg'              `avg_row_length'   `auto_increment'
  24274. `between'          `bigint'           `bit'              `binary'
  24275. `blob'             `bool'             `both'             `by'
  24276. `cascade'          `case'             `char'             `character'
  24277. `change'           `check'            `checksum'         `column'
  24278. `columns'          `comment'          `constraint'       `create'
  24279. `cross'            `current_date'     `current_time'     `current_timestamp'
  24280. `data'             `database'         `databases'        `date'
  24281. `datetime'         `day'              `day_hour'         `day_minute'
  24282. `day_second'       `dayofmonth'       `dayofweek'        `dayofyear'
  24283. `dec'              `decimal'          `default'          `delayed'
  24284. `delay_key_write'  `delete'           `desc'             `describe'
  24285. `distinct'         `distinctrow'      `double'           `drop'
  24286. `end'              `else'             `escape'           `escaped'
  24287. `enclosed'         `enum'             `explain'          `exists'
  24288. `fields'           `file'             `first'            `float'
  24289. `float4'           `float8'           `flush'            `foreign'
  24290. `from'             `for'              `full'             `function'
  24291. `global'           `grant'            `grants'           `group'
  24292. `having'           `heap'             `high_priority'    `hour'
  24293. `hour_minute'      `hour_second'      `hosts'            `identified'
  24294. `ignore'           `in'               `index'            `infile'
  24295. `inner'            `insert'           `insert_id'        `int'
  24296. `integer'          `interval'         `int1'             `int2'
  24297. `int3'             `int4'             `int8'             `into'
  24298. `if'               `is'               `isam'             `join'
  24299. `key'              `keys'             `kill'             `last_insert_id'
  24300. `leading'          `left'             `length'           `like'
  24301. `lines'            `limit'            `load'             `local'
  24302. `lock'             `logs'             `long'             `longblob'
  24303. `longtext'         `low_priority'     `max'              `max_rows'
  24304. `match'            `mediumblob'       `mediumtext'       `mediumint'
  24305. `middleint'        `min_rows'         `minute'           `minute_second'
  24306. `modify'           `month'            `monthname'        `myisam'
  24307. `natural'          `numeric'          `no'               `not'
  24308. `null'             `on'               `optimize'         `option'
  24309. `optionally'       `or'               `order'            `outer'
  24310. `outfile'          `pack_keys'        `partial'          `password'
  24311. `precision'        `primary'          `procedure'        `process'
  24312. `processlist'      `privileges'       `read'             `real'
  24313. `references'       `reload'           `regexp'           `rename'
  24314. `replace'          `restrict'         `returns'          `revoke'
  24315. `rlike'            `row'              `rows'             `second'
  24316. `select'           `set'              `show'             `shutdown'
  24317. `smallint'         `soname'           `sql_big_tables'   `sql_big_selects'
  24318. `sql_low_priority_updates'`sql_log_off'      `sql_log_update'   `sql_select_limit'
  24319. `sql_small_result' `sql_big_result'   `sql_warnings'     `straight_join'
  24320. `starting'         `status'           `string'           `table'
  24321. `tables'           `temporary'        `terminated'       `text'
  24322. `then'             `time'             `timestamp'        `tinyblob'
  24323. `tinytext'         `tinyint'          `trailing'         `to'
  24324. `type'             `use'              `using'            `unique'
  24325. `unlock'           `unsigned'         `update'           `usage'
  24326. `values'           `varchar'          `variables'        `varying'
  24327. `varbinary'        `with'             `write'            `when'
  24328. `where'            `year'             `year_month'       `zerofill'
  24329.  
  24330. The following symbols (from the table above) are disallowed by ANSI SQL
  24331. but allowed by MySQL as column/table names. This is because some of
  24332. these names are very natural names and a lot of people have already
  24333. used them.
  24334.  
  24335.    * `ACTION'
  24336.  
  24337.    * `BIT'
  24338.  
  24339.    * `DATE'
  24340.  
  24341.    * `ENUM'
  24342.  
  24343.    * `NO'
  24344.  
  24345.    * `TEXT'
  24346.  
  24347.    * `TIME'
  24348.  
  24349.    * `TIMESTAMP'
  24350.  
  24351. 
  24352. File: mysql.info,  Node: Column types,  Next: Functions,  Prev: Language Structure,  Up: Reference
  24353.  
  24354. Column Types
  24355. ============
  24356.  
  24357. MySQL supports a number of column types, which may be grouped into
  24358. three categories: numeric types, date and time types, and string
  24359. (character) types.  This section first gives an overview of the types
  24360. available and summarizes the storage requirements for each column type,
  24361. then provides a more detailed description of the properties of the
  24362. types in each category.  The overview is intentionally brief.  The more
  24363. detailed descriptions should be consulted for additional information
  24364. about particular column types, such as the allowable formats in which
  24365. you can specify values.
  24366.  
  24367. The column types supported by MySQL are listed below.  The following
  24368. code letters are used in the descriptions:
  24369.  
  24370. `M'
  24371.      Indicates the maximum display size.  The maximum legal display
  24372.      size is 255.
  24373.  
  24374. `D'
  24375.      Applies to floating-point types and indicates the number of digits
  24376.      following the decimal point.  The maximum possible value is 30, but
  24377.      should be no greater than `M'-2.
  24378.  
  24379. Square brackets (`[' and `]') indicate parts of type specifiers that
  24380. are optional.
  24381.  
  24382. Note that if you specify `ZEROFILL' for a column, MySQL will
  24383. automatically add the `UNSIGNED' attribute to the column.
  24384.  
  24385. `TINYINT[(M)] [UNSIGNED] [ZEROFILL]'
  24386.      A very small integer. The signed range is `-128' to `127'. The
  24387.      unsigned range is `0' to `255'.
  24388.  
  24389. `SMALLINT[(M)] [UNSIGNED] [ZEROFILL]'
  24390.      A small integer. The signed range is `-32768' to `32767'. The
  24391.      unsigned range is `0' to `65535'.
  24392.  
  24393. `MEDIUMINT[(M)] [UNSIGNED] [ZEROFILL]'
  24394.      A medium-size integer. The signed range is `-8388608' to
  24395.      `8388607'. The unsigned range is `0' to `16777215'.
  24396.  
  24397. `INT[(M)] [UNSIGNED] [ZEROFILL]'
  24398.      A normal-size integer. The signed range is `-2147483648' to
  24399.      `2147483647'.  The unsigned range is `0' to `4294967295'.
  24400.  
  24401. `INTEGER[(M)] [UNSIGNED] [ZEROFILL]'
  24402.      This is a synonym for `INT'.
  24403.  
  24404. `BIGINT[(M)] [UNSIGNED] [ZEROFILL]'
  24405.      A large integer. The signed range is `-9223372036854775808' to
  24406.      `9223372036854775807'. The unsigned range is `0' to
  24407.      `18446744073709551615'.
  24408.  
  24409.      Some things you should be aware about `BIGINT' columns:
  24410.  
  24411.         * As all arithmetic is done using signed `BIGINT' or `DOUBLE'
  24412.           values, so you shouldn't use unsigned big integers larger than
  24413.           `9223372036854775807' (63 bits) except with bit functions! If
  24414.           you do that, some of the last digits in the result may be
  24415.           wrong because of rounding errors when converting the `BIGINT'
  24416.           to a `DOUBLE'.
  24417.  
  24418.         * You can always store an exact integer value in a `BIGINT'
  24419.           column by storing it as a string, as there is in this case
  24420.           there will be no intermediate double representation.
  24421.  
  24422.         * `-', `+', and `*' will use `BIGINT' arithmetic when both
  24423.           arguments are `INTEGER' values!  This means that if you
  24424.           multiply two big integers (or results from functions that
  24425.           return integers) you may get unexpected results when the
  24426.           result is larger than `9223372036854775807'.
  24427.  
  24428. `FLOAT(precision) [ZEROFILL]'
  24429.      A floating-point number. Cannot be unsigned.  `precision' can be
  24430.      `<=24' for a single-precision floating-point number and between 25
  24431.      and 53 for a double-precision floating-point number. These types
  24432.      are like the `FLOAT' and `DOUBLE' types described immediately
  24433.      below.  `FLOAT(X)' has the same range as the corresponding `FLOAT'
  24434.      and `DOUBLE' types, but the display size and number of decimals is
  24435.      undefined.
  24436.  
  24437.      In MySQL Version 3.23, this is a true floating-point value.  In
  24438.      earlier MySQL versions, `FLOAT(precision)' always has 2 decimals.
  24439.  
  24440.      Note that using `FLOAT' may give you some unexpected problems as
  24441.      all calculation in MySQL is done with double precision.  *Note No
  24442.      matching rows::.
  24443.  
  24444.      This syntax is provided for ODBC compatibility.
  24445.  
  24446. `FLOAT[(M,D)] [ZEROFILL]'
  24447.      A small (single-precision) floating-point number. Cannot be
  24448.      unsigned.  Allowable values are `-3.402823466E+38' to
  24449.      `-1.175494351E-38', `0', and `1.175494351E-38' to
  24450.      `3.402823466E+38'.  The M is the display width and D is the number
  24451.      of decimals.  `FLOAT' without an argument or with an argument of
  24452.      <= 24 stands for a single-precision floating-point number.
  24453.  
  24454. `DOUBLE[(M,D)] [ZEROFILL]'
  24455.      A normal-size (double-precision) floating-point number. Cannot be
  24456.      unsigned. Allowable values are `-1.7976931348623157E+308' to
  24457.      `-2.2250738585072014E-308', `0', and `2.2250738585072014E-308' to
  24458.      `1.7976931348623157E+308'.  The M is the display width and D is
  24459.      the number of decimals.  `DOUBLE' without an argument or
  24460.      `FLOAT(X)' where 25 <= X <= 53 stands for a double-precision
  24461.      floating-point number.
  24462.  
  24463. `DOUBLE PRECISION[(M,D)] [ZEROFILL]'
  24464. `REAL[(M,D)] [ZEROFILL]'
  24465.      These are synonyms for `DOUBLE'.
  24466.  
  24467. `DECIMAL[(M[,D])] [ZEROFILL]'
  24468.      An unpacked floating-point number.  Cannot be unsigned.  Behaves
  24469.      like a `CHAR' column: "unpacked" means the number is stored as a
  24470.      string, using one character for each digit of the value.  The
  24471.      decimal point and, for negative numbers, the `-' sign, are not
  24472.      counted in M (but space for these are reserved). If `D' is 0,
  24473.      values will have no decimal point or fractional part.  The maximum
  24474.      range of `DECIMAL' values is the same as for `DOUBLE', but the
  24475.      actual range for a given `DECIMAL' column may be constrained by
  24476.      the choice of `M' and `D'.
  24477.  
  24478.      If `D' is left out it's set to 0. If `M' is left out it's set to
  24479.      10.
  24480.  
  24481.      Note that in MySQL Version 3.22 the `M' argument had to includes
  24482.      the space needed for the sign and the decimal point.
  24483.  
  24484. `NUMERIC(M,D) [ZEROFILL]'
  24485.      This is a synonym for `DECIMAL'.
  24486.  
  24487. `DATE'
  24488.      A date.  The supported range is `'1000-01-01'' to `'9999-12-31''.
  24489.      MySQL displays `DATE' values in `'YYYY-MM-DD'' format, but allows
  24490.      you to assign values to `DATE' columns using either strings or
  24491.      numbers. *Note DATETIME::.
  24492.  
  24493. `DATETIME'
  24494.      A date and time combination.  The supported range is `'1000-01-01
  24495.      00:00:00'' to `'9999-12-31 23:59:59''.  MySQL displays `DATETIME'
  24496.      values in `'YYYY-MM-DD HH:MM:SS'' format, but allows you to assign
  24497.      values to `DATETIME' columns using either strings or numbers.
  24498.      *Note DATETIME::.
  24499.  
  24500. `TIMESTAMP[(M)]'
  24501.      A timestamp.  The range is `'1970-01-01 00:00:00'' to sometime in
  24502.      the year `2037'.  MySQL displays `TIMESTAMP' values in
  24503.      `YYYYMMDDHHMMSS', `YYMMDDHHMMSS', `YYYYMMDD', or `YYMMDD' format,
  24504.      depending on whether `M' is `14' (or missing), `12', `8', or `6',
  24505.      but allows you to assign values to `TIMESTAMP' columns using
  24506.      either strings or numbers.  A `TIMESTAMP' column is useful for
  24507.      recording the date and time of an `INSERT' or `UPDATE' operation
  24508.      because it is automatically set to the date and time of the most
  24509.      recent operation if you don't give it a value yourself.  You can
  24510.      also set it to the current date and time by assigning it a `NULL'
  24511.      value.  *Note Date and time types::.
  24512.  
  24513.      A `TIMESTAMP' is always stored in 4 bytes.  The `M' argument only
  24514.      affects how the `TIMESTAMP' column is displayed.
  24515.  
  24516.      Note that `TIMESTAMP(X)' columns where X is 8 or 14 are reported to
  24517.      be numbers while other `TIMESTAMP(X)' columns are reported to be
  24518.      strings.  This is just to ensure that one can reliably dump and
  24519.      restore the table with these types!  *Note DATETIME::.
  24520.  
  24521. `TIME'
  24522.      A time.  The range is `'-838:59:59'' to `'838:59:59''.  MySQL
  24523.      displays `TIME' values in `'HH:MM:SS'' format, but allows you to
  24524.      assign values to `TIME' columns using either strings or numbers.
  24525.      *Note TIME::.
  24526.  
  24527. `YEAR[(2|4)]'
  24528.      A year in 2- or 4-digit format (default is 4-digit).  The
  24529.      allowable values are `1901' to `2155', `0000' in the 4-digit year
  24530.      format, and 1970-2069 if you use the 2-digit format (70-69).
  24531.      MySQL displays `YEAR' values in `YYYY' format, but allows you to
  24532.      assign values to `YEAR' columns using either strings or numbers.
  24533.      (The `YEAR' type is new in MySQL Version 3.22.). *Note YEAR::.
  24534.  
  24535. `[NATIONAL] CHAR(M) [BINARY]'
  24536.      A fixed-length string that is always right-padded with spaces to
  24537.      the specified length when stored. The range of `M' is 1 to 255
  24538.      characters.  Trailing spaces are removed when the value is
  24539.      retrieved. `CHAR' values are sorted and compared in
  24540.      case-insensitive fashion according to the default character set
  24541.      unless the `BINARY' keyword is given.
  24542.  
  24543.      `NATIONAL CHAR' (short form `NCHAR') is the ANSI SQL way to define
  24544.      that a CHAR column should use the default CHARACTER set.  This is
  24545.      the default in MySQL.
  24546.  
  24547.      `CHAR' is a shorthand for `CHARACTER'.
  24548.  
  24549.      MySQL allows you to create a column of type `CHAR(0)'. This is
  24550.      mainly useful when you have to be compliant with some old
  24551.      applications that depend on the existence of a column but that do
  24552.      not actually use the value.  This is also quite nice when you need
  24553.      a column that only can take 2 values: A `CHAR(0)', that is not
  24554.      defined as `NOT NULL', will only occupy one bit and can only take
  24555.      2 values: `NULL' or `""'. *Note CHAR::.
  24556.  
  24557. `BIT'
  24558. `BOOL'
  24559. `CHAR'
  24560.      These three are synonyms for `CHAR(1)'.
  24561.  
  24562. `[NATIONAL] VARCHAR(M) [BINARY]'
  24563.      A variable-length string.  *NOTE:* Trailing spaces are removed when
  24564.      the value is stored (this differs from the ANSI SQL
  24565.      specification). The range of `M' is 1 to 255 characters. `VARCHAR'
  24566.      values are sorted and compared in case-insensitive fashion unless
  24567.      the `BINARY' keyword is given. *Note Silent column changes::.
  24568.  
  24569.      `VARCHAR' is a shorthand for `CHARACTER VARYING'.  *Note CHAR::.
  24570.  
  24571. `TINYBLOB'
  24572. `TINYTEXT'
  24573.      A `BLOB' or `TEXT' column with a maximum length of 255 (2^8 - 1)
  24574.      characters. *Note Silent column changes::. *Note BLOB::.
  24575.  
  24576. `BLOB'
  24577. `TEXT'
  24578.      A `BLOB' or `TEXT' column with a maximum length of 65535 (2^16 - 1)
  24579.      characters. *Note Silent column changes::. *Note BLOB::.
  24580.  
  24581. `MEDIUMBLOB'
  24582. `MEDIUMTEXT'
  24583.      A `BLOB' or `TEXT' column with a maximum length of 16777215 (2^24
  24584.      - 1) characters. *Note Silent column changes::. *Note BLOB::.
  24585.  
  24586. `LONGBLOB'
  24587. `LONGTEXT'
  24588.      A `BLOB' or `TEXT' column with a maximum length of 4294967295
  24589.      (2^32 - 1) characters. *Note Silent column changes::.  Note that
  24590.      because the server/client protocol and MyISAM tables has currently
  24591.      a limit of 16M per communication packet / table row, you can't yet
  24592.      use this the whole range of this type. *Note BLOB::.
  24593.  
  24594. `ENUM('value1','value2',...)'
  24595.      An enumeration.  A string object that can have only one value,
  24596.      chosen from the list of values `'value1'', `'value2'', `...',
  24597.      `NULL' or the special `""' error value.  An `ENUM' can have a
  24598.      maximum of 65535 distinct values. *Note ENUM::.
  24599.  
  24600. `SET('value1','value2',...)'
  24601.      A set.  A string object that can have zero or more values, each of
  24602.      which must be chosen from the list of values `'value1'',
  24603.      `'value2'', `...' A `SET' can have a maximum of 64 members. *Note
  24604.      SET::.
  24605.  
  24606. * Menu:
  24607.  
  24608. * Numeric types::               Numeric types
  24609. * Date and time types::         Date and time types
  24610. * String types::                String types
  24611. * Choosing types::              Choosing the right type for a column
  24612. * Other-vendor column types::   Using column types from other database engines
  24613. * Storage requirements::        Column type storage requirements
  24614.  
  24615. 
  24616. File: mysql.info,  Node: Numeric types,  Next: Date and time types,  Prev: Column types,  Up: Column types
  24617.  
  24618. Numeric Types
  24619. -------------
  24620.  
  24621. MySQL supports all of the ANSI/ISO SQL92 numeric types.  These types
  24622. include the exact numeric data types (`NUMERIC', `DECIMAL', `INTEGER',
  24623. and `SMALLINT'), as well as the approximate numeric data types
  24624. (`FLOAT', `REAL', and `DOUBLE PRECISION'). The keyword `INT' is a
  24625. synonym for `INTEGER', and the keyword `DEC' is a synonym for `DECIMAL'.
  24626.  
  24627. The `NUMERIC' and `DECIMAL' types are implemented as the same type by
  24628. MySQL, as permitted by the SQL92 standard.  They are used for values
  24629. for which it is important to preserve exact precision, for example with
  24630. monetary data.  When declaring a column of one of these types the
  24631. precision and scale can be (and usually is) specified; for example:
  24632.  
  24633.          salary DECIMAL(9,2)
  24634.  
  24635. In this example, `9' (`precision') represents the number of significant
  24636. decimal digits that will be stored for values, and `2' (`scale')
  24637. represents the number of digits that will be stored following the
  24638. decimal point.  In this case, therefore, the range of values that can
  24639. be stored in the `salary' column is from `-9999999.99' to `9999999.99'.
  24640. (MySQL can actually store numbers up to `9999999.99' in this column
  24641. because it doesn't have to store the sign for positive numbers)
  24642.  
  24643. In ANSI/ISO SQL92, the syntax `DECIMAL(p)' is equivalent to
  24644. `DECIMAL(p,0)'.  Similarly, the syntax `DECIMAL' is equivalent to
  24645. `DECIMAL(p,0)', where the implementation is allowed to decide the value
  24646. of `p'.  MySQL does not currently support either of these variant forms
  24647. of the `DECIMAL'/`NUMERIC' data types.  This is not generally a serious
  24648. problem, as the principal benefits of these types derive from the
  24649. ability to control both precision and scale explicitly.
  24650.  
  24651. `DECIMAL' and `NUMERIC' values are stored as strings, rather than as
  24652. binary floating-point numbers, in order to preserve the decimal
  24653. precision of those values.  One character is used for each digit of the
  24654. value, the decimal point (if `scale' > 0), and the `-' sign (for
  24655. negative numbers).  If `scale' is 0, `DECIMAL' and `NUMERIC' values
  24656. contain no decimal point or fractional part.
  24657.  
  24658. The maximum range of `DECIMAL' and `NUMERIC' values is the same as for
  24659. `DOUBLE', but the actual range for a given `DECIMAL' or `NUMERIC'
  24660. column can be constrained by the `precision' or `scale' for a given
  24661. column.  When such a column is assigned a value with more digits
  24662. following the decimal point than are allowed by the specified `scale',
  24663. the value is rounded to that `scale'.  When a `DECIMAL' or `NUMERIC'
  24664. column is assigned a value whose magnitude exceeds the range implied by
  24665. the specified (or defaulted) `precision' and `scale', MySQL stores the
  24666. value representing the corresponding end point of that range.
  24667.  
  24668. As an extension to the ANSI/ISO SQL92 standard, MySQL also supports the
  24669. integral types `TINYINT', `MEDIUMINT', and `BIGINT' as listed in the
  24670. tables above.  Another extension is supported by MySQL for optionally
  24671. specifying the display width of an integral value in parentheses
  24672. following the base keyword for the type (for example, `INT(4)').  This
  24673. optional width specification is used to left-pad the display of values
  24674. whose width is less than the width specified for the column, but does
  24675. not constrain the range of values that can be stored in the column, nor
  24676. the number of digits that will be displayed for values whose width
  24677. exceeds that specified for the column.  When used in conjunction with
  24678. the optional extension attribute `ZEROFILL', the default padding of
  24679. spaces is replaced with zeroes.  For example, for a column declared as
  24680. `INT(5) ZEROFILL', a value of `4' is retrieved as `00004'.  Note that
  24681. if you store larger values than the display width in an integer column,
  24682. you may experience problems when MySQL generates temporary tables for
  24683. some complicated joins, as in these cases MySQL trusts that the data
  24684. did fit into the original column width.
  24685.  
  24686. All integral types can have an optional (non-standard) attribute
  24687. `UNSIGNED'.  Unsigned values can be used when you want to allow only
  24688. positive numbers in a column and you need a little bigger numeric range
  24689. for the column.
  24690.  
  24691. The `FLOAT' type is used to represent approximate numeric data types.
  24692. The ANSI/ISO SQL92 standard allows an optional specification of the
  24693. precision (but not the range of the exponent) in bits following the
  24694. keyword `FLOAT' in parentheses.  The MySQL implementation also supports
  24695. this optional precision specification.  When the keyword `FLOAT' is
  24696. used for a column type without a precision specification, MySQL uses
  24697. four bytes to store the values.  A variant syntax is also supported,
  24698. with two numbers given in parentheses following the `FLOAT' keyword.
  24699. With this option, the first number continues to represent the storage
  24700. requirements for the value in bytes, and the second number specifies
  24701. the number of digits to be stored and displayed following the decimal
  24702. point (as with `DECIMAL' and `NUMERIC').  When MySQL is asked to store
  24703. a number for such a column with more decimal digits following the
  24704. decimal point than specified for the column, the value is rounded to
  24705. eliminate the extra digits when the value is stored.
  24706.  
  24707. The `REAL' and `DOUBLE PRECISION' types do not accept precision
  24708. specifications.  As an extension to the ANSI/ISO SQL92 standard, MySQL
  24709. recognizes `DOUBLE' as a synonym for the `DOUBLE PRECISION' type.  In
  24710. contrast with the standard's requirement that the precision for `REAL'
  24711. be smaller than that used for `DOUBLE PRECISION', MySQL implements both
  24712. as 8-byte double-precision floating-point values (when not running in
  24713. "ANSI mode").  For maximum portability, code requiring storage of
  24714. approximate numeric data values should use `FLOAT' or `DOUBLE
  24715. PRECISION' with no specification of precision or number of decimal
  24716. points.
  24717.  
  24718. When asked to store a value in a numeric column that is outside the
  24719. column type's allowable range, MySQL clips the value to the appropriate
  24720. endpoint of the range and stores the resulting value instead.
  24721.  
  24722. For example, the range of an `INT' column is `-2147483648' to
  24723. `2147483647'.  If you try to insert `-9999999999' into an `INT' column,
  24724. the value is clipped to the lower endpoint of the range, and
  24725. `-2147483648' is stored instead. Similarly, if you try to insert
  24726. `9999999999', `2147483647' is stored instead.
  24727.  
  24728. If the `INT' column is `UNSIGNED', the size of the column's range is
  24729. the same but its endpoints shift up to `0' and `4294967295'.  If you
  24730. try to store `-9999999999' and `9999999999', the values stored in the
  24731. column become `0' and `4294967296'.
  24732.  
  24733. Conversions that occur due to clipping are reported as "warnings" for
  24734. `ALTER TABLE', `LOAD DATA INFILE', `UPDATE', and multi-row `INSERT'
  24735. statements.
  24736.  
  24737. 
  24738. File: mysql.info,  Node: Date and time types,  Next: String types,  Prev: Numeric types,  Up: Column types
  24739.  
  24740. Date and Time Types
  24741. -------------------
  24742.  
  24743. * Menu:
  24744.  
  24745. * Y2K issues::                  Y2K issues and date types
  24746. * DATETIME::                    The `DATETIME', `DATE' and `TIMESTAMP' types
  24747. * TIME::                        The `TIME' type
  24748. * YEAR::                        The `YEAR' type
  24749.  
  24750. The date and time types are `DATETIME', `DATE', `TIMESTAMP', `TIME',
  24751. and `YEAR'.  Each of these has a range of legal values, as well as a
  24752. "zero" value that is used when you specify a really illegal value.
  24753. Note that MySQL allows you to store certain 'not strictly' legal date
  24754. values, for example `1999-11-31'.  The reason for this is that we think
  24755. it's the responsibility of the application to handle date checking, not
  24756. the SQL servers.  To make the date checking 'fast', MySQL only checks
  24757. that the month is in the range of 0-12 and the day is in the range of
  24758. 0-31. The above ranges are defined this way because MySQL allows you to
  24759. store, in a `DATE' or `DATETIME' column, dates where the day or
  24760. month-day is zero.  This is extremely useful for applications that need
  24761. to store a birth-date for which you don't know the exact date. In this
  24762. case you simply store the date like `1999-00-00' or `1999-01-00'.  (You
  24763. cannot expect to get a correct value from functions like `DATE_SUB()'
  24764. or `DATE_ADD' for dates like these.)
  24765.  
  24766. Here are some general considerations to keep in mind when working with
  24767. date and time types:
  24768.  
  24769.    * MySQL retrieves values for a given date or time type in a standard
  24770.      format, but it attempts to interpret a variety of formats for
  24771.      values that you supply (for example, when you specify a value to
  24772.      be assigned to or compared to a date or time type).  Nevertheless,
  24773.      only the formats described in the following sections are
  24774.      supported.  It is expected that you will supply legal values, and
  24775.      unpredictable results may occur if you use values in other formats.
  24776.  
  24777.    * Although MySQL tries to interpret values in several formats, it
  24778.      always expects the year part of date values to be leftmost.  Dates
  24779.      must be given in year-month-day order (for example, `'98-09-04''),
  24780.      rather than in the month-day-year or day-month-year orders
  24781.      commonly used elsewhere (for example, `'09-04-98'', `'04-09-98'').
  24782.  
  24783.    * MySQL automatically converts a date or time type value to a number
  24784.      if the value is used in a numeric context, and vice versa.
  24785.  
  24786.    * When MySQL encounters a value for a date or time type that is out
  24787.      of range or otherwise illegal for the type (see the start of this
  24788.      section), it converts the value to the "zero" value for that type.
  24789.      (The exception is that out-of-range `TIME' values are clipped to
  24790.      the appropriate endpoint of the `TIME' range.)  The table below
  24791.      shows the format of the "zero" value for each type:
  24792.  
  24793.      *Column type*        *"Zero" value*
  24794.      `DATETIME'           `'0000-00-00 00:00:00''
  24795.      `DATE'               `'0000-00-00''
  24796.      `TIMESTAMP'          `00000000000000' (length depends on display
  24797.                           size)
  24798.      `TIME'               `'00:00:00''
  24799.      `YEAR'               `0000'
  24800.  
  24801.    * The "zero" values are special, but you can store or refer to them
  24802.      explicitly using the values shown in the table.  You can also do
  24803.      this using the values `'0'' or `0', which are easier to write.
  24804.  
  24805.    * "Zero" date or time values used through *MyODBC* are converted
  24806.      automatically to `NULL' in *MyODBC* Version 2.50.12 and above,
  24807.      because ODBC can't handle such values.
  24808.  
  24809. 
  24810. File: mysql.info,  Node: Y2K issues,  Next: DATETIME,  Prev: Date and time types,  Up: Date and time types
  24811.  
  24812. Y2K Issues and Date Types
  24813. .........................
  24814.  
  24815. MySQL itself is Y2K-safe (*note Year 2000 compliance::), but input
  24816. values presented to MySQL may not be.  Any input containing 2-digit
  24817. year values is ambiguous, because the century is unknown.  Such values
  24818. must be interpreted into 4-digit form because MySQL stores years
  24819. internally using four digits.
  24820.  
  24821. For `DATETIME', `DATE', `TIMESTAMP', and `YEAR' types, MySQL interprets
  24822. dates with ambiguous year values using the following rules:
  24823.  
  24824.    * Year values in the range `00-69' are converted to `2000-2069'.
  24825.  
  24826.    * Year values in the range `70-99' are converted to `1970-1999'.
  24827.  
  24828. Remember that these rules provide only reasonable guesses as to what
  24829. your data mean.  If the heuristics used by MySQL don't produce the
  24830. correct values, you should provide unambiguous input containing 4-digit
  24831. year values.
  24832.  
  24833. `ORDER BY' will sort 2-digit `YEAR/DATE/DATETIME' types properly.
  24834.  
  24835. Note also that some functions like `MIN()' and `MAX()' will convert a
  24836. `TIMESTAMP/DATE' to a number. This means that a timestamp with a
  24837. 2-digit year will not work properly with these functions.  The fix in
  24838. this case is to convert the `TIMESTAMP/DATE' to 4-digit year format or
  24839. use something like `MIN(DATE_ADD(timestamp,INTERVAL 0 DAYS))'.
  24840.  
  24841. 
  24842. File: mysql.info,  Node: DATETIME,  Next: TIME,  Prev: Y2K issues,  Up: Date and time types
  24843.  
  24844. The `DATETIME', `DATE', and `TIMESTAMP' Types
  24845. .............................................
  24846.  
  24847. The `DATETIME', `DATE', and `TIMESTAMP' types are related.  This
  24848. section describes their characteristics, how they are similar, and how
  24849. they differ.
  24850.  
  24851. The `DATETIME' type is used when you need values that contain both date
  24852. and time information.  MySQL retrieves and displays `DATETIME' values
  24853. in `'YYYY-MM-DD HH:MM:SS'' format.  The supported range is `'1000-01-01
  24854. 00:00:00'' to `'9999-12-31 23:59:59''.  ("Supported" means that
  24855. although earlier values might work, there is no guarantee that they
  24856. will.)
  24857.  
  24858. The `DATE' type is used when you need only a date value, without a time
  24859. part.  MySQL retrieves and displays `DATE' values in `'YYYY-MM-DD''
  24860. format.  The supported range is `'1000-01-01'' to `'9999-12-31''.
  24861.  
  24862. The `TIMESTAMP' column type provides a type that you can use to
  24863. automatically mark `INSERT' or `UPDATE' operations with the current
  24864. date and time.  If you have multiple `TIMESTAMP' columns, only the first
  24865. one is updated automatically.
  24866.  
  24867. Automatic updating of the first `TIMESTAMP' column occurs under any of
  24868. the following conditions:
  24869.  
  24870.    * The column is not specified explicitly in an `INSERT' or `LOAD
  24871.      DATA INFILE' statement.
  24872.  
  24873.    * The column is not specified explicitly in an `UPDATE' statement
  24874.      and some other column changes value.  (Note that an `UPDATE' that
  24875.      sets a column to the value it already has will not cause the
  24876.      `TIMESTAMP' column to be updated, because if you set a column to
  24877.      its current value, MySQL ignores the update for efficiency.)
  24878.  
  24879.    * You explicitly set the `TIMESTAMP' column to `NULL'.
  24880.  
  24881. `TIMESTAMP' columns other than the first may also be set to the current
  24882. date and time.  Just set the column to `NULL' or to `NOW()'.
  24883.  
  24884. You can set any `TIMESTAMP' column to a value different than the current
  24885. date and time by setting it explicitly to the desired value.  This is
  24886. true even for the first `TIMESTAMP' column.  You can use this property
  24887. if, for example, you want a `TIMESTAMP' to be set to the current date
  24888. and time when you create a row, but not to be changed whenever the row
  24889. is updated later:
  24890.  
  24891.    * Let MySQL set the column when the row is created.  This will
  24892.      initialize it to the current date and time.
  24893.  
  24894.    * When you perform subsequent updates to other columns in the row,
  24895.      set the `TIMESTAMP' column explicitly to its current value.
  24896.  
  24897. On the other hand, you may find it just as easy to use a `DATETIME'
  24898. column that you initialize to `NOW()' when the row is created and leave
  24899. alone for subsequent updates.
  24900.  
  24901. `TIMESTAMP' values may range from the beginning of 1970 to sometime in
  24902. the year 2037, with a resolution of one second.  Values are displayed as
  24903. numbers.
  24904.  
  24905. The format in which MySQL retrieves and displays `TIMESTAMP' values
  24906. depends on the display size, as illustrated by the table below.  The
  24907. `full' `TIMESTAMP' format is 14 digits, but `TIMESTAMP' columns may be
  24908. created with shorter display sizes:
  24909.  
  24910. *Column type*          *Display format*
  24911. `TIMESTAMP(14)'        `YYYYMMDDHHMMSS'
  24912. `TIMESTAMP(12)'        `YYMMDDHHMMSS'
  24913. `TIMESTAMP(10)'        `YYMMDDHHMM'
  24914. `TIMESTAMP(8)'         `YYYYMMDD'
  24915. `TIMESTAMP(6)'         `YYMMDD'
  24916. `TIMESTAMP(4)'         `YYMM'
  24917. `TIMESTAMP(2)'         `YY'
  24918.  
  24919. All `TIMESTAMP' columns have the same storage size, regardless of
  24920. display size.  The most common display sizes are 6, 8, 12, and 14.  You
  24921. can specify an arbitrary display size at table creation time, but
  24922. values of 0 or greater than 14 are coerced to 14.  Odd-valued sizes in
  24923. the range from 1 to 13 are coerced to the next higher even number.
  24924.  
  24925. You can specify `DATETIME', `DATE', and `TIMESTAMP' values using any of
  24926. a common set of formats:
  24927.  
  24928.    * As a string in either `'YYYY-MM-DD HH:MM:SS'' or `'YY-MM-DD
  24929.      HH:MM:SS'' format.  A "relaxed" syntax is allowed--any punctuation
  24930.      character may be used as the delimiter between date parts or time
  24931.      parts.  For example, `'98-12-31 11:30:45'', `'98.12.31 11+30+45'',
  24932.      `'98/12/31 11*30*45'', and `'98@12@31 11^30^45'' are equivalent.
  24933.  
  24934.    * As a string in either `'YYYY-MM-DD'' or `'YY-MM-DD'' format.  A
  24935.      "relaxed" syntax is allowed here, too.  For example, `'98-12-31'',
  24936.      `'98.12.31'', `'98/12/31'', and `'98@12@31'' are equivalent.
  24937.  
  24938.    * As a string with no delimiters in either `'YYYYMMDDHHMMSS'' or
  24939.      `'YYMMDDHHMMSS'' format, provided that the string makes sense as a
  24940.      date.  For example, `'19970523091528'' and `'970523091528'' are
  24941.      interpreted as `'1997-05-23 09:15:28'', but `'971122129015'' is
  24942.      illegal (it has a nonsensical minute part) and becomes `'0000-00-00
  24943.      00:00:00''.
  24944.  
  24945.    * As a string with no delimiters in either `'YYYYMMDD'' or `'YYMMDD''
  24946.      format, provided that the string makes sense as a date.  For
  24947.      example, `'19970523'' and `'970523'' are interpreted as
  24948.      `'1997-05-23'', but `'971332'' is illegal (it has nonsensical month
  24949.      and day parts) and becomes `'0000-00-00''.
  24950.  
  24951.    * As a number in either `YYYYMMDDHHMMSS' or `YYMMDDHHMMSS' format,
  24952.      provided that the number makes sense as a date.  For example,
  24953.      `19830905132800' and `830905132800' are interpreted as
  24954.      `'1983-09-05 13:28:00''.
  24955.  
  24956.    * As a number in either `YYYYMMDD' or `YYMMDD' format, provided that
  24957.      the number makes sense as a date.  For example, `19830905' and
  24958.      `830905' are interpreted as `'1983-09-05''.
  24959.  
  24960.    * As the result of a function that returns a value that is acceptable
  24961.      in a `DATETIME', `DATE', or `TIMESTAMP' context, such as `NOW()'
  24962.      or `CURRENT_DATE'.
  24963.  
  24964. Illegal `DATETIME', `DATE', or `TIMESTAMP' values are converted to the
  24965. "zero" value of the appropriate type (`'0000-00-00 00:00:00'',
  24966. `'0000-00-00'', or `00000000000000').
  24967.  
  24968. For values specified as strings that include date part delimiters, it
  24969. is not necessary to specify two digits for month or day values that are
  24970. less than `10'.  `'1979-6-9'' is the same as `'1979-06-09''.  Similarly,
  24971. for values specified as strings that include time part delimiters, it
  24972. is not necessary to specify two digits for hour, month, or second
  24973. values that are less than `10'.  `'1979-10-30 1:2:3'' is the same as
  24974. `'1979-10-30 01:02:03''.
  24975.  
  24976. Values specified as numbers should be 6, 8, 12, or 14 digits long.  If
  24977. the number is 8 or 14 digits long, it is assumed to be in `YYYYMMDD' or
  24978. `YYYYMMDDHHMMSS' format and that the year is given by the first 4
  24979. digits.  If the number is 6 or 12 digits long, it is assumed to be in
  24980. `YYMMDD' or `YYMMDDHHMMSS' format and that the year is given by the
  24981. first 2 digits.  Numbers that are not one of these lengths are
  24982. interpreted as though padded with leading zeros to the closest length.
  24983.  
  24984. Values specified as non-delimited strings are interpreted using their
  24985. length as given.  If the string is 8 or 14 characters long, the year is
  24986. assumed to be given by the first 4 characters.  Otherwise the year is
  24987. assumed to be given by the first 2 characters.  The string is
  24988. interpreted from left to right to find year, month, day, hour, minute,
  24989. and second values, for as many parts as are present in the string.
  24990. This means you should not use strings that have fewer than 6
  24991. characters.  For example, if you specify `'9903'', thinking that will
  24992. represent March, 1999, you will find that MySQL inserts a "zero" date
  24993. into your table.  This is because the year and month values are `99'
  24994. and `03', but the day part is missing (zero), so the value is not a
  24995. legal date.
  24996.  
  24997. `TIMESTAMP' columns store legal values using the full precision with
  24998. which the value was specified, regardless of the display size.  This has
  24999. several implications:
  25000.  
  25001.    * Always specify year, month, and day, even if your column types are
  25002.      `TIMESTAMP(4)' or `TIMESTAMP(2)'.  Otherwise, the value will not
  25003.      be a legal date and `0' will be stored.
  25004.  
  25005.    * If you use `ALTER TABLE' to widen a narrow `TIMESTAMP' column,
  25006.      information will be displayed that previously was "hidden".
  25007.  
  25008.    * Similarly, narrowing a `TIMESTAMP' column does not cause
  25009.      information to be lost, except in the sense that less information
  25010.      is shown when the values are displayed.
  25011.  
  25012.    * Although `TIMESTAMP' values are stored to full precision, the only
  25013.      function that operates directly on the underlying stored value is
  25014.      `UNIX_TIMESTAMP()'.  Other functions operate on the formatted
  25015.      retrieved value.  This means you cannot use functions such as
  25016.      `HOUR()' or `SECOND()' unless the relevant part of the `TIMESTAMP'
  25017.      value is included in the formatted value.  For example, the `HH'
  25018.      part of a `TIMESTAMP' column is not displayed unless the display
  25019.      size is at least 10, so trying to use `HOUR()' on shorter
  25020.      `TIMESTAMP' values produces a meaningless result.
  25021.  
  25022. You can to some extent assign values of one date type to an object of a
  25023. different date type.  However, there may be some alteration of the
  25024. value or loss of information:
  25025.  
  25026.    * If you assign a `DATE' value to a `DATETIME' or `TIMESTAMP'
  25027.      object, the time part of the resulting value is set to
  25028.      `'00:00:00'', because the `DATE' value contains no time
  25029.      information.
  25030.  
  25031.    * If you assign a `DATETIME' or `TIMESTAMP' value to a `DATE'
  25032.      object, the time part of the resulting value is deleted, because
  25033.      the `DATE' type stores no time information.
  25034.  
  25035.    * Remember that although `DATETIME', `DATE', and `TIMESTAMP' values
  25036.      all can be specified using the same set of formats, the types do
  25037.      not all have the same range of values.  For example, `TIMESTAMP'
  25038.      values cannot be earlier than `1970' or later than `2037'.  This
  25039.      means that a date such as `'1968-01-01'', while legal as a
  25040.      `DATETIME' or `DATE' value, is not a valid `TIMESTAMP' value and
  25041.      will be converted to `0' if assigned to such an object.
  25042.  
  25043. Be aware of certain pitfalls when specifying date values:
  25044.  
  25045.    * The relaxed format allowed for values specified as strings can be
  25046.      deceiving.  For example, a value such as `'10:11:12'' might look
  25047.      like a time value because of the `:' delimiter, but if used in a
  25048.      date context will be interpreted as the year `'2010-11-12''.  The
  25049.      value `'10:45:15'' will be converted to `'0000-00-00'' because
  25050.      `'45'' is not a legal month.
  25051.  
  25052.    * Year values specified as two digits are ambiguous, because the
  25053.      century is unknown.  MySQL interprets 2-digit year values using
  25054.      the following rules:
  25055.  
  25056.         - Year values in the range `00-69' are converted to `2000-2069'.
  25057.  
  25058.         - Year values in the range `70-99' are converted to `1970-1999'.
  25059.  
  25060. 
  25061. File: mysql.info,  Node: TIME,  Next: YEAR,  Prev: DATETIME,  Up: Date and time types
  25062.  
  25063. The `TIME' Type
  25064. ...............
  25065.  
  25066. MySQL retrieves and displays `TIME' values in `'HH:MM:SS'' format (or
  25067. `'HHH:MM:SS'' format for large hours values).  `TIME' values may range
  25068. from `'-838:59:59'' to `'838:59:59''.  The reason the hours part may be
  25069. so large is that the `TIME' type may be used not only to represent a
  25070. time of day (which must be less than 24 hours), but also elapsed time
  25071. or a time interval between two events (which may be much greater than
  25072. 24 hours, or even negative).
  25073.  
  25074. You can specify `TIME' values in a variety of formats:
  25075.  
  25076.    * As a string in `'D HH:MM:SS.fraction'' format.  (Note that MySQL
  25077.      doesn't yet store the fraction for the time column).  One can also
  25078.      use one of the following "relaxed" syntax:
  25079.  
  25080.      `HH:MM:SS.fraction', `HH:MM:SS', `HH:MM', `D HH:MM:SS', `D HH:MM',
  25081.      `D HH' or `SS'.  Here `D' is days between 0-33.
  25082.  
  25083.    * As a string with no delimiters in `'HHMMSS'' format, provided that
  25084.      it makes sense as a time.  For example, `'101112'' is understood as
  25085.      `'10:11:12'', but `'109712'' is illegal (it has a nonsensical
  25086.      minute part) and becomes `'00:00:00''.
  25087.  
  25088.    * As a number in `HHMMSS' format, provided that it makes sense as a
  25089.      time.  For example, `101112' is understood as `'10:11:12''.  The
  25090.      following alternative formats are also understood: `SS',
  25091.      `MMSS',`HHMMSS', `HHMMSS.fraction'.  Note that MySQL doesn't yet
  25092.      store the fraction part.
  25093.  
  25094.    * As the result of a function that returns a value that is acceptable
  25095.      in a `TIME' context, such as `CURRENT_TIME'.
  25096.  
  25097. For `TIME' values specified as strings that include a time part
  25098. delimiter, it is not necessary to specify two digits for hours,
  25099. minutes, or seconds values that are less than `10'.  `'8:3:2'' is the
  25100. same as `'08:03:02''.
  25101.  
  25102. Be careful about assigning "short" `TIME' values to a `TIME' column.
  25103. Without semicolon, MySQL interprets values using the assumption that
  25104. the rightmost digits represent seconds. (MySQL interprets `TIME' values
  25105. as elapsed time rather than as time of day.) For example, you might
  25106. think of `'1112'' and `1112' as meaning `'11:12:00'' (12 minutes after
  25107. 11 o'clock), but MySQL interprets them as `'00:11:12'' (11 minutes, 12
  25108. seconds).  Similarly, `'12'' and `12' are interpreted as `'00:00:12''.
  25109. `TIME' values with semicolon, instead, are always treated as time of
  25110. the day. That is `'11:12'' will mean `'11:12:00'', not `'00:11:12''.
  25111.  
  25112. Values that lie outside the `TIME' range but are otherwise legal are
  25113. clipped to the appropriate endpoint of the range.  For example,
  25114. `'-850:00:00'' and `'850:00:00'' are converted to `'-838:59:59'' and
  25115. `'838:59:59''.
  25116.  
  25117. Illegal `TIME' values are converted to `'00:00:00''.  Note that because
  25118. `'00:00:00'' is itself a legal `TIME' value, there is no way to tell,
  25119. from a value of `'00:00:00'' stored in a table, whether the original
  25120. value was specified as `'00:00:00'' or whether it was illegal.
  25121.  
  25122. 
  25123. File: mysql.info,  Node: YEAR,  Prev: TIME,  Up: Date and time types
  25124.  
  25125. The `YEAR' Type
  25126. ...............
  25127.  
  25128. The `YEAR' type is a 1-byte type used for representing years.
  25129.  
  25130. MySQL retrieves and displays `YEAR' values in `YYYY' format.  The range
  25131. is `1901' to `2155'.
  25132.  
  25133. You can specify `YEAR' values in a variety of formats:
  25134.  
  25135.    * As a four-digit string in the range `'1901'' to `'2155''.
  25136.  
  25137.    * As a four-digit number in the range `1901' to `2155'.
  25138.  
  25139.    * As a two-digit string in the range `'00'' to `'99''.  Values in the
  25140.      ranges `'00'' to `'69'' and `'70'' to `'99'' are converted to
  25141.      `YEAR' values in the ranges `2000' to `2069' and `1970' to `1999'.
  25142.  
  25143.    * As a two-digit number in the range `1' to `99'.  Values in the
  25144.      ranges `1' to `69' and `70' to `99' are converted to `YEAR' values
  25145.      in the ranges `2001' to `2069' and `1970' to `1999'.  Note that
  25146.      the range for two-digit numbers is slightly different than the
  25147.      range for two-digit strings, because you cannot specify zero
  25148.      directly as a number and have it be interpreted as `2000'.  You
  25149.      _must_ specify it as a string `'0'' or `'00'' or it will be
  25150.      interpreted as `0000'.
  25151.  
  25152.    * As the result of a function that returns a value that is acceptable
  25153.      in a `YEAR' context, such as `NOW()'.
  25154.  
  25155. Illegal `YEAR' values are converted to `0000'.
  25156.  
  25157. 
  25158. File: mysql.info,  Node: String types,  Next: Choosing types,  Prev: Date and time types,  Up: Column types
  25159.  
  25160. String Types
  25161. ------------
  25162.  
  25163. * Menu:
  25164.  
  25165. * CHAR::                        The `CHAR' and `VARCHAR' types
  25166. * BLOB::                        The `BLOB' and `TEXT' types
  25167. * ENUM::                        The `ENUM' type
  25168. * SET::                         The `SET' type
  25169.  
  25170. The string types are `CHAR', `VARCHAR', `BLOB', `TEXT', `ENUM', and
  25171. `SET'.  This section describes how these types work, their storage
  25172. requirements, and how to use them in your queries.
  25173.  
  25174. 
  25175. File: mysql.info,  Node: CHAR,  Next: BLOB,  Prev: String types,  Up: String types
  25176.  
  25177. The `CHAR' and `VARCHAR' Types
  25178. ..............................
  25179.  
  25180. The `CHAR' and `VARCHAR' types are similar, but differ in the way they
  25181. are stored and retrieved.
  25182.  
  25183. The length of a `CHAR' column is fixed to the length that you declare
  25184. when you create the table.  The length can be any value between 1 and
  25185. 255.  (As of MySQL Version 3.23, the length of `CHAR' may be 0 to 255.)
  25186. When `CHAR' values are stored, they are right-padded with spaces to the
  25187. specified length.  When `CHAR' values are retrieved, trailing spaces are
  25188. removed.
  25189.  
  25190. Values in `VARCHAR' columns are variable-length strings.  You can
  25191. declare a `VARCHAR' column to be any length between 1 and 255, just as
  25192. for `CHAR' columns.  However, in contrast to `CHAR', `VARCHAR' values
  25193. are stored using only as many characters as are needed, plus one byte
  25194. to record the length.  Values are not padded; instead, trailing spaces
  25195. are removed when values are stored.  (This space removal differs from
  25196. the ANSI SQL specification.)
  25197.  
  25198. If you assign a value to a `CHAR' or `VARCHAR' column that exceeds the
  25199. column's maximum length, the value is truncated to fit.
  25200.  
  25201. The table below illustrates the differences between the two types of
  25202. columns by showing the result of storing various string values into
  25203. `CHAR(4)' and `VARCHAR(4)' columns:
  25204.  
  25205. *Value*        `CHAR(4)'   *Storage       `VARCHAR(4)'   *Storage required*
  25206.                            required*                     
  25207. `'''           `'    ''    4 bytes        `'''           1 byte
  25208. `'ab''         `'ab  ''    4 bytes        `'ab''         3 bytes
  25209. `'abcd''       `'abcd''    4 bytes        `'abcd''       5 bytes
  25210. `'abcdefgh''   `'abcd''    4 bytes        `'abcd''       5 bytes
  25211.  
  25212. The values retrieved from the `CHAR(4)' and `VARCHAR(4)' columns will
  25213. be the same in each case, because trailing spaces are removed from
  25214. `CHAR' columns upon retrieval.
  25215.  
  25216. Values in `CHAR' and `VARCHAR' columns are sorted and compared in
  25217. case-insensitive fashion, unless the `BINARY' attribute was specified
  25218. when the table was created.  The `BINARY' attribute means that column
  25219. values are sorted and compared in case-sensitive fashion according to
  25220. the ASCII order of the machine where the MySQL server is running.
  25221. `BINARY' doesn't affect how the column is stored or retrieved.
  25222.  
  25223. The `BINARY' attribute is sticky.  This means that if a column marked
  25224. `BINARY' is used in an expression, the whole expression is compared as a
  25225. `BINARY' value.
  25226.  
  25227. MySQL may silently change the type of a `CHAR' or `VARCHAR' column at
  25228. table creation time.  *Note Silent column changes::.
  25229.  
  25230. 
  25231. File: mysql.info,  Node: BLOB,  Next: ENUM,  Prev: CHAR,  Up: String types
  25232.  
  25233. The `BLOB' and `TEXT' Types
  25234. ...........................
  25235.  
  25236. A `BLOB' is a binary large object that can hold a variable amount of
  25237. data.  The four `BLOB' types `TINYBLOB', `BLOB', `MEDIUMBLOB', and
  25238. `LONGBLOB' differ only in the maximum length of the values they can
  25239. hold.  *Note Storage requirements::.
  25240.  
  25241. The four `TEXT' types `TINYTEXT', `TEXT', `MEDIUMTEXT', and `LONGTEXT'
  25242. correspond to the four `BLOB' types and have the same maximum lengths
  25243. and storage requirements.  The only difference between `BLOB' and
  25244. `TEXT' types is that sorting and comparison is performed in
  25245. case-sensitive fashion for `BLOB' values and case-insensitive fashion
  25246. for `TEXT' values.  In other words, a `TEXT' is a case-insensitive
  25247. `BLOB'.
  25248.  
  25249. If you assign a value to a `BLOB' or `TEXT' column that exceeds the
  25250. column type's maximum length, the value is truncated to fit.
  25251.  
  25252. In most respects, you can regard a `TEXT' column as a `VARCHAR' column
  25253. that can be as big as you like.  Similarly, you can regard a `BLOB'
  25254. column as a `VARCHAR BINARY' column.  The differences are:
  25255.  
  25256.    * You can have indexes on `BLOB' and `TEXT' columns with MySQL
  25257.      Version 3.23.2 and newer. Older versions of MySQL did not support
  25258.      this.
  25259.  
  25260.    * There is no trailing-space removal for `BLOB' and `TEXT' columns
  25261.      when values are stored, as there is for `VARCHAR' columns.
  25262.  
  25263.    * `BLOB' and `TEXT' columns cannot have `DEFAULT' values.
  25264.  
  25265. *MyODBC* defines `BLOB' values as `LONGVARBINARY' and `TEXT' values as
  25266. `LONGVARCHAR'.
  25267.  
  25268. Because `BLOB' and `TEXT' values may be extremely long, you may run up
  25269. against some constraints when using them:
  25270.  
  25271.    * If you want to use `GROUP BY' or `ORDER BY' on a `BLOB' or `TEXT'
  25272.      column, you must convert the column value into a fixed-length
  25273.      object. The standard way to do this is with the `SUBSTRING'
  25274.      function.  For example:
  25275.  
  25276.           mysql> select comment from tbl_name,substring(comment,20) as substr
  25277.                  ORDER BY substr;
  25278.  
  25279.      If you don't do this, only the first `max_sort_length' bytes of the
  25280.      column are used when sorting.  The default value of
  25281.      `max_sort_length' is 1024; this value can be changed using the
  25282.      `-O' option when starting the `mysqld' server. You can group on an
  25283.      expression involving `BLOB' or `TEXT' values by specifying the
  25284.      column position or by using an alias:
  25285.  
  25286.           mysql> select id,substring(blob_col,1,100) from tbl_name
  25287.                      GROUP BY 2;
  25288.           mysql> select id,substring(blob_col,1,100) as b from tbl_name
  25289.                      GROUP BY b;
  25290.  
  25291.    * The maximum size of a `BLOB' or `TEXT' object is determined by its
  25292.      type, but the largest value you can actually transmit between the
  25293.      client and server is determined by the amount of available memory
  25294.      and the size of the communications buffers.  You can change the
  25295.      message buffer size, but you must do so on both the server and
  25296.      client ends. *Note Server parameters::.
  25297.  
  25298. Note that each `BLOB' or `TEXT' value is represented internally by a
  25299. separately allocated object. This is in contrast to all other column
  25300. types, for which storage is allocated once per column when the table is
  25301. opened.
  25302.  
  25303. 
  25304. File: mysql.info,  Node: ENUM,  Next: SET,  Prev: BLOB,  Up: String types
  25305.  
  25306. The `ENUM' Type
  25307. ...............
  25308.  
  25309. An `ENUM' is a string object whose value normally is chosen from a list
  25310. of allowed values that are enumerated explicitly in the column
  25311. specification at table creation time.
  25312.  
  25313. The value may also be the empty string (`""') or `NULL' under certain
  25314. circumstances:
  25315.  
  25316.    * If you insert an invalid value into an `ENUM' (that is, a string
  25317.      not present in the list of allowed values), the empty string is
  25318.      inserted instead as a special error value.
  25319.  
  25320.    * If an `ENUM' is declared `NULL', `NULL' is also a legal value for
  25321.      the column, and the default value is `NULL'.  If an `ENUM' is
  25322.      declared `NOT NULL', the default value is the first element of the
  25323.      list of allowed values.
  25324.  
  25325. Each enumeration value has an index:
  25326.  
  25327.    * Values from the list of allowable elements in the column
  25328.      specification are numbered beginning with 1.
  25329.  
  25330.    * The index value of the empty string error value is 0.  This means
  25331.      that you can use the following `SELECT' statement to find rows
  25332.      into which invalid `ENUM' values were assigned:
  25333.  
  25334.           mysql> SELECT * FROM tbl_name WHERE enum_col=0;
  25335.  
  25336.    * The index of the `NULL' value is `NULL'.
  25337.  
  25338. For example, a column specified as `ENUM("one", "two", "three")' can
  25339. have any of the values shown below.  The index of each value is also
  25340. shown:
  25341.  
  25342. *Value*        *Index*
  25343. `NULL'         `NULL'
  25344. `""'           0
  25345. `"one"'        1
  25346. `"two"'        2
  25347. `"three"'      3
  25348.  
  25349. An enumeration can have a maximum of 65535 elements.
  25350.  
  25351. Lettercase is irrelevant when you assign values to an `ENUM' column.
  25352. However, values retrieved from the column later have lettercase
  25353. matching the values that were used to specify the allowable values at
  25354. table creation time.
  25355.  
  25356. If you retrieve an `ENUM' in a numeric context, the column value's
  25357. index is returned.  For example, you can retrieve numeric values from
  25358. an `ENUM' column like this:
  25359.  
  25360.      mysql> SELECT enum_col+0 FROM tbl_name;
  25361.  
  25362. If you store a number into an `ENUM', the number is treated as an
  25363. index, and the value stored is the enumeration member with that index.
  25364. (However, this will not work with `LOAD DATA', which treats all input
  25365. as strings.)
  25366.  
  25367. `ENUM' values are sorted according to the order in which the enumeration
  25368. members were listed in the column specification.  (In other words,
  25369. `ENUM' values are sorted according to their index numbers.)  For
  25370. example, `"a"' sorts before `"b"' for `ENUM("a", "b")', but `"b"' sorts
  25371. before `"a"' for `ENUM("b", "a")'.  The empty string sorts before
  25372. non-empty strings, and `NULL' values sort before all other enumeration
  25373. values.
  25374.  
  25375. If you want to get all possible values for an `ENUM' column, you should
  25376. use: `SHOW COLUMNS FROM table_name LIKE enum_column_name' and parse the
  25377. `ENUM' definition in the second column.
  25378.  
  25379. 
  25380. File: mysql.info,  Node: SET,  Prev: ENUM,  Up: String types
  25381.  
  25382. The `SET' Type
  25383. ..............
  25384.  
  25385. A `SET' is a string object that can have zero or more values, each of
  25386. which must be chosen from a list of allowed values specified when the
  25387. table is created.  `SET' column values that consist of multiple set
  25388. members are specified with members separated by commas (`,').  A
  25389. consequence of this is that `SET' member values cannot themselves
  25390. contain commas.
  25391.  
  25392. For example, a column specified as `SET("one", "two") NOT NULL' can have
  25393. any of these values:
  25394.  
  25395.      ""
  25396.      "one"
  25397.      "two"
  25398.      "one,two"
  25399.  
  25400. A `SET' can have a maximum of 64 different members.
  25401.  
  25402. MySQL stores `SET' values numerically, with the low-order bit of the
  25403. stored value corresponding to the first set member.  If you retrieve a
  25404. `SET' value in a numeric context, the value retrieved has bits set
  25405. corresponding to the set members that make up the column value.  For
  25406. example, you can retrieve numeric values from a `SET' column like this:
  25407.  
  25408.      mysql> SELECT set_col+0 FROM tbl_name;
  25409.  
  25410. If a number is stored into a `SET' column, the bits that are set in the
  25411. binary representation of the number determine the set members in the
  25412. column value.  Suppose a column is specified as `SET("a","b","c","d")'.
  25413. Then the members have the following bit values:
  25414.  
  25415. `SET'          *Decimal       *Binary value*
  25416. *member*       value*         
  25417. `a'            `1'            `0001'
  25418. `b'            `2'            `0010'
  25419. `c'            `4'            `0100'
  25420. `d'            `8'            `1000'
  25421.  
  25422. If you assign a value of `9' to this column, that is `1001' in binary,
  25423. so the first and fourth `SET' value members `"a"' and `"d"' are
  25424. selected and the resulting value is `"a,d"'.
  25425.  
  25426. For a value containing more than one `SET' element, it does not matter
  25427. what order the elements are listed in when you insert the value.  It
  25428. also does not matter how many times a given element is listed in the
  25429. value.  When the value is retrieved later, each element in the value
  25430. will appear once, with elements listed according to the order in which
  25431. they were specified at table creation time.  For example, if a column
  25432. is specified as `SET("a","b","c","d")', then `"a,d"', `"d,a"', and
  25433. `"d,a,a,d,d"' will all appear as `"a,d"' when retrieved.
  25434.  
  25435. `SET' values are sorted numerically.  `NULL' values sort before
  25436. non-`NULL' `SET' values.
  25437.  
  25438. Normally, you perform a `SELECT' on a `SET' column using the `LIKE'
  25439. operator or the `FIND_IN_SET()' function:
  25440.  
  25441.      mysql> SELECT * FROM tbl_name WHERE set_col LIKE '%value%';
  25442.      mysql> SELECT * FROM tbl_name WHERE FIND_IN_SET('value',set_col)>0;
  25443.  
  25444. But the following will also work:
  25445.  
  25446.      mysql> SELECT * FROM tbl_name WHERE set_col = 'val1,val2';
  25447.      mysql> SELECT * FROM tbl_name WHERE set_col & 1;
  25448.  
  25449. The first of these statements looks for an exact match.  The second
  25450. looks for values containing the first set member.
  25451.  
  25452. If you want to get all possible values for a `SET' column, you should
  25453. use: `SHOW COLUMNS FROM table_name LIKE set_column_name' and parse the
  25454. `SET' definition in the second column.
  25455.  
  25456. 
  25457. File: mysql.info,  Node: Choosing types,  Next: Other-vendor column types,  Prev: String types,  Up: Column types
  25458.  
  25459. Choosing the Right Type for a Column
  25460. ------------------------------------
  25461.  
  25462. For the most efficient use of storage, try to use the most precise type
  25463. in all cases. For example, if an integer column will be used for values
  25464. in the range between `1' and `99999', `MEDIUMINT UNSIGNED' is the best
  25465. type.
  25466.  
  25467. Accurate representation of monetary values is a common problem. In
  25468. MySQL, you should use the `DECIMAL' type. This is stored as a string,
  25469. so no loss of accuracy should occur. If accuracy is not too important,
  25470. the `DOUBLE' type may also be good enough.
  25471.  
  25472. For high precision, you can always convert to a fixed-point type stored
  25473. in a `BIGINT'. This allows you to do all calculations with integers and
  25474. convert results back to floating-point values only when necessary.
  25475.  
  25476. 
  25477. File: mysql.info,  Node: Other-vendor column types,  Next: Storage requirements,  Prev: Choosing types,  Up: Column types
  25478.  
  25479. Using Column Types from Other Database Engines
  25480. ----------------------------------------------
  25481.  
  25482. To make it easier to use code written for SQL implementations from other
  25483. vendors, MySQL maps column types as shown in the table below.  These
  25484. mappings make it easier to move table definitions from other database
  25485. engines to MySQL:
  25486.  
  25487. *Other vendor type*           *MySQL type*
  25488. `BINARY(NUM)'                 `CHAR(NUM) BINARY'
  25489. `CHAR VARYING(NUM)'           `VARCHAR(NUM)'
  25490. `FLOAT4'                      `FLOAT'
  25491. `FLOAT8'                      `DOUBLE'
  25492. `INT1'                        `TINYINT'
  25493. `INT2'                        `SMALLINT'
  25494. `INT3'                        `MEDIUMINT'
  25495. `INT4'                        `INT'
  25496. `INT8'                        `BIGINT'
  25497. `LONG VARBINARY'              `MEDIUMBLOB'
  25498. `LONG VARCHAR'                `MEDIUMTEXT'
  25499. `MIDDLEINT'                   `MEDIUMINT'
  25500. `VARBINARY(NUM)'              `VARCHAR(NUM) BINARY'
  25501.  
  25502. Column type mapping occurs at table creation time.  If you create a
  25503. table with types used by other vendors and then issue a `DESCRIBE
  25504. tbl_name' statement, MySQL reports the table structure using the
  25505. equivalent MySQL types.
  25506.  
  25507. 
  25508. File: mysql.info,  Node: Storage requirements,  Prev: Other-vendor column types,  Up: Column types
  25509.  
  25510. Column Type Storage Requirements
  25511. --------------------------------
  25512.  
  25513. The storage requirements for each of the column types supported by
  25514. MySQL are listed below by category.
  25515.  
  25516. Storage requirements for numeric types
  25517. ......................................
  25518.  
  25519. *Column type*                        *Storage required*
  25520. `TINYINT'                            1 byte
  25521. `SMALLINT'                           2 bytes
  25522. `MEDIUMINT'                          3 bytes
  25523. `INT'                                4 bytes
  25524. `INTEGER'                            4 bytes
  25525. `BIGINT'                             8 bytes
  25526. `FLOAT(X)'                           4 if X <= 24 or 8 if 25 <= X <= 53
  25527. `FLOAT'                              4 bytes
  25528. `DOUBLE'                             8 bytes
  25529. `DOUBLE PRECISION'                   8 bytes
  25530. `REAL'                               8 bytes
  25531. `DECIMAL(M,D)'                       `M+2' bytes if D > 0, `M+1' bytes
  25532.                                      if D = 0 (`D'+2, if `M < D')
  25533. `NUMERIC(M,D)'                       `M+2' bytes if D > 0, `M+1' bytes
  25534.                                      if D = 0 (`D'+2, if `M < D')
  25535.  
  25536. Storage requirements for date and time types
  25537. ............................................
  25538.  
  25539. *Column type*                        *Storage required*
  25540. `DATE'                               3 bytes
  25541. `DATETIME'                           8 bytes
  25542. `TIMESTAMP'                          4 bytes
  25543. `TIME'                               3 bytes
  25544. `YEAR'                               1 byte
  25545.  
  25546. Storage requirements for string types
  25547. .....................................
  25548.  
  25549. *Column type*                        *Storage required*
  25550. `CHAR(M)'                            `M' bytes, `1 <= M <= 255'
  25551. `VARCHAR(M)'                         `L'+1 bytes, where `L <= M' and `1
  25552.                                      <= M <= 255'
  25553. `TINYBLOB', `TINYTEXT'               `L'+1 bytes, where `L' < 2^8
  25554. `BLOB', `TEXT'                       `L'+2 bytes, where `L' < 2^16
  25555. `MEDIUMBLOB', `MEDIUMTEXT'           `L'+3 bytes, where `L' < 2^24
  25556. `LONGBLOB', `LONGTEXT'               `L'+4 bytes, where `L' < 2^32
  25557. `ENUM('value1','value2',...)'        1 or 2 bytes, depending on the
  25558.                                      number of enumeration values (65535
  25559.                                      values maximum)
  25560. `SET('value1','value2',...)'         1, 2, 3, 4 or 8 bytes, depending on
  25561.                                      the number of set members (64
  25562.                                      members maximum)
  25563.  
  25564. `VARCHAR' and the `BLOB' and `TEXT' types are variable-length types,
  25565. for which the storage requirements depend on the actual length of
  25566. column values (represented by `L' in the preceding table), rather than
  25567. on the type's maximum possible size.  For example, a `VARCHAR(10)'
  25568. column can hold a string with a maximum length of 10 characters.  The
  25569. actual storage required is the length of the string (`L'), plus 1 byte
  25570. to record the length of the string.  For the string `'abcd'', `L' is 4
  25571. and the storage requirement is 5 bytes.
  25572.  
  25573. The `BLOB' and `TEXT' types require 1, 2, 3, or 4 bytes to record the
  25574. length of the column value, depending on the maximum possible length of
  25575. the type.  *Note BLOB::.
  25576.  
  25577. If a table includes any variable-length column types, the record format
  25578. will also be variable-length.  Note that when a table is created, MySQL
  25579. may, under certain conditions, change a column from a variable-length
  25580. type to a fixed-length type, or vice-versa.  *Note Silent column
  25581. changes::.
  25582.  
  25583. The size of an `ENUM' object is determined by the number of different
  25584. enumeration values.  One byte is used for enumerations with up to 255
  25585. possible values.  Two bytes are used for enumerations with up to 65535
  25586. values. *Note ENUM::.
  25587.  
  25588. The size of a `SET' object is determined by the number of different set
  25589. members.  If the set size is `N', the object occupies `(N+7)/8' bytes,
  25590. rounded up to 1, 2, 3, 4, or 8 bytes.  A `SET' can have a maximum of 64
  25591. members. *Note SET::.
  25592.  
  25593. 
  25594. File: mysql.info,  Node: Functions,  Next: Data Manipulation,  Prev: Column types,  Up: Reference
  25595.  
  25596. Functions for Use in `SELECT' and `WHERE' Clauses
  25597. =================================================
  25598.  
  25599. A `select_expression' or `where_definition' in a SQL statement can
  25600. consist of any expression using the functions described below.
  25601.  
  25602. An expression that contains `NULL' always produces a `NULL' value
  25603. unless otherwise indicated in the documentation for the operators and
  25604. functions involved in the expression.
  25605.  
  25606. *NOTE:* There must be no whitespace between a function name and the
  25607. parenthesis following it. This helps the MySQL parser distinguish
  25608. between function calls and references to tables or columns that happen
  25609. to have the same name as a function.  Spaces around arguments are
  25610. permitted, though.
  25611.  
  25612. You can force MySQL to accept spaces after the function name by
  25613. starting `mysqld' with `--ansi' or using the `CLIENT_IGNORE_SPACE' to
  25614. `mysql_connect()', but in this case all function names will become
  25615. reserved words. *Note ANSI mode::.
  25616.  
  25617. For the sake of brevity, examples display the output from the `mysql'
  25618. program in abbreviated form.  So this:
  25619.  
  25620.      mysql> select MOD(29,9);
  25621.      1 rows in set (0.00 sec)
  25622.      
  25623.      +-----------+
  25624.      | mod(29,9) |
  25625.      +-----------+
  25626.      |         2 |
  25627.      +-----------+
  25628.  
  25629. is displayed like this:
  25630.  
  25631.      mysql> select MOD(29,9);
  25632.              -> 2
  25633.  
  25634. * Menu:
  25635.  
  25636. * Non-typed Operators::         Non-Type-Specific Operators and Functions
  25637. * String functions::            String functions
  25638. * Numeric Functions::           Numeric Functions
  25639. * Date and time functions::     Date and time functions
  25640. * Other Functions::             Other Functions
  25641.  
  25642. 
  25643. File: mysql.info,  Node: Non-typed Operators,  Next: String functions,  Prev: Functions,  Up: Functions
  25644.  
  25645. Non-Type-Specific Operators and Functions
  25646. -----------------------------------------
  25647.  
  25648. * Menu:
  25649.  
  25650. * Parenthesis::                 Parenthesis
  25651. * Comparison Operators::        Comparison Operators
  25652. * Logical Operators::           Logical Operators
  25653. * Control flow functions::      Control Flow Functions
  25654.  
  25655. 
  25656. File: mysql.info,  Node: Parenthesis,  Next: Comparison Operators,  Prev: Non-typed Operators,  Up: Non-typed Operators
  25657.  
  25658. Parenthesis
  25659. ...........
  25660.  
  25661.      ( ... )
  25662.  
  25663. Use parenthesis to force the order of evaluation in an expression.  For
  25664. example:
  25665.  
  25666.      mysql> select 1+2*3;
  25667.              -> 7
  25668.      mysql> select (1+2)*3;
  25669.              -> 9
  25670.  
  25671. 
  25672. File: mysql.info,  Node: Comparison Operators,  Next: Logical Operators,  Prev: Parenthesis,  Up: Non-typed Operators
  25673.  
  25674. Comparison Operators
  25675. ....................
  25676.  
  25677. Comparison operations result in a value of `1' (TRUE), `0' (FALSE), or
  25678. `NULL'. These functions work for both numbers and strings.  Strings are
  25679. automatically converted to numbers and numbers to strings as needed (as
  25680. in Perl).
  25681.  
  25682. MySQL performs comparisons using the following rules:
  25683.  
  25684.    * If one or both arguments are `NULL', the result of the comparison
  25685.      is `NULL', except for the `<=>' operator.
  25686.  
  25687.    * If both arguments in a comparison operation are strings, they are
  25688.      compared as strings.
  25689.  
  25690.    * If both arguments are integers, they are compared as integers.
  25691.  
  25692.    * Hexadecimal values are treated as binary strings if not compared
  25693.      to a number.
  25694.  
  25695.    * If one of the arguments is a `TIMESTAMP' or `DATETIME' column and
  25696.      the other argument is a constant, the constant is converted to a
  25697.      timestamp before the comparison is performed. This is done to be
  25698.      more ODBC-friendly.
  25699.  
  25700.    * In all other cases, the arguments are compared as floating-point
  25701.      (real) numbers.
  25702.  
  25703. By default, string comparisons are done in case-independent fashion
  25704. using the current character set (ISO-8859-1 Latin1 by default, which
  25705. also works excellently for English).
  25706.  
  25707. The examples below illustrate conversion of strings to numbers for
  25708. comparison operations:
  25709.  
  25710.      mysql> SELECT 1 > '6x';
  25711.               -> 0
  25712.      mysql> SELECT 7 > '6x';
  25713.               -> 1
  25714.      mysql> SELECT 0 > 'x6';
  25715.               -> 0
  25716.      mysql> SELECT 0 = 'x6';
  25717.               -> 1
  25718.  
  25719. `='
  25720.      Equal:
  25721.           mysql> select 1 = 0;
  25722.                   -> 0
  25723.           mysql> select '0' = 0;
  25724.                   -> 1
  25725.           mysql> select '0.0' = 0;
  25726.                   -> 1
  25727.           mysql> select '0.01' = 0;
  25728.                   -> 0
  25729.           mysql> select '.01' = 0.01;
  25730.                   -> 1
  25731.  
  25732. `<>'
  25733. `!='
  25734.      Not equal:
  25735.           mysql> select '.01' <> '0.01';
  25736.                   -> 1
  25737.           mysql> select .01 <> '0.01';
  25738.                   -> 0
  25739.           mysql> select 'zapp' <> 'zappp';
  25740.                   -> 1
  25741.  
  25742. `<='
  25743.      Less than or equal:
  25744.           mysql> select 0.1 <= 2;
  25745.                   -> 1
  25746.  
  25747. `<'
  25748.      Less than:
  25749.           mysql> select 2 < 2;
  25750.                   -> 0
  25751.  
  25752. `>='
  25753.      Greater than or equal:
  25754.           mysql> select 2 >= 2;
  25755.                   -> 1
  25756.  
  25757. `>'
  25758.      Greater than:
  25759.           mysql> select 2 > 2;
  25760.                   -> 0
  25761.  
  25762. `<=>'
  25763.      Null safe equal:
  25764.           mysql> select 1 <=> 1, NULL <=> NULL, 1 <=> NULL;
  25765.                   -> 1 1 0
  25766.  
  25767. `IS NULL'
  25768. `IS NOT NULL'
  25769.      Test whether or not a value is or is not `NULL':
  25770.           mysql> select 1 IS NULL, 0 IS NULL, NULL IS NULL;
  25771.                   -> 0 0 1
  25772.           mysql> select 1 IS NOT NULL, 0 IS NOT NULL, NULL IS NOT NULL;
  25773.                   -> 1 1 0
  25774.  
  25775. `expr BETWEEN min AND max'
  25776.      If `expr' is greater than or equal to `min' and `expr' is less
  25777.      than or equal to `max', `BETWEEN' returns `1', otherwise it
  25778.      returns `0'.  This is equivalent to the expression `(min <= expr
  25779.      AND expr <= max)' if all the arguments are of the same type.  The
  25780.      first argument (`expr') determines how the comparison is performed
  25781.      as follows:
  25782.  
  25783.         * If `expr' is a `TIMESTAMP', `DATE', or `DATETIME' column,
  25784.           `MIN()' and `MAX()' are formatted to the same format if they
  25785.           are constants.
  25786.  
  25787.         * If `expr' is a case-insensitive string expression, a
  25788.           case-insensitive string comparison is done.
  25789.  
  25790.         * If `expr' is a case-sensitive string expression, a
  25791.           case-sensitive string comparison is done.
  25792.  
  25793.         * If `expr' is an integer expression, an integer comparison is
  25794.           done.
  25795.  
  25796.         * Otherwise, a floating-point (real) comparison is done.
  25797.  
  25798.           mysql> select 1 BETWEEN 2 AND 3;
  25799.                   -> 0
  25800.           mysql> select 'b' BETWEEN 'a' AND 'c';
  25801.                   -> 1
  25802.           mysql> select 2 BETWEEN 2 AND '3';
  25803.                   -> 1
  25804.           mysql> select 2 BETWEEN 2 AND 'x-3';
  25805.                   -> 0
  25806.  
  25807. `expr IN (value,...)'
  25808.      Returns `1' if `expr' is any of the values in the `IN' list, else
  25809.      returns `0'.  If all values are constants, then all values are
  25810.      evaluated according to the type of `expr' and sorted. The search
  25811.      for the item is then done using a binary search. This means `IN'
  25812.      is very quick if the `IN' value list consists entirely of
  25813.      constants.  If `expr' is a case-sensitive string expression, the
  25814.      string comparison is performed in case-sensitive fashion:
  25815.  
  25816.           mysql> select 2 IN (0,3,5,'wefwf');
  25817.                   -> 0
  25818.           mysql> select 'wefwf' IN (0,3,5,'wefwf');
  25819.                   -> 1
  25820.  
  25821. `expr NOT IN (value,...)'
  25822.      Same as `NOT (expr IN (value,...))'.
  25823.  
  25824. `ISNULL(expr)'
  25825.      If `expr' is `NULL', `ISNULL()' returns `1', otherwise it returns
  25826.      `0':
  25827.           mysql> select ISNULL(1+1);
  25828.                   -> 0
  25829.           mysql> select ISNULL(1/0);
  25830.                   -> 1
  25831.  
  25832.      Note that a comparison of `NULL' values using `=' will always be
  25833.      false!
  25834.  
  25835. `COALESCE(list)'
  25836.      Returns first non-`NULL' element in list:
  25837.  
  25838.           mysql> select COALESCE(NULL,1);
  25839.                   -> 1
  25840.           mysql> select COALESCE(NULL,NULL,NULL);
  25841.                   -> NULL
  25842.  
  25843. `INTERVAL(N,N1,N2,N3,...)'
  25844.      Returns `0' if `N' < `N1', `1' if `N' < `N2' and so on. All
  25845.      arguments are treated as integers.  It is required that `N1' <
  25846.      `N2' < `N3' < `...' < `Nn' for this function to work correctly.
  25847.      This is because a binary search is used (very fast):
  25848.  
  25849.           mysql> select INTERVAL(23, 1, 15, 17, 30, 44, 200);
  25850.                   -> 3
  25851.           mysql> select INTERVAL(10, 1, 10, 100, 1000);
  25852.                   -> 2
  25853.           mysql> select INTERVAL(22, 23, 30, 44, 200);
  25854.                   -> 0
  25855.  
  25856. If you are comparing case sensitive string with any of the standard
  25857. operators (`=', `<>'..., but not `LIKE') end space will be ignored.
  25858.  
  25859.      mysql> select "a" ="A ";
  25860.              -> 1
  25861.  
  25862. 
  25863. File: mysql.info,  Node: Logical Operators,  Next: Control flow functions,  Prev: Comparison Operators,  Up: Non-typed Operators
  25864.  
  25865. Logical Operators
  25866. .................
  25867.  
  25868. All logical functions return `1' (TRUE), `0' (FALSE) or `NULL'
  25869. (unknown, which is in most cases the same as FALSE):
  25870.  
  25871. `NOT'
  25872. `!'
  25873.      Logical NOT. Returns `1' if the argument is `0', otherwise returns
  25874.      `0'.  Exception: `NOT NULL' returns `NULL':
  25875.           mysql> select NOT 1;
  25876.                   -> 0
  25877.           mysql> select NOT NULL;
  25878.                   -> NULL
  25879.           mysql> select ! (1+1);
  25880.                   -> 0
  25881.           mysql> select ! 1+1;
  25882.                   -> 1
  25883.      The last example returns `1' because the expression evaluates the
  25884.      same way as `(!1)+1'.
  25885.  
  25886. `OR'
  25887. `||'
  25888.      Logical OR. Returns `1' if either argument is not `0' and not
  25889.      `NULL':
  25890.           mysql> select 1 || 0;
  25891.                   -> 1
  25892.           mysql> select 0 || 0;
  25893.                   -> 0
  25894.           mysql> select 1 || NULL;
  25895.                   -> 1
  25896.  
  25897. `AND'
  25898. `&&'
  25899.      Logical AND. Returns `0' if either argument is `0' or `NULL',
  25900.      otherwise returns `1':
  25901.           mysql> select 1 && NULL;
  25902.                   -> 0
  25903.           mysql> select 1 && 0;
  25904.                   -> 0
  25905.  
  25906. 
  25907. File: mysql.info,  Node: Control flow functions,  Prev: Logical Operators,  Up: Non-typed Operators
  25908.  
  25909. Control Flow Functions
  25910. ......................
  25911.  
  25912. `IFNULL(expr1,expr2)'
  25913.      If `expr1' is not `NULL', `IFNULL()' returns `expr1', else it
  25914.      returns `expr2'.  `IFNULL()' returns a numeric or string value,
  25915.      depending on the context in which it is used:
  25916.           mysql> select IFNULL(1,0);
  25917.                   -> 1
  25918.           mysql> select IFNULL(NULL,10);
  25919.                   -> 10
  25920.           mysql> select IFNULL(1/0,10);
  25921.                   -> 10
  25922.           mysql> select IFNULL(1/0,'yes');
  25923.                   -> 'yes'
  25924.  
  25925. `NULLIF(expr1,expr2)'
  25926.      If `expr1 = expr2' is true, return `NULL' else return `expr1'.
  25927.      This is the same as `CASE WHEN x = y THEN NULL ELSE x END':
  25928.           mysql> select NULLIF(1,1);
  25929.                   -> NULL
  25930.           mysql> select NULLIF(1,2);
  25931.                   -> 1
  25932.  
  25933.      Note that `expr1' is evaluated twice in MySQL if the arguments are
  25934.      equal.
  25935.  
  25936. `IF(expr1,expr2,expr3)'
  25937.      If `expr1' is TRUE (`expr1 <> 0' and `expr1 <> NULL') then `IF()'
  25938.      returns `expr2', else it returns `expr3'.  `IF()' returns a
  25939.      numeric or string value, depending on the context in which it is
  25940.      used:
  25941.  
  25942.           mysql> select IF(1>2,2,3);
  25943.                   -> 3
  25944.           mysql> select IF(1<2,'yes','no');
  25945.                   -> 'yes'
  25946.           mysql> select IF(strcmp('test','test1'),'no','yes');
  25947.                   -> 'no'
  25948.  
  25949.      `expr1' is evaluated as an integer value, which means that if you
  25950.      are testing floating-point or string values, you should do so
  25951.      using a comparison operation:
  25952.  
  25953.           mysql> select IF(0.1,1,0);
  25954.                   -> 0
  25955.           mysql> select IF(0.1<>0,1,0);
  25956.                   -> 1
  25957.  
  25958.      In the first case above, `IF(0.1)' returns `0' because `0.1' is
  25959.      converted to an integer value, resulting in a test of `IF(0)'.
  25960.      This may not be what you expect.  In the second case, the
  25961.      comparison tests the original floating-point value to see whether
  25962.      it is non-zero.  The result of the comparison is used as an
  25963.      integer.
  25964.  
  25965.      The default return type of `IF()' (which may matter when it is
  25966.      stored into a temporary table) is calculated in MySQL Version 3.23
  25967.      as follows:
  25968.  
  25969.      *Expression*                          *Return value*
  25970.      expr2 or expr3 returns string         string
  25971.      expr2 or expr3 returns a              floating-point
  25972.      floating-point value                  
  25973.      expr2 or expr3 returns an integer     integer
  25974.  
  25975.      If expr2 and expr3 are strings, then the result is case sensitive
  25976.      if both strings are case sensitive. (Starting from 3.23.51)
  25977.  
  25978. `CASE value WHEN [compare-value] THEN result [WHEN [compare-value] THEN result ...] [ELSE result] END'
  25979.  
  25980. `CASE WHEN [condition] THEN result [WHEN [condition] THEN result ...] [ELSE result] END'
  25981.      The first version returns the `result' where
  25982.      `value=compare-value'. The second version returns the result for
  25983.      the first condition, which is true. If there was no matching result
  25984.      value, then the result after `ELSE' is returned. If there is no
  25985.      `ELSE' part then `NULL' is returned:
  25986.  
  25987.           mysql> SELECT CASE 1 WHEN 1 THEN "one" WHEN 2 THEN "two" ELSE "more" END;
  25988.                  -> "one"
  25989.           mysql> SELECT CASE WHEN 1>0 THEN "true" ELSE "false" END;
  25990.                  -> "true"
  25991.           mysql> SELECT CASE BINARY "B" when "a" then 1 when "b" then 2 END;
  25992.                  -> NULL
  25993.  
  25994. The type of the return value (`INTEGER', `DOUBLE' or `STRING') is the
  25995. same as the type of the first returned value (the expression after the
  25996. first `THEN').
  25997.  
  25998. 
  25999. File: mysql.info,  Node: String functions,  Next: Numeric Functions,  Prev: Non-typed Operators,  Up: Functions
  26000.  
  26001. String Functions
  26002. ----------------
  26003.  
  26004. String-valued functions return `NULL' if the length of the result would
  26005. be greater than the `max_allowed_packet' server parameter.  *Note
  26006. Server parameters::.
  26007.  
  26008. For functions that operate on string positions, the first position is
  26009. numbered 1.
  26010.  
  26011. `ASCII(str)'
  26012.      Returns the ASCII code value of the leftmost character of the
  26013.      string `str'. Returns `0' if `str' is the empty string.  Returns
  26014.      `NULL' if `str' is `NULL':
  26015.  
  26016.           mysql> select ASCII('2');
  26017.                   -> 50
  26018.           mysql> select ASCII(2);
  26019.                   -> 50
  26020.           mysql> select ASCII('dx');
  26021.                   -> 100
  26022.  
  26023.      See also the `ORD()' function.
  26024.  
  26025. `ORD(str)'
  26026.      If the leftmost character of the string str is a multi-byte
  26027.      character, returns the code of multi-byte character by returning
  26028.      the ASCII code value of the character in the format of: `((first
  26029.      byte ASCII code)*256+(second byte ASCII code))[*256+third byte
  26030.      ASCII code...]'.  If the leftmost character is not a multi-byte
  26031.      character, returns the same value as the like `ASCII()' function
  26032.      does:
  26033.  
  26034.           mysql> select ORD('2');
  26035.                   -> 50
  26036.  
  26037. `CONV(N,from_base,to_base)'
  26038.      Converts numbers between different number bases.  Returns a string
  26039.      representation of the number `N', converted from base `from_base'
  26040.      to base `to_base'.  Returns `NULL' if any argument is `NULL'.  The
  26041.      argument `N' is interpreted as an integer, but may be specified as
  26042.      an integer or a string.  The minimum base is `2' and the maximum
  26043.      base is `36'.  If `to_base' is a negative number, `N' is regarded
  26044.      as a signed number.  Otherwise, `N' is treated as unsigned.
  26045.      `CONV' works with 64-bit precision:
  26046.  
  26047.           mysql> select CONV("a",16,2);
  26048.                   -> '1010'
  26049.           mysql> select CONV("6E",18,8);
  26050.                   -> '172'
  26051.           mysql> select CONV(-17,10,-18);
  26052.                   -> '-H'
  26053.           mysql> select CONV(10+"10"+'10'+0xa,10,10);
  26054.                   -> '40'
  26055.  
  26056. `BIN(N)'
  26057.      Returns a string representation of the binary value of `N', where
  26058.      `N' is a longlong (`BIGINT') number.  This is equivalent to
  26059.      `CONV(N,10,2)'.  Returns `NULL' if `N' is `NULL':
  26060.  
  26061.           mysql> select BIN(12);
  26062.                   -> '1100'
  26063.  
  26064. `OCT(N)'
  26065.      Returns a string representation of the octal value of `N', where
  26066.      `N' is a longlong number.  This is equivalent to `CONV(N,10,8)'.
  26067.      Returns `NULL' if `N' is `NULL':
  26068.  
  26069.           mysql> select OCT(12);
  26070.                   -> '14'
  26071.  
  26072. `HEX(N)'
  26073.      Returns a string representation of the hexadecimal value of `N',
  26074.      where `N' is a longlong (`BIGINT') number.  This is equivalent to
  26075.      `CONV(N,10,16)'.  Returns `NULL' if `N' is `NULL':
  26076.  
  26077.           mysql> select HEX(255);
  26078.                   -> 'FF'
  26079.  
  26080. `CHAR(N,...)'
  26081.      `CHAR()' interprets the arguments as integers and returns a string
  26082.      consisting of the characters given by the ASCII code values of
  26083.      those integers. `NULL' values are skipped:
  26084.  
  26085.           mysql> select CHAR(77,121,83,81,'76');
  26086.                   -> 'MySQL'
  26087.           mysql> select CHAR(77,77.3,'77.3');
  26088.                   -> 'MMM'
  26089.  
  26090. `CONCAT(str1,str2,...)'
  26091.      Returns the string that results from concatenating the arguments.
  26092.      Returns `NULL' if any argument is `NULL'.  May have more than 2
  26093.      arguments.  A numeric argument is converted to the equivalent
  26094.      string form:
  26095.  
  26096.           mysql> select CONCAT('My', 'S', 'QL');
  26097.                   -> 'MySQL'
  26098.           mysql> select CONCAT('My', NULL, 'QL');
  26099.                   -> NULL
  26100.           mysql> select CONCAT(14.3);
  26101.                   -> '14.3'
  26102.  
  26103. `CONCAT_WS(separator, str1, str2,...)'
  26104.      `CONCAT_WS()' stands for CONCAT With Separator and is a special
  26105.      form of `CONCAT()'.  The first argument is the separator for the
  26106.      rest of the arguments. The separator can be a string as well as
  26107.      the rest of the arguments. If the separator is `NULL', the result
  26108.      will be `NULL'.  The function will skip any `NULL's and empty
  26109.      strings, after the separator argument. The separator will be added
  26110.      between the strings to be concatenated:
  26111.  
  26112.           mysql> select CONCAT_WS(",","First name","Second name","Last Name");
  26113.                  -> 'First name,Second name,Last Name'
  26114.           mysql> select CONCAT_WS(",","First name",NULL,"Last Name");
  26115.                  -> 'First name,Last Name'
  26116.  
  26117. `LENGTH(str)'
  26118. `OCTET_LENGTH(str)'
  26119. `CHAR_LENGTH(str)'
  26120. `CHARACTER_LENGTH(str)'
  26121.      Returns the length of the string `str':
  26122.  
  26123.           mysql> select LENGTH('text');
  26124.                   -> 4
  26125.           mysql> select OCTET_LENGTH('text');
  26126.                   -> 4
  26127.  
  26128.      Note that for `CHAR_LENGTH()', multi-byte characters are only
  26129.      counted once.
  26130.  
  26131. `LOCATE(substr,str)'
  26132. `POSITION(substr IN str)'
  26133.      Returns the position of the first occurrence of substring `substr'
  26134.      in string `str'. Returns `0' if `substr' is not in `str':
  26135.  
  26136.           mysql> select LOCATE('bar', 'foobarbar');
  26137.                   -> 4
  26138.           mysql> select LOCATE('xbar', 'foobar');
  26139.                   -> 0
  26140.  
  26141.      This function is multi-byte safe.
  26142.  
  26143. `LOCATE(substr,str,pos)'
  26144.      Returns the position of the first occurrence of substring `substr'
  26145.      in string `str', starting at position `pos'.  Returns `0' if
  26146.      `substr' is not in `str':
  26147.  
  26148.           mysql> select LOCATE('bar', 'foobarbar',5);
  26149.                   -> 7
  26150.  
  26151.      This function is multi-byte safe.
  26152.  
  26153. `INSTR(str,substr)'
  26154.      Returns the position of the first occurrence of substring `substr'
  26155.      in string `str'. This is the same as the two-argument form of
  26156.      `LOCATE()', except that the arguments are swapped:
  26157.  
  26158.           mysql> select INSTR('foobarbar', 'bar');
  26159.                   -> 4
  26160.           mysql> select INSTR('xbar', 'foobar');
  26161.                   -> 0
  26162.  
  26163.      This function is multi-byte safe.
  26164.  
  26165. `LPAD(str,len,padstr)'
  26166.      Returns the string `str', left-padded with the string `padstr'
  26167.      until `str' is `len' characters long. If `str' is longer than
  26168.      `len'' then it will be shortened to `len' characters.
  26169.  
  26170.           mysql> select LPAD('hi',4,'??');
  26171.                   -> '??hi'
  26172.  
  26173. `RPAD(str,len,padstr)'
  26174.      Returns the string `str', right-padded with the string `padstr'
  26175.      until `str' is `len' characters long.  If `str' is longer than
  26176.      `len'' then it will be shortened to `len' characters.
  26177.  
  26178.           mysql> select RPAD('hi',5,'?');
  26179.                   -> 'hi???'
  26180.  
  26181. `LEFT(str,len)'
  26182.      Returns the leftmost `len' characters from the string `str':
  26183.  
  26184.           mysql> select LEFT('foobarbar', 5);
  26185.                   -> 'fooba'
  26186.  
  26187.      This function is multi-byte safe.
  26188.  
  26189. `RIGHT(str,len)'
  26190.      Returns the rightmost `len' characters from the string `str':
  26191.  
  26192.           mysql> select RIGHT('foobarbar', 4);
  26193.                   -> 'rbar'
  26194.  
  26195.      This function is multi-byte safe.
  26196.  
  26197. `SUBSTRING(str,pos,len)'
  26198. `SUBSTRING(str FROM pos FOR len)'
  26199. `MID(str,pos,len)'
  26200.      Returns a substring `len' characters long from string `str',
  26201.      starting at position `pos'.  The variant form that uses `FROM' is
  26202.      ANSI SQL92 syntax:
  26203.  
  26204.           mysql> select SUBSTRING('Quadratically',5,6);
  26205.                   -> 'ratica'
  26206.  
  26207.      This function is multi-byte safe.
  26208.  
  26209. `SUBSTRING(str,pos)'
  26210.  
  26211. `SUBSTRING(str FROM pos)'
  26212.      Returns a substring from string `str' starting at position `pos':
  26213.  
  26214.           mysql> select SUBSTRING('Quadratically',5);
  26215.                   -> 'ratically'
  26216.           mysql> select SUBSTRING('foobarbar' FROM 4);
  26217.                   -> 'barbar'
  26218.  
  26219.      This function is multi-byte safe.
  26220.  
  26221. `SUBSTRING_INDEX(str,delim,count)'
  26222.      Returns the substring from string `str' before `count' occurrences
  26223.      of the delimiter `delim'.  If `count' is positive, everything to
  26224.      the left of the final delimiter (counting from the left) is
  26225.      returned.  If `count' is negative, everything to the right of the
  26226.      final delimiter (counting from the right) is returned:
  26227.  
  26228.           mysql> select SUBSTRING_INDEX('www.mysql.com', '.', 2);
  26229.                   -> 'www.mysql'
  26230.           mysql> select SUBSTRING_INDEX('www.mysql.com', '.', -2);
  26231.                   -> 'mysql.com'
  26232.  
  26233.      This function is multi-byte safe.
  26234.  
  26235. `LTRIM(str)'
  26236.      Returns the string `str' with leading space characters removed:
  26237.  
  26238.           mysql> select LTRIM('  barbar');
  26239.                   -> 'barbar'
  26240.  
  26241. `RTRIM(str)'
  26242.      Returns the string `str' with trailing space characters removed:
  26243.  
  26244.           mysql> select RTRIM('barbar   ');
  26245.                   -> 'barbar'
  26246.  
  26247.      This function is multi-byte safe.
  26248.  
  26249. `TRIM([[BOTH | LEADING | TRAILING] [remstr] FROM] str)'
  26250.      Returns the string `str' with all `remstr' prefixes and/or suffixes
  26251.      removed. If none of the specifiers `BOTH', `LEADING' or `TRAILING'
  26252.      are given, `BOTH' is assumed. If `remstr' is not specified, spaces
  26253.      are removed:
  26254.  
  26255.           mysql> select TRIM('  bar   ');
  26256.                   -> 'bar'
  26257.           mysql> select TRIM(LEADING 'x' FROM 'xxxbarxxx');
  26258.                   -> 'barxxx'
  26259.           mysql> select TRIM(BOTH 'x' FROM 'xxxbarxxx');
  26260.                   -> 'bar'
  26261.           mysql> select TRIM(TRAILING 'xyz' FROM 'barxxyz');
  26262.                   -> 'barx'
  26263.  
  26264.      This function is multi-byte safe.
  26265.  
  26266. `SOUNDEX(str)'
  26267.      Returns a soundex string from `str'. Two strings that sound almost
  26268.      the same should have identical soundex strings. A standard soundex
  26269.      string is 4 characters long, but the `SOUNDEX()' function returns
  26270.      an arbitrarily long string. You can use `SUBSTRING()' on the
  26271.      result to get a standard soundex string.  All non-alphanumeric
  26272.      characters are ignored in the given string. All international
  26273.      alpha characters outside the A-Z range are treated as vowels:
  26274.  
  26275.           mysql> select SOUNDEX('Hello');
  26276.                   -> 'H400'
  26277.           mysql> select SOUNDEX('Quadratically');
  26278.                   -> 'Q36324'
  26279.  
  26280. `SPACE(N)'
  26281.      Returns a string consisting of `N' space characters:
  26282.  
  26283.           mysql> select SPACE(6);
  26284.                   -> '      '
  26285.  
  26286. `REPLACE(str,from_str,to_str)'
  26287.      Returns the string `str' with all all occurrences of the string
  26288.      `from_str' replaced by the string `to_str':
  26289.  
  26290.           mysql> select REPLACE('www.mysql.com', 'w', 'Ww');
  26291.                   -> 'WwWwWw.mysql.com'
  26292.  
  26293.      This function is multi-byte safe.
  26294.  
  26295. `REPEAT(str,count)'
  26296.      Returns a string consisting of the string `str' repeated `count'
  26297.      times. If `count <= 0', returns an empty string. Returns `NULL' if
  26298.      `str' or `count' are `NULL':
  26299.  
  26300.           mysql> select REPEAT('MySQL', 3);
  26301.                   -> 'MySQLMySQLMySQL'
  26302.  
  26303. `REVERSE(str)'
  26304.      Returns the string `str' with the order of the characters reversed:
  26305.  
  26306.           mysql> select REVERSE('abc');
  26307.                   -> 'cba'
  26308.  
  26309.      This function is multi-byte safe.
  26310.  
  26311. `INSERT(str,pos,len,newstr)'
  26312.      Returns the string `str', with the substring beginning at position
  26313.      `pos' and `len' characters long replaced by the string `newstr':
  26314.  
  26315.           mysql> select INSERT('Quadratic', 3, 4, 'What');
  26316.                   -> 'QuWhattic'
  26317.  
  26318.      This function is multi-byte safe.
  26319.  
  26320. `ELT(N,str1,str2,str3,...)'
  26321.      Returns `str1' if `N' = `1', `str2' if `N' = `2', and so on.
  26322.      Returns `NULL' if `N' is less than `1' or greater than the number
  26323.      of arguments.  `ELT()' is the complement of `FIELD()':
  26324.  
  26325.           mysql> select ELT(1, 'ej', 'Heja', 'hej', 'foo');
  26326.                   -> 'ej'
  26327.           mysql> select ELT(4, 'ej', 'Heja', 'hej', 'foo');
  26328.                   -> 'foo'
  26329.  
  26330. `FIELD(str,str1,str2,str3,...)'
  26331.      Returns the index of `str' in the `str1', `str2', `str3', `...'
  26332.      list.  Returns `0' if `str' is not found.  `FIELD()' is the
  26333.      complement of `ELT()':
  26334.  
  26335.           mysql> select FIELD('ej', 'Hej', 'ej', 'Heja', 'hej', 'foo');
  26336.                   -> 2
  26337.           mysql> select FIELD('fo', 'Hej', 'ej', 'Heja', 'hej', 'foo');
  26338.                   -> 0
  26339.  
  26340. `FIND_IN_SET(str,strlist)'
  26341.      Returns a value `1' to `N' if the string `str' is in the list
  26342.      `strlist' consisting of `N' substrings. A string list is a string
  26343.      composed of substrings separated by `,' characters. If the first
  26344.      argument is a constant string and the second is a column of type
  26345.      `SET', the `FIND_IN_SET()' function is optimized to use bit
  26346.      arithmetic!  Returns `0' if `str' is not in `strlist' or if
  26347.      `strlist' is the empty string.  Returns `NULL' if either argument
  26348.      is `NULL'.  This function will not work properly if the first
  26349.      argument contains a `,':
  26350.  
  26351.           mysql> SELECT FIND_IN_SET('b','a,b,c,d');
  26352.                   -> 2
  26353.  
  26354. `MAKE_SET(bits,str1,str2,...)'
  26355.      Returns a set (a string containing substrings separated by `,'
  26356.      characters) consisting of the strings that have the corresponding
  26357.      bit in `bits' set.  `str1' corresponds to bit 0, `str2' to bit 1,
  26358.      etc.  `NULL' strings in `str1', `str2', `...' are not appended to
  26359.      the result:
  26360.  
  26361.           mysql> SELECT MAKE_SET(1,'a','b','c');
  26362.                   -> 'a'
  26363.           mysql> SELECT MAKE_SET(1 | 4,'hello','nice','world');
  26364.                   -> 'hello,world'
  26365.           mysql> SELECT MAKE_SET(0,'a','b','c');
  26366.                   -> ''
  26367.  
  26368. `EXPORT_SET(bits,on,off,[separator,[number_of_bits]])'
  26369.      Returns a string where for every bit set in 'bit', you get an 'on'
  26370.      string and for every reset bit you get an 'off' string. Each
  26371.      string is separated with 'separator' (default ',') and only
  26372.      'number_of_bits' (default 64) of 'bits' is used:
  26373.  
  26374.           mysql> select EXPORT_SET(5,'Y','N',',',4)
  26375.                   -> Y,N,Y,N
  26376.  
  26377. `LCASE(str)'
  26378. `LOWER(str)'
  26379.      Returns the string `str' with all characters changed to lowercase
  26380.      according to the current character set mapping (the default is
  26381.      ISO-8859-1 Latin1):
  26382.  
  26383.           mysql> select LCASE('QUADRATICALLY');
  26384.                   -> 'quadratically'
  26385.  
  26386.      This function is multi-byte safe.
  26387.  
  26388. `UCASE(str)'
  26389. `UPPER(str)'
  26390.      Returns the string `str' with all characters changed to uppercase
  26391.      according to the current character set mapping (the default is
  26392.      ISO-8859-1 Latin1):
  26393.  
  26394.           mysql> select UCASE('Hej');
  26395.                   -> 'HEJ'
  26396.  
  26397.      This function is multi-byte safe.
  26398.  
  26399. `LOAD_FILE(file_name)'
  26400.      Reads the file and returns the file contents as a string.  The file
  26401.      must be on the server, you must specify the full pathname to the
  26402.      file, and you must have the *file* privilege.  The file must be
  26403.      readable by all and be smaller than `max_allowed_packet'.
  26404.  
  26405.      If the file doesn't exist or can't be read due to one of the above
  26406.      reasons, the function returns `NULL':
  26407.  
  26408.           mysql> UPDATE table_name
  26409.                      SET blob_column=LOAD_FILE("/tmp/picture")
  26410.                      WHERE id=1;
  26411.  
  26412. If you are not using MySQL Version 3.23, you have to do the reading of
  26413. the file inside your application and create an `INSERT' statement to
  26414. update the database with the file information. One way to do this, if
  26415. you are using the MySQL++ library, can be found at
  26416. `http://www.mysql.com/documentation/mysql++/mysql++-examples.html'.
  26417.  
  26418. MySQL automatically converts numbers to strings as necessary, and
  26419. vice-versa:
  26420.  
  26421.      mysql> SELECT 1+"1";
  26422.              -> 2
  26423.      mysql> SELECT CONCAT(2,' test');
  26424.              -> '2 test'
  26425.  
  26426. If you want to convert a number to a string explicitly, pass it as the
  26427. argument to `CONCAT()'.
  26428.  
  26429. If a string function is given a binary string as an argument, the
  26430. resulting string is also a binary string.  A number converted to a
  26431. string is treated as a binary string.  This only affects comparisons.
  26432.  
  26433. * Menu:
  26434.  
  26435. * String comparison functions::  String Comparison Functions
  26436. * Case Sensitivity Operators::  Case Sensitivity
  26437.  
  26438. 
  26439. File: mysql.info,  Node: String comparison functions,  Next: Case Sensitivity Operators,  Prev: String functions,  Up: String functions
  26440.  
  26441. String Comparison Functions
  26442. ...........................
  26443.  
  26444. Normally, if any expression in a string comparison is case sensitive,
  26445. the comparison is performed in case-sensitive fashion.
  26446.  
  26447. `expr LIKE pat [ESCAPE 'escape-char']'
  26448.      Pattern matching using SQL simple regular expression comparison.
  26449.      Returns `1' (TRUE) or `0' (FALSE).  With `LIKE' you can use the
  26450.      following two wild-card characters in the pattern:
  26451.  
  26452.      `%'     Matches any number of characters, even zero characters
  26453.      `_'     Matches exactly one character
  26454.  
  26455.           mysql> select 'David!' LIKE 'David_';
  26456.                   -> 1
  26457.           mysql> select 'David!' LIKE '%D%v%';
  26458.                   -> 1
  26459.  
  26460.      To test for literal instances of a wild-card character, precede
  26461.      the character with the escape character.  If you don't specify the
  26462.      `ESCAPE' character, `\' is assumed:
  26463.  
  26464.      `\%'    Matches one `%' character
  26465.      `\_'    Matches one `_' character
  26466.  
  26467.           mysql> select 'David!' LIKE 'David\_';
  26468.                   -> 0
  26469.           mysql> select 'David_' LIKE 'David\_';
  26470.                   -> 1
  26471.  
  26472.      To specify a different escape character, use the `ESCAPE' clause:
  26473.  
  26474.           mysql> select 'David_' LIKE 'David|_' ESCAPE '|';
  26475.                   -> 1
  26476.  
  26477.      The following two statements illustrate that string comparisons are
  26478.      case insensitive unless one of the operands is a binary string:
  26479.  
  26480.           mysql> select 'abc' LIKE 'ABC';
  26481.                   -> 1
  26482.           mysql> SELECT 'abc' LIKE BINARY 'ABC';
  26483.                   -> 0
  26484.  
  26485.      `LIKE' is allowed on numeric expressions! (This is a MySQL
  26486.      extension to the ANSI SQL `LIKE'.)
  26487.  
  26488.           mysql> select 10 LIKE '1%';
  26489.                   -> 1
  26490.  
  26491.      Note: Because MySQL uses the C escape syntax in strings (for
  26492.      example, `\n'), you must double any `\' that you use in your `LIKE'
  26493.      strings.  For example, to search for `\n', specify it as `\\n'.  To
  26494.      search for `\', specify it as `\\\\' (the backslashes are stripped
  26495.      once by the parser and another time when the pattern match is
  26496.      done, leaving a single backslash to be matched).
  26497.  
  26498. `expr NOT LIKE pat [ESCAPE 'escape-char']'
  26499.      Same as `NOT (expr LIKE pat [ESCAPE 'escape-char'])'.
  26500.  
  26501. `expr REGEXP pat'
  26502. `expr RLIKE pat'
  26503.      Performs a pattern match of a string expression `expr' against a
  26504.      pattern `pat'.  The pattern can be an extended regular expression.
  26505.      *Note Regexp::.  Returns `1' if `expr' matches `pat', otherwise
  26506.      returns `0'.  `RLIKE' is a synonym for `REGEXP', provided for
  26507.      `mSQL' compatibility. Note: Because MySQL uses the C escape syntax
  26508.      in strings (for example, `\n'), you must double any `\' that you
  26509.      use in your `REGEXP' strings.  As of MySQL Version 3.23.4,
  26510.      `REGEXP' is case insensitive for normal (not binary) strings:
  26511.  
  26512.           mysql> select 'Monty!' REGEXP 'm%y%%';
  26513.                   -> 0
  26514.           mysql> select 'Monty!' REGEXP '.*';
  26515.                   -> 1
  26516.           mysql> select 'new*\n*line' REGEXP 'new\\*.\\*line';
  26517.                   -> 1
  26518.           mysql> select "a" REGEXP "A", "a" REGEXP BINARY "A";
  26519.                   -> 1  0
  26520.           mysql> select "a" REGEXP "^[a-d]";
  26521.                   -> 1
  26522.  
  26523. `'
  26524.      `REGEXP' and `RLIKE' use the current character set (ISO-8859-1
  26525.      Latin1 by default) when deciding the type of a character.
  26526.  
  26527. `expr NOT REGEXP pat'
  26528. `expr NOT RLIKE pat'
  26529.      Same as `NOT (expr REGEXP pat)'.
  26530.  
  26531. `STRCMP(expr1,expr2)'
  26532.      `STRCMP()' returns `0' if the strings are the same, `-1' if the
  26533.      first argument is smaller than the second according to the current
  26534.      sort order, and `1' otherwise:
  26535.  
  26536.           mysql> select STRCMP('text', 'text2');
  26537.                   -> -1
  26538.           mysql> select STRCMP('text2', 'text');
  26539.                   -> 1
  26540.           mysql> select STRCMP('text', 'text');
  26541.                   -> 0
  26542.  
  26543. `MATCH (col1,col2,...) AGAINST (expr)'
  26544.      `MATCH ... AGAINST()' is used for full-text search and returns
  26545.      relevance - similarity measure between the text in columns
  26546.      `(col1,col2,...)' and the query `expr'. Relevance is a positive
  26547.      floating-point number. Zero relevance means no similarity.  For
  26548.      `MATCH ... AGAINST()' to work, a *FULLTEXT* index must be created
  26549.      first. *Note `CREATE TABLE': CREATE TABLE.  `MATCH ... AGAINST()'
  26550.      is available in MySQL Version 3.23.23 or later. For details and
  26551.      usage examples *note Fulltext Search::.
  26552.  
  26553. 
  26554. File: mysql.info,  Node: Case Sensitivity Operators,  Prev: String comparison functions,  Up: String functions
  26555.  
  26556. Case Sensitivity
  26557. ................
  26558.  
  26559. ``BINARY''
  26560.      The `BINARY' operator casts the string following it to a binary
  26561.      string.  This is an easy way to force a column comparison to be
  26562.      case sensitive even if the column isn't defined as `BINARY' or
  26563.      `BLOB':
  26564.           mysql> select "a" = "A";
  26565.                   -> 1
  26566.           mysql> select BINARY "a" = "A";
  26567.                   -> 0
  26568.  
  26569.      `BINARY' was introduced in MySQL Version 3.23.0.
  26570.  
  26571.      Note that in some context MySQL will not be able to use the index
  26572.      efficiently when you cast an indexed column to `BINARY'.
  26573.  
  26574. If you want to compare a blob case-insensitively you can always convert
  26575. the blob to upper case before doing the comparison:
  26576.  
  26577.      SELECT 'A' LIKE UPPER(blob_col) FROM table_name;
  26578.  
  26579. We plan to soon introduce casting between different character sets to
  26580. make string comparison even more flexible.
  26581.  
  26582. 
  26583. File: mysql.info,  Node: Numeric Functions,  Next: Date and time functions,  Prev: String functions,  Up: Functions
  26584.  
  26585. Numeric Functions
  26586. -----------------
  26587.  
  26588. * Menu:
  26589.  
  26590. * Arithmetic functions::        Arithmetic Operations
  26591. * Mathematical functions::      Mathematical Functions
  26592.  
  26593. 
  26594. File: mysql.info,  Node: Arithmetic functions,  Next: Mathematical functions,  Prev: Numeric Functions,  Up: Numeric Functions
  26595.  
  26596. Arithmetic Operations
  26597. .....................
  26598.  
  26599. The usual arithmetic operators are available. Note that in the case of
  26600. `-', `+', and `*', the result is calculated with `BIGINT' (64-bit)
  26601. precision if both arguments are integers!
  26602.  
  26603. `+'
  26604.      Addition:
  26605.           mysql> select 3+5;
  26606.                   -> 8
  26607.  
  26608. `-'
  26609.      Subtraction:
  26610.           mysql> select 3-5;
  26611.                   -> -2
  26612.  
  26613. `*'
  26614.      Multiplication:
  26615.           mysql> select 3*5;
  26616.                   -> 15
  26617.           mysql> select 18014398509481984*18014398509481984.0;
  26618.                   -> 324518553658426726783156020576256.0
  26619.           mysql> select 18014398509481984*18014398509481984;
  26620.                   -> 0
  26621.  
  26622.      The result of the last expression is incorrect because the result
  26623.      of the integer multiplication exceeds the 64-bit range of `BIGINT'
  26624.      calculations.
  26625.  
  26626. `/'
  26627.      Division:
  26628.           mysql> select 3/5;
  26629.                   -> 0.60
  26630.  
  26631.      Division by zero produces a `NULL' result:
  26632.  
  26633.           mysql> select 102/(1-1);
  26634.                   -> NULL
  26635.  
  26636.      A division will be calculated with `BIGINT' arithmetic only if
  26637.      performed in a context where its result is converted to an integer!
  26638.  
  26639. 
  26640. File: mysql.info,  Node: Mathematical functions,  Prev: Arithmetic functions,  Up: Numeric Functions
  26641.  
  26642. Mathematical Functions
  26643. ......................
  26644.  
  26645. All mathematical functions return `NULL' in case of an error.
  26646.  
  26647. `-'
  26648.      Unary minus. Changes the sign of the argument:
  26649.           mysql> select - 2;
  26650.                   -> -2
  26651.  
  26652.      Note that if this operator is used with a `BIGINT', the return
  26653.      value is a `BIGINT'!  This means that you should avoid using `-'
  26654.      on integers that may have the value of `-2^63'!
  26655.  
  26656. `ABS(X)'
  26657.      Returns the absolute value of `X':
  26658.           mysql> select ABS(2);
  26659.                   -> 2
  26660.           mysql> select ABS(-32);
  26661.                   -> 32
  26662.  
  26663.      This function is safe to use with `BIGINT' values.
  26664.  
  26665. `SIGN(X)'
  26666.      Returns the sign of the argument as `-1', `0', or `1', depending
  26667.      on whether `X' is negative, zero, or positive:
  26668.           mysql> select SIGN(-32);
  26669.                   -> -1
  26670.           mysql> select SIGN(0);
  26671.                   -> 0
  26672.           mysql> select SIGN(234);
  26673.                   -> 1
  26674.  
  26675. `MOD(N,M)'
  26676. `%'
  26677.      Modulo (like the `%' operator in C).  Returns the remainder of `N'
  26678.      divided by `M':
  26679.           mysql> select MOD(234, 10);
  26680.                   -> 4
  26681.           mysql> select 253 % 7;
  26682.                   -> 1
  26683.           mysql> select MOD(29,9);
  26684.                   -> 2
  26685.  
  26686.      This function is safe to use with `BIGINT' values.
  26687.  
  26688. `FLOOR(X)'
  26689.      Returns the largest integer value not greater than `X':
  26690.           mysql> select FLOOR(1.23);
  26691.                   -> 1
  26692.           mysql> select FLOOR(-1.23);
  26693.                   -> -2
  26694.  
  26695.      Note that the return value is converted to a `BIGINT'!
  26696.  
  26697. `CEILING(X)'
  26698.      Returns the smallest integer value not less than `X':
  26699.           mysql> select CEILING(1.23);
  26700.                   -> 2
  26701.           mysql> select CEILING(-1.23);
  26702.                   -> -1
  26703.  
  26704.      Note that the return value is converted to a `BIGINT'!
  26705.  
  26706. `ROUND(X)'
  26707.      Returns the argument `X', rounded to the nearest integer:
  26708.           mysql> select ROUND(-1.23);
  26709.                   -> -1
  26710.           mysql> select ROUND(-1.58);
  26711.                   -> -2
  26712.           mysql> select ROUND(1.58);
  26713.                   -> 2
  26714.  
  26715.      Note that the behavior of `ROUND()' when the argument is half way
  26716.      between two integers depends on the C library implementation.
  26717.      Some round to the nearest even number, always up, always down, or
  26718.      always towards zero.  If you need one kind of rounding, you should
  26719.      use a well-defined function like `TRUNCATE()' or `FLOOR()' instead.
  26720.  
  26721. `ROUND(X,D)'
  26722.      Returns the argument `X', rounded to a number with `D' decimals.
  26723.      If `D' is `0', the result will have no decimal point or fractional
  26724.      part:
  26725.  
  26726.           mysql> select ROUND(1.298, 1);
  26727.                   -> 1.3
  26728.           mysql> select ROUND(1.298, 0);
  26729.                   -> 1
  26730.  
  26731. `EXP(X)'
  26732.      Returns the value of `e' (the base of natural logarithms) raised to
  26733.      the power of `X':
  26734.           mysql> select EXP(2);
  26735.                   -> 7.389056
  26736.           mysql> select EXP(-2);
  26737.                   -> 0.135335
  26738.  
  26739. `LOG(X)'
  26740.      Returns the natural logarithm of `X':
  26741.           mysql> select LOG(2);
  26742.                   -> 0.693147
  26743.           mysql> select LOG(-2);
  26744.                   -> NULL
  26745.      If you want the log of a number `X' to some arbitary base `B', use
  26746.      the formula `LOG(X)/LOG(B)'.
  26747.  
  26748. `LOG10(X)'
  26749.      Returns the base-10 logarithm of `X':
  26750.           mysql> select LOG10(2);
  26751.                   -> 0.301030
  26752.           mysql> select LOG10(100);
  26753.                   -> 2.000000
  26754.           mysql> select LOG10(-100);
  26755.                   -> NULL
  26756.  
  26757. `POW(X,Y)'
  26758. `POWER(X,Y)'
  26759.      Returns the value of `X' raised to the power of `Y':
  26760.           mysql> select POW(2,2);
  26761.                   -> 4.000000
  26762.           mysql> select POW(2,-2);
  26763.                   -> 0.250000
  26764.  
  26765. `SQRT(X)'
  26766.      Returns the non-negative square root of `X':
  26767.           mysql> select SQRT(4);
  26768.                   -> 2.000000
  26769.           mysql> select SQRT(20);
  26770.                   -> 4.472136
  26771.  
  26772. `PI()'
  26773.      Returns the value of PI. The default shown number of decimals is
  26774.      5, but MySQL internally uses the full double precession for PI.
  26775.           mysql> select PI();
  26776.                   -> 3.141593
  26777.           mysql> SELECT PI()+0.000000000000000000;
  26778.                   -> 3.141592653589793116
  26779.  
  26780. `COS(X)'
  26781.      Returns the cosine of `X', where `X' is given in radians:
  26782.           mysql> select COS(PI());
  26783.                   -> -1.000000
  26784.  
  26785. `SIN(X)'
  26786.      Returns the sine of `X', where `X' is given in radians:
  26787.           mysql> select SIN(PI());
  26788.                   -> 0.000000
  26789.  
  26790. `TAN(X)'
  26791.      Returns the tangent of `X', where `X' is given in radians:
  26792.           mysql> select TAN(PI()+1);
  26793.                   -> 1.557408
  26794.  
  26795. `ACOS(X)'
  26796.      Returns the arc cosine of `X', that is, the value whose cosine is
  26797.      `X'. Returns `NULL' if `X' is not in the range `-1' to `1':
  26798.           mysql> select ACOS(1);
  26799.                   -> 0.000000
  26800.           mysql> select ACOS(1.0001);
  26801.                   -> NULL
  26802.           mysql> select ACOS(0);
  26803.                   -> 1.570796
  26804.  
  26805. `ASIN(X)'
  26806.      Returns the arc sine of `X', that is, the value whose sine is `X'.
  26807.      Returns `NULL' if `X' is not in the range `-1' to `1':
  26808.           mysql> select ASIN(0.2);
  26809.                   -> 0.201358
  26810.           mysql> select ASIN('foo');
  26811.                   -> 0.000000
  26812.  
  26813. `ATAN(X)'
  26814.      Returns the arc tangent of `X', that is, the value whose tangent is
  26815.      `X':
  26816.           mysql> select ATAN(2);
  26817.                   -> 1.107149
  26818.           mysql> select ATAN(-2);
  26819.                   -> -1.107149
  26820.  
  26821. `ATAN(Y,X)'
  26822. `ATAN2(Y,X)'
  26823.      Returns the arc tangent of the two variables `X' and `Y'. It is
  26824.      similar to calculating the arc tangent of `Y / X', except that the
  26825.      signs of both arguments are used to determine the quadrant of the
  26826.      result:
  26827.           mysql> select ATAN(-2,2);
  26828.                   -> -0.785398
  26829.           mysql> select ATAN2(PI(),0);
  26830.                   -> 1.570796
  26831.  
  26832. `COT(X)'
  26833.      Returns the cotangent of `X':
  26834.           mysql> select COT(12);
  26835.                   -> -1.57267341
  26836.           mysql> select COT(0);
  26837.                   -> NULL
  26838.  
  26839. `RAND()'
  26840. `RAND(N)'
  26841.      Returns a random floating-point value in the range `0' to `1.0'.
  26842.      If an integer argument `N' is specified, it is used as the seed
  26843.      value:
  26844.           mysql> select RAND();
  26845.                   -> 0.5925
  26846.           mysql> select RAND(20);
  26847.                   -> 0.1811
  26848.           mysql> select RAND(20);
  26849.                   -> 0.1811
  26850.           mysql> select RAND();
  26851.                   -> 0.2079
  26852.           mysql> select RAND();
  26853.                   -> 0.7888
  26854.      You can't use a column with `RAND()' values in an `ORDER BY'
  26855.      clause, because `ORDER BY' would evaluate the column multiple
  26856.      times.  In MySQL Version 3.23, you can, however, do: `SELECT *
  26857.      FROM table_name ORDER BY RAND()'
  26858.  
  26859.      This is useful to get a random sample of a set `SELECT * FROM
  26860.      table1,table2 WHERE a=b AND c<d ORDER BY RAND() LIMIT 1000'.
  26861.  
  26862.      Note that a `RAND()' in a `WHERE' clause will be re-evaluated
  26863.      every time the `WHERE' is executed.
  26864.  
  26865. `LEAST(X,Y,...)'
  26866.      With two or more arguments, returns the smallest (minimum-valued)
  26867.      argument.  The arguments are compared using the following rules:
  26868.  
  26869.         * If the return value is used in an `INTEGER' context, or all
  26870.           arguments are integer-valued, they are compared as integers.
  26871.  
  26872.         * If the return value is used in a `REAL' context, or all
  26873.           arguments are real-valued, they are compared as reals.
  26874.  
  26875.         * If any argument is a case-sensitive string, the arguments are
  26876.           compared as case-sensitive strings.
  26877.  
  26878.         * In other cases, the arguments are compared as
  26879.           case-insensitive strings:
  26880.  
  26881.           mysql> select LEAST(2,0);
  26882.                   -> 0
  26883.           mysql> select LEAST(34.0,3.0,5.0,767.0);
  26884.                   -> 3.0
  26885.           mysql> select LEAST("B","A","C");
  26886.                   -> "A"
  26887.      In MySQL versions prior to Version 3.22.5, you can use `MIN()'
  26888.      instead of `LEAST'.
  26889.  
  26890. `GREATEST(X,Y,...)'
  26891.      Returns the largest (maximum-valued) argument.  The arguments are
  26892.      compared using the same rules as for `LEAST':
  26893.           mysql> select GREATEST(2,0);
  26894.                   -> 2
  26895.           mysql> select GREATEST(34.0,3.0,5.0,767.0);
  26896.                   -> 767.0
  26897.           mysql> select GREATEST("B","A","C");
  26898.                   -> "C"
  26899.      In MySQL versions prior to Version 3.22.5, you can use `MAX()'
  26900.      instead of `GREATEST'.
  26901.  
  26902. `DEGREES(X)'
  26903.      Returns the argument `X', converted from radians to degrees:
  26904.           mysql> select DEGREES(PI());
  26905.                   -> 180.000000
  26906.  
  26907. `RADIANS(X)'
  26908.      Returns the argument `X', converted from degrees to radians:
  26909.           mysql> select RADIANS(90);
  26910.                   -> 1.570796
  26911.  
  26912. `TRUNCATE(X,D)'
  26913.      Returns the number `X', truncated to `D' decimals.  If `D' is `0',
  26914.      the result will have no decimal point or fractional part:
  26915.           mysql> select TRUNCATE(1.223,1);
  26916.                   -> 1.2
  26917.           mysql> select TRUNCATE(1.999,1);
  26918.                   -> 1.9
  26919.           mysql> select TRUNCATE(1.999,0);
  26920.                   -> 1
  26921.           mysql> select TRUNCATE(-1.999,1);
  26922.                   -> -1.9
  26923.  
  26924.      Starting from MySQL 3.23.51 all numbers are rounded towards zero.
  26925.  
  26926.      If `D' is negative, then the whole part of the number is zeroed
  26927.      out:
  26928.  
  26929.           mysql> select truncate(122,-2);
  26930.                  -> 100
  26931.  
  26932.      Note that as decimal numbers are normally not stored as exact
  26933.      numbers in computers, but as double values, you may be fooled by
  26934.      the following result:
  26935.  
  26936.           mysql> select TRUNCATE(10.28*100,0);
  26937.                  -> 1027
  26938.  
  26939.      The above happens because 10.28 is actually stored as something
  26940.      like 10.2799999999999999.
  26941.  
  26942. 
  26943. File: mysql.info,  Node: Date and time functions,  Next: Other Functions,  Prev: Numeric Functions,  Up: Functions
  26944.  
  26945. Date and Time Functions
  26946. -----------------------
  26947.  
  26948. See *Note Date and time types:: for a description of the range of values
  26949. each type has and the valid formats in which date and time values may be
  26950. specified.
  26951.  
  26952. Here is an example that uses date functions.  The query below selects
  26953. all records with a `date_col' value from within the last 30 days:
  26954.  
  26955.      mysql> SELECT something FROM table
  26956.                 WHERE TO_DAYS(NOW()) - TO_DAYS(date_col) <= 30;
  26957.  
  26958. `DAYOFWEEK(date)'
  26959.      Returns the weekday index
  26960.  
  26961.      for `date' (`1' = Sunday, `2' = Monday, ... `7' = Saturday).
  26962.      These index values correspond to the ODBC standard:
  26963.  
  26964.           mysql> select DAYOFWEEK('1998-02-03');
  26965.                   -> 3
  26966.  
  26967. `WEEKDAY(date)'
  26968.      Returns the weekday index for `date' (`0' = Monday, `1' = Tuesday,
  26969.      ... `6' = Sunday):
  26970.  
  26971.           mysql> select WEEKDAY('1997-10-04 22:23:00');
  26972.                   -> 5
  26973.           mysql> select WEEKDAY('1997-11-05');
  26974.                   -> 2
  26975.  
  26976. `DAYOFMONTH(date)'
  26977.      Returns the day of the month for `date', in the range `1' to `31':
  26978.  
  26979.           mysql> select DAYOFMONTH('1998-02-03');
  26980.                   -> 3
  26981.  
  26982. `DAYOFYEAR(date)'
  26983.      Returns the day of the year for `date', in the range `1' to `366':
  26984.  
  26985.           mysql> select DAYOFYEAR('1998-02-03');
  26986.                   -> 34
  26987.  
  26988. `MONTH(date)'
  26989.      Returns the month for `date', in the range `1' to `12':
  26990.  
  26991.           mysql> select MONTH('1998-02-03');
  26992.                   -> 2
  26993.  
  26994. `DAYNAME(date)'
  26995.      Returns the name of the weekday for `date':
  26996.  
  26997.           mysql> select DAYNAME("1998-02-05");
  26998.                   -> 'Thursday'
  26999.  
  27000. `MONTHNAME(date)'
  27001.      Returns the name of the month for `date':
  27002.  
  27003.           mysql> select MONTHNAME("1998-02-05");
  27004.                   -> 'February'
  27005.  
  27006. `QUARTER(date)'
  27007.      Returns the quarter of the year for `date', in the range `1' to
  27008.      `4':
  27009.  
  27010.           mysql> select QUARTER('98-04-01');
  27011.                   -> 2
  27012.  
  27013. `WEEK(date)'
  27014. `WEEK(date,first)'
  27015.      With a single argument, returns the week for `date', in the range
  27016.      `0' to `53' (yes, there may be the beginnings of a week 53), for
  27017.      locations where Sunday is the first day of the week.  The
  27018.      two-argument form of `WEEK()' allows you to specify whether the
  27019.      week starts on Sunday or Monday.  The week starts on Sunday if the
  27020.      second argument is `0', on Monday if the second argument is `1':
  27021.  
  27022.           mysql> select WEEK('1998-02-20');
  27023.                   -> 7
  27024.           mysql> select WEEK('1998-02-20',0);
  27025.                   -> 7
  27026.           mysql> select WEEK('1998-02-20',1);
  27027.                   -> 8
  27028.           mysql> select WEEK('1998-12-31',1);
  27029.                   -> 53
  27030.  
  27031. `YEAR(date)'
  27032.      Returns the year for `date', in the range `1000' to `9999':
  27033.  
  27034.           mysql> select YEAR('98-02-03');
  27035.                   -> 1998
  27036.  
  27037. `YEARWEEK(date)'
  27038. `YEARWEEK(date,first)'
  27039.      Returns year and week for a date.  The second arguments works
  27040.      exactly like the second argument to `WEEK()'.  Note that the year
  27041.      may be different from the year in the date argument for the first
  27042.      and the last week of the year:
  27043.  
  27044.           mysql> select YEARWEEK('1987-01-01');
  27045.                   -> 198653
  27046.  
  27047. `HOUR(time)'
  27048.      Returns the hour for `time', in the range `0' to `23':
  27049.  
  27050.           mysql> select HOUR('10:05:03');
  27051.                   -> 10
  27052.  
  27053. `MINUTE(time)'
  27054.      Returns the minute for `time', in the range `0' to `59':
  27055.  
  27056.           mysql> select MINUTE('98-02-03 10:05:03');
  27057.                   -> 5
  27058.  
  27059. `SECOND(time)'
  27060.      Returns the second for `time', in the range `0' to `59':
  27061.  
  27062.           mysql> select SECOND('10:05:03');
  27063.                   -> 3
  27064.  
  27065. `PERIOD_ADD(P,N)'
  27066.      Adds `N' months to period `P' (in the format `YYMM' or `YYYYMM').
  27067.      Returns a value in the format `YYYYMM'.
  27068.  
  27069.      Note that the period argument `P' is _not_ a date value:
  27070.  
  27071.           mysql> select PERIOD_ADD(9801,2);
  27072.                   -> 199803
  27073.  
  27074. `PERIOD_DIFF(P1,P2)'
  27075.      Returns the number of months between periods `P1' and `P2'.  `P1'
  27076.      and `P2' should be in the format `YYMM' or `YYYYMM'.
  27077.  
  27078.      Note that the period arguments `P1' and `P2' are _not_ date values:
  27079.  
  27080.           mysql> select PERIOD_DIFF(9802,199703);
  27081.                   -> 11
  27082.  
  27083. `DATE_ADD(date,INTERVAL expr type)'
  27084. `DATE_SUB(date,INTERVAL expr type)'
  27085. `ADDDATE(date,INTERVAL expr type)'
  27086. `SUBDATE(date,INTERVAL expr type)'
  27087.      These functions perform date arithmetic.  They are new for MySQL
  27088.      Version 3.22.  `ADDDATE()' and `SUBDATE()' are synonyms for
  27089.      `DATE_ADD()' and `DATE_SUB()'.
  27090.  
  27091.      In MySQL Version 3.23, you can use `+' and `-' instead of
  27092.      `DATE_ADD()' and `DATE_SUB()' if the expression on the right side
  27093.      is a date or datetime column. (See example)
  27094.  
  27095.      `date' is a `DATETIME' or `DATE' value specifying the starting
  27096.      date.  `expr' is an expression specifying the interval value to be
  27097.      added or subtracted from the starting date.  `expr' is a string;
  27098.      it may start with a `-' for negative intervals.  `type' is a
  27099.      keyword indicating how the expression should be interpreted.
  27100.  
  27101.      The related function `EXTRACT(type FROM date)' returns the 'type'
  27102.      interval from the date.
  27103.  
  27104.      The following table shows how the `type' and `expr' arguments are
  27105.      related:
  27106.  
  27107.      `type' *value*                     *Expected* `expr' *format*
  27108.      `SECOND'                           `SECONDS'
  27109.      `MINUTE'                           `MINUTES'
  27110.      `HOUR'                             `HOURS'
  27111.      `DAY'                              `DAYS'
  27112.      `MONTH'                            `MONTHS'
  27113.      `YEAR'                             `YEARS'
  27114.      `MINUTE_SECOND'                    `"MINUTES:SECONDS"'
  27115.      `HOUR_MINUTE'                      `"HOURS:MINUTES"'
  27116.      `DAY_HOUR'                         `"DAYS HOURS"'
  27117.      `YEAR_MONTH'                       `"YEARS-MONTHS"'
  27118.      `HOUR_SECOND'                      `"HOURS:MINUTES:SECONDS"'
  27119.      `DAY_MINUTE'                       `"DAYS HOURS:MINUTES"'
  27120.      `DAY_SECOND'                       `"DAYS HOURS:MINUTES:SECONDS"'
  27121.  
  27122.      MySQL allows any punctuation delimiter in the `expr' format.
  27123.      Those shown in the table are the suggested delimiters.  If the
  27124.      `date' argument is a `DATE' value and your calculations involve
  27125.      only `YEAR', `MONTH', and `DAY' parts (that is, no time parts), the
  27126.      result is a `DATE' value.  Otherwise the result is a `DATETIME'
  27127.      value:
  27128.  
  27129.           mysql> SELECT "1997-12-31 23:59:59" + INTERVAL 1 SECOND;
  27130.                   -> 1998-01-01 00:00:00
  27131.           mysql> SELECT INTERVAL 1 DAY + "1997-12-31";
  27132.                   -> 1998-01-01
  27133.           mysql> SELECT "1998-01-01" - INTERVAL 1 SECOND;
  27134.                  -> 1997-12-31 23:59:59
  27135.           mysql> SELECT DATE_ADD("1997-12-31 23:59:59",
  27136.                                  INTERVAL 1 SECOND);
  27137.                   -> 1998-01-01 00:00:00
  27138.           mysql> SELECT DATE_ADD("1997-12-31 23:59:59",
  27139.                                  INTERVAL 1 DAY);
  27140.                   -> 1998-01-01 23:59:59
  27141.           mysql> SELECT DATE_ADD("1997-12-31 23:59:59",
  27142.                                  INTERVAL "1:1" MINUTE_SECOND);
  27143.                   -> 1998-01-01 00:01:00
  27144.           mysql> SELECT DATE_SUB("1998-01-01 00:00:00",
  27145.                                  INTERVAL "1 1:1:1" DAY_SECOND);
  27146.                   -> 1997-12-30 22:58:59
  27147.           mysql> SELECT DATE_ADD("1998-01-01 00:00:00",
  27148.                                  INTERVAL "-1 10" DAY_HOUR);
  27149.                   -> 1997-12-30 14:00:00
  27150.           mysql> SELECT DATE_SUB("1998-01-02", INTERVAL 31 DAY);
  27151.                   -> 1997-12-02
  27152.  
  27153.      If you specify an interval value that is too short (does not
  27154.      include all the interval parts that would be expected from the
  27155.      `type' keyword), MySQL assumes you have left out the leftmost
  27156.      parts of the interval value.  For example, if you specify a `type'
  27157.      of `DAY_SECOND', the value of `expr' is expected to have days,
  27158.      hours, minutes, and seconds parts.  If you specify a value like
  27159.      `"1:10"', MySQL assumes that the days and hours parts are missing
  27160.      and the value represents minutes and seconds.  In other words,
  27161.      `"1:10" DAY_SECOND' is interpreted in such a way that it is
  27162.      equivalent to `"1:10" MINUTE_SECOND'.  This is analogous to the
  27163.      way that MySQL interprets `TIME' values as representing elapsed
  27164.      time rather than as time of day.
  27165.  
  27166.      Note that if you add or subtract a date value against something
  27167.      that contains a time part, the date value will be automatically
  27168.      converted to a datetime value:
  27169.  
  27170.           mysql> select date_add("1999-01-01", interval 1 day);
  27171.                  -> 1999-01-02
  27172.           mysql> select date_add("1999-01-01", interval 1 hour);
  27173.                  -> 1999-01-01 01:00:00
  27174.  
  27175.      If you use really incorrect dates, the result is `NULL'. If you add
  27176.      `MONTH', `YEAR_MONTH', or `YEAR' and the resulting date has a day
  27177.      that is larger than the maximum day for the new month, the day is
  27178.      adjusted to the maximum days in the new month:
  27179.  
  27180.           mysql> select DATE_ADD('1998-01-30', Interval 1 month);
  27181.                   -> 1998-02-28
  27182.  
  27183.      Note from the preceding example that the word `INTERVAL' and the
  27184.      `type' keyword are not case sensitive.
  27185.  
  27186. `EXTRACT(type FROM date)'
  27187.      The `EXTRACT()' function uses the same kinds of interval type
  27188.      specifiers as `DATE_ADD()' or `DATE_SUB()', but extracts parts
  27189.      from the date rather than performing date arithmetic.
  27190.  
  27191.           mysql> SELECT EXTRACT(YEAR FROM "1999-07-02");
  27192.                  -> 1999
  27193.           mysql> SELECT EXTRACT(YEAR_MONTH FROM "1999-07-02 01:02:03");
  27194.                  -> 199907
  27195.           mysql> SELECT EXTRACT(DAY_MINUTE FROM "1999-07-02 01:02:03");
  27196.                  -> 20102
  27197.  
  27198. `TO_DAYS(date)'
  27199.      Given a date `date', returns a daynumber (the number of days since
  27200.      year 0):
  27201.  
  27202.           mysql> select TO_DAYS(950501);
  27203.                   -> 728779
  27204.           mysql> select TO_DAYS('1997-10-07');
  27205.                   -> 729669
  27206.  
  27207.      `TO_DAYS()' is not intended for use with values that precede the
  27208.      advent of the Gregorian calendar (1582), because it doesn't take
  27209.      into account the days that were lost when the calendar was changed.
  27210.  
  27211. `FROM_DAYS(N)'
  27212.      Given a daynumber `N', returns a `DATE' value:
  27213.  
  27214.           mysql> select FROM_DAYS(729669);
  27215.                   -> '1997-10-07'
  27216.  
  27217.      `FROM_DAYS()' is not intended for use with values that precede the
  27218.      advent of the Gregorian calendar (1582), because it doesn't take
  27219.      into account the days that were lost when the calendar was changed.
  27220.  
  27221. `DATE_FORMAT(date,format)'
  27222.      Formats the `date' value according to the `format' string. The
  27223.      following specifiers may be used in the `format' string:
  27224.      `%M'    Month name (`January'..`December')
  27225.      `%W'    Weekday name (`Sunday'..`Saturday')
  27226.      `%D'    Day of the month with English suffix
  27227.              (`1st', `2nd', `3rd', etc.)
  27228.      `%Y'    Year, numeric, 4 digits
  27229.      `%y'    Year, numeric, 2 digits
  27230.      `%X'    Year for the week where Sunday is the
  27231.              first day of the week, numeric, 4
  27232.              digits, used with '%V'
  27233.      `%x'    Year for the week, where Monday is the
  27234.              first day of the week, numeric, 4
  27235.              digits, used with '%v'
  27236.      `%a'    Abbreviated weekday name (`Sun'..`Sat')
  27237.      `%d'    Day of the month, numeric (`00'..`31')
  27238.      `%e'    Day of the month, numeric (`0'..`31')
  27239.      `%m'    Month, numeric (`01'..`12')
  27240.      `%c'    Month, numeric (`1'..`12')
  27241.      `%b'    Abbreviated month name (`Jan'..`Dec')
  27242.      `%j'    Day of year (`001'..`366')
  27243.      `%H'    Hour (`00'..`23')
  27244.      `%k'    Hour (`0'..`23')
  27245.      `%h'    Hour (`01'..`12')
  27246.      `%I'    Hour (`01'..`12')
  27247.      `%l'    Hour (`1'..`12')
  27248.      `%i'    Minutes, numeric (`00'..`59')
  27249.      `%r'    Time, 12-hour (`hh:mm:ss [AP]M')
  27250.      `%T'    Time, 24-hour (`hh:mm:ss')
  27251.      `%S'    Seconds (`00'..`59')
  27252.      `%s'    Seconds (`00'..`59')
  27253.      `%p'    `AM' or `PM'
  27254.      `%w'    Day of the week
  27255.              (`0'=Sunday..`6'=Saturday)
  27256.      `%U'    Week (`0'..`53'), where Sunday is the
  27257.              first day of the week
  27258.      `%u'    Week (`0'..`53'), where Monday is the
  27259.              first day of the week
  27260.      `%V'    Week (`1'..`53'), where Sunday is the
  27261.              first day of the week. Used with '%X'
  27262.      `%v'    Week (`1'..`53'), where Monday is the
  27263.              first day of the week. Used with '%x'
  27264.      `%%'    A literal `%'.
  27265.  
  27266.      All other characters are just copied to the result without
  27267.      interpretation:
  27268.  
  27269.           mysql> select DATE_FORMAT('1997-10-04 22:23:00', '%W %M %Y');
  27270.                   -> 'Saturday October 1997'
  27271.           mysql> select DATE_FORMAT('1997-10-04 22:23:00', '%H:%i:%s');
  27272.                   -> '22:23:00'
  27273.           mysql> select DATE_FORMAT('1997-10-04 22:23:00',
  27274.                                     '%D %y %a %d %m %b %j');
  27275.                   -> '4th 97 Sat 04 10 Oct 277'
  27276.           mysql> select DATE_FORMAT('1997-10-04 22:23:00',
  27277.                                     '%H %k %I %r %T %S %w');
  27278.                   -> '22 22 10 10:23:00 PM 22:23:00 00 6'
  27279.           mysql> select DATE_FORMAT('1999-01-01', '%X %V');
  27280.                   -> '1998 52'
  27281.  
  27282.      As of MySQL Version 3.23, the `%' character is required before
  27283.      format specifier characters.  In earlier versions of MySQL, `%'
  27284.      was optional.
  27285.  
  27286. `TIME_FORMAT(time,format)'
  27287.      This is used like the `DATE_FORMAT()' function above, but the
  27288.      `format' string may contain only those format specifiers that
  27289.      handle hours, minutes, and seconds.  Other specifiers produce a
  27290.      `NULL' value or `0'.
  27291.  
  27292. `CURDATE()'
  27293. `CURRENT_DATE'
  27294.      Returns today's date as a value in `'YYYY-MM-DD'' or `YYYYMMDD'
  27295.      format, depending on whether the function is used in a string or
  27296.      numeric context:
  27297.  
  27298.           mysql> select CURDATE();
  27299.                   -> '1997-12-15'
  27300.           mysql> select CURDATE() + 0;
  27301.                   -> 19971215
  27302.  
  27303. `CURTIME()'
  27304. `CURRENT_TIME'
  27305.      Returns the current time as a value in `'HH:MM:SS'' or `HHMMSS'
  27306.      format, depending on whether the function is used in a string or
  27307.      numeric context:
  27308.  
  27309.           mysql> select CURTIME();
  27310.                   -> '23:50:26'
  27311.           mysql> select CURTIME() + 0;
  27312.                   -> 235026
  27313.  
  27314. `NOW()'
  27315. `SYSDATE()'
  27316. `CURRENT_TIMESTAMP'
  27317.      Returns the current date and time as a value in `'YYYY-MM-DD
  27318.      HH:MM:SS'' or `YYYYMMDDHHMMSS' format, depending on whether the
  27319.      function is used in a string or numeric context:
  27320.  
  27321.           mysql> select NOW();
  27322.                   -> '1997-12-15 23:50:26'
  27323.           mysql> select NOW() + 0;
  27324.                   -> 19971215235026
  27325.  
  27326. `UNIX_TIMESTAMP()'
  27327. `UNIX_TIMESTAMP(date)'
  27328.      If called with no argument, returns a Unix timestamp (seconds since
  27329.      `'1970-01-01 00:00:00'' GMT). If `UNIX_TIMESTAMP()' is called with
  27330.      a `date' argument, it returns the value of the argument as seconds
  27331.      since `'1970-01-01 00:00:00'' GMT.  `date' may be a `DATE' string,
  27332.      a `DATETIME' string, a `TIMESTAMP', or a number in the format
  27333.      `YYMMDD' or `YYYYMMDD' in local time:
  27334.  
  27335.           mysql> select UNIX_TIMESTAMP();
  27336.                   -> 882226357
  27337.           mysql> select UNIX_TIMESTAMP('1997-10-04 22:23:00');
  27338.                   -> 875996580
  27339.  
  27340.      When `UNIX_TIMESTAMP' is used on a `TIMESTAMP' column, the function
  27341.      will receive the value directly, with no implicit
  27342.      "string-to-unix-timestamp" conversion.  If you give
  27343.      `UNIX_TIMESTAMP()' a wrong or out-of-range date, it will return 0.
  27344.  
  27345. `FROM_UNIXTIME(unix_timestamp)'
  27346.      Returns a representation of the `unix_timestamp' argument as a
  27347.      value in `'YYYY-MM-DD HH:MM:SS'' or `YYYYMMDDHHMMSS' format,
  27348.      depending on whether the function is used in a string or numeric
  27349.      context:
  27350.  
  27351.           mysql> select FROM_UNIXTIME(875996580);
  27352.                   -> '1997-10-04 22:23:00'
  27353.           mysql> select FROM_UNIXTIME(875996580) + 0;
  27354.                   -> 19971004222300
  27355.  
  27356. `FROM_UNIXTIME(unix_timestamp,format)'
  27357.      Returns a string representation of the Unix timestamp, formatted
  27358.      according to the `format' string. `format' may contain the same
  27359.      specifiers as those listed in the entry for the `DATE_FORMAT()'
  27360.      function:
  27361.  
  27362.           mysql> select FROM_UNIXTIME(UNIX_TIMESTAMP(),
  27363.                                       '%Y %D %M %h:%i:%s %x');
  27364.                   -> '1997 23rd December 03:43:30 x'
  27365.  
  27366. `SEC_TO_TIME(seconds)'
  27367.      Returns the `seconds' argument, converted to hours, minutes, and
  27368.      seconds, as a value in `'HH:MM:SS'' or `HHMMSS' format, depending
  27369.      on whether the function is used in a string or numeric context:
  27370.  
  27371.           mysql> select SEC_TO_TIME(2378);
  27372.                   -> '00:39:38'
  27373.           mysql> select SEC_TO_TIME(2378) + 0;
  27374.                   -> 3938
  27375.  
  27376. `TIME_TO_SEC(time)'
  27377.      Returns the `time' argument, converted to seconds:
  27378.  
  27379.           mysql> select TIME_TO_SEC('22:23:00');
  27380.                   -> 80580
  27381.           mysql> select TIME_TO_SEC('00:39:38');
  27382.                   -> 2378
  27383.  
  27384. 
  27385. File: mysql.info,  Node: Other Functions,  Prev: Date and time functions,  Up: Functions
  27386.  
  27387. Other Functions
  27388. ---------------
  27389.  
  27390. * Menu:
  27391.  
  27392. * Bit functions::               Bit Functions
  27393. * Miscellaneous functions::     Miscellaneous Functions
  27394.  
  27395. 
  27396. File: mysql.info,  Node: Bit functions,  Next: Miscellaneous functions,  Prev: Other Functions,  Up: Other Functions
  27397.  
  27398. Bit Functions
  27399. .............
  27400.  
  27401. MySQL uses `BIGINT' (64-bit) arithmetic for bit operations, so these
  27402. operators have a maximum range of 64 bits.
  27403.  
  27404. `|'
  27405.      Bitwise OR:
  27406.           mysql> select 29 | 15;
  27407.                   -> 31
  27408.  
  27409. `&'
  27410.      Bitwise AND:
  27411.           mysql> select 29 & 15;
  27412.                   -> 13
  27413.  
  27414. `<<'
  27415.      Shifts a longlong (`BIGINT') number to the left:
  27416.           mysql> select 1 << 2;
  27417.                   -> 4
  27418.  
  27419. `>>'
  27420.      Shifts a longlong (`BIGINT') number to the right:
  27421.           mysql> select 4 >> 2;
  27422.                   -> 1
  27423.  
  27424. `~'
  27425.      Invert all bits:
  27426.           mysql> select 5 & ~1;
  27427.                   -> 4
  27428.  
  27429. `BIT_COUNT(N)'
  27430.      Returns the number of bits that are set in the argument `N':
  27431.           mysql> select BIT_COUNT(29);
  27432.                   -> 4
  27433.  
  27434. 
  27435. File: mysql.info,  Node: Miscellaneous functions,  Prev: Bit functions,  Up: Other Functions
  27436.  
  27437. Miscellaneous Functions
  27438. .......................
  27439.  
  27440. `DATABASE()'
  27441.      Returns the current database name:
  27442.  
  27443.           mysql> select DATABASE();
  27444.                   -> 'test'
  27445.  
  27446.      If there is no current database, `DATABASE()' returns the empty
  27447.      string.
  27448.  
  27449. `USER()'
  27450. `SYSTEM_USER()'
  27451. `SESSION_USER()'
  27452.      Returns the current MySQL user name:
  27453.  
  27454.           mysql> select USER();
  27455.                   -> 'davida@localhost'
  27456.  
  27457.      In MySQL Version 3.22.11 or later, this includes the client
  27458.      hostname as well  as the user name.  You can extract just the user
  27459.      name part like this (which works whether or not the value includes
  27460.      a hostname part):
  27461.  
  27462.           mysql> select substring_index(USER(),"@",1);
  27463.                   -> 'davida'
  27464.  
  27465. `PASSWORD(str)'
  27466.      Calculates a password string from the plaintext password `str'.
  27467.      This is the function that is used for encrypting MySQL passwords
  27468.      for storage in the `Password' column of the `user' grant table:
  27469.  
  27470.           mysql> select PASSWORD('badpwd');
  27471.                   -> '7f84554057dd964b'
  27472.  
  27473.      `PASSWORD()' encryption is non-reversible.
  27474.  
  27475.      `PASSWORD()' does not perform password encryption in the same way
  27476.      that Unix passwords are encrypted.  You should not assume that if
  27477.      your Unix password and your MySQL password are the same,
  27478.      `PASSWORD()' will result in the same encrypted value as is stored
  27479.      in the Unix password file.  See `ENCRYPT()'.
  27480.  
  27481. `ENCRYPT(str[,salt])'
  27482.      Encrypt `str' using the Unix `crypt()' system call. The `salt'
  27483.      argument should be a string with two characters.  (As of MySQL
  27484.      Version 3.22.16, `salt' may be longer than two characters.):
  27485.  
  27486.           mysql> select ENCRYPT("hello");
  27487.                   -> 'VxuFAJXVARROc'
  27488.  
  27489.      If `crypt()' is not available on your system, `ENCRYPT()' always
  27490.      returns `NULL'.
  27491.  
  27492.      `ENCRYPT()' ignores all but the first 8 characters of `str', at
  27493.      least on some systems.  This will be determined by the behavior of
  27494.      the underlying `crypt()' system call.
  27495.  
  27496. `ENCODE(str,pass_str)'
  27497.      Encrypt `str' using `pass_str' as the password.  To decrypt the
  27498.      result, use `DECODE()'.
  27499.  
  27500.      The results is a binary string of the same length as `string'.  If
  27501.      you want to save it in a column, use a `BLOB' column type.
  27502.  
  27503. `DECODE(crypt_str,pass_str)'
  27504.      Descrypts the encrypted string `crypt_str' using `pass_str' as the
  27505.      password.  `crypt_str' should be a string returned from `ENCODE()'.
  27506.  
  27507. `MD5(string)'
  27508.      Calculates a MD5 checksum for the string. Value is returned as a
  27509.      32 long hex number that may, for example, be used as a hash key:
  27510.  
  27511.           mysql> select MD5("testing");
  27512.                   -> 'ae2b1fca515949e5d54fb22b8ed95575'
  27513.  
  27514.      This is an "RSA Data Security, Inc. MD5 Message-Digest Algorithm".
  27515.  
  27516. `LAST_INSERT_ID([expr])'
  27517.      Returns the last automatically generated value that was inserted
  27518.      into an `AUTO_INCREMENT' column.  *Note `mysql_insert_id()':
  27519.      mysql_insert_id.
  27520.  
  27521.           mysql> select LAST_INSERT_ID();
  27522.                   -> 195
  27523.  
  27524.      The last ID that was generated is maintained in the server on a
  27525.      per-connection basis.  It will not be changed by another client.
  27526.      It will not even be changed if you update another `AUTO_INCREMENT'
  27527.      column with a non-magic value (that is, a value that is not `NULL'
  27528.      and not `0').
  27529.  
  27530.      If you insert many rows at the same time with an insert statement,
  27531.      `LAST_INSERT_ID()' returns the value for the first inserted row.
  27532.      The reason for this is so that you it makes it possible to easily
  27533.      reproduce the same `INSERT' statement against some other server.
  27534.  
  27535.      If `expr' is given as an argument to `LAST_INSERT_ID()', then the
  27536.      value of the argument is returned by the function, is set as the
  27537.      next value to be returned by `LAST_INSERT_ID()' and used as the
  27538.      next auto_increment value.  This can be used to simulate sequences:
  27539.  
  27540.      First create the table:
  27541.  
  27542.           mysql> create table sequence (id int not null);
  27543.           mysql> insert into sequence values (0);
  27544.  
  27545.      Then the table can be used to generate sequence numbers like this:
  27546.  
  27547.           mysql> update sequence set id=LAST_INSERT_ID(id+1);
  27548.  
  27549.      You can generate sequences without calling `LAST_INSERT_ID()', but
  27550.      the utility of using the function this way is that the ID value is
  27551.      maintained in the server as the last automatically generated
  27552.      value.  You can retrieve the new ID as you would read any normal
  27553.      `AUTO_INCREMENT' value in MySQL.  For example, `LAST_INSERT_ID()'
  27554.      (without an argument) will return the new ID.  The C API function
  27555.      `mysql_insert_id()' can also be used to get the value.
  27556.  
  27557.      Note that as `mysql_insert_id()' is only updated after `INSERT'
  27558.      and `UPDATE' statements, you can't use this function to retrieve
  27559.      the value for `LAST_INSERT_ID(expr)' after executing other SQL
  27560.      statements like `SELECT' or `SET'.
  27561.  
  27562. `FORMAT(X,D)'
  27563.      Formats the number `X' to a format like `'#,###,###.##'', rounded
  27564.      to `D' decimals.  If `D' is `0', the result will have no decimal
  27565.      point or fractional part:
  27566.  
  27567.           mysql> select FORMAT(12332.123456, 4);
  27568.                   -> '12,332.1235'
  27569.           mysql> select FORMAT(12332.1,4);
  27570.                   -> '12,332.1000'
  27571.           mysql> select FORMAT(12332.2,0);
  27572.                   -> '12,332'
  27573.  
  27574. `VERSION()'
  27575.      Returns a string indicating the MySQL server version:
  27576.  
  27577.           mysql> select VERSION();
  27578.                   -> '3.23.13-log'
  27579.  
  27580.      Note that if your version ends with `-log' this means that logging
  27581.      is enabled.
  27582.  
  27583. `CONNECTION_ID()'
  27584.      Returns the connection id (`thread_id') for the connection.  Every
  27585.      connection has its own unique id:
  27586.  
  27587.           mysql> select CONNECTION_ID();
  27588.                   -> 1
  27589.  
  27590. `GET_LOCK(str,timeout)'
  27591.      Tries to obtain a lock with a name given by the string `str', with
  27592.      a timeout of `timeout' seconds.  Returns `1' if the lock was
  27593.      obtained successfully, `0' if the attempt timed out, or `NULL' if
  27594.      an error occurred (such as running out of memory or the thread was
  27595.      killed with `mysqladmin kill').  A lock is released when you
  27596.      execute `RELEASE_LOCK()', execute a new `GET_LOCK()', or the thread
  27597.      terminates.  This function can be used to implement application
  27598.      locks or to simulate record locks.  It blocks requests by other
  27599.      clients for locks with the same name; clients that agree on a
  27600.      given lock string name can use the string to perform cooperative
  27601.      advisory locking:
  27602.  
  27603.           mysql> select GET_LOCK("lock1",10);
  27604.                   -> 1
  27605.           mysql> select GET_LOCK("lock2",10);
  27606.                   -> 1
  27607.           mysql> select RELEASE_LOCK("lock2");
  27608.                   -> 1
  27609.           mysql> select RELEASE_LOCK("lock1");
  27610.                   -> NULL
  27611.  
  27612.      Note that the second `RELEASE_LOCK()' call returns `NULL' because
  27613.      the lock `"lock1"' was automatically released by the second
  27614.      `GET_LOCK()' call.
  27615.  
  27616. `RELEASE_LOCK(str)'
  27617.      Releases the lock named by the string `str' that was obtained with
  27618.      `GET_LOCK()'. Returns `1' if the lock was released, `0' if the
  27619.      lock wasn't locked by this thread (in which case the lock is not
  27620.      released), and `NULL' if the named lock didn't exist.  The lock
  27621.      will not exist if it was never obtained by a call to `GET_LOCK()'
  27622.      or if it already has been released.
  27623.  
  27624.      The `DO' statement is convinient to use with `RELEASE_LOCK()'.
  27625.      *Note DO::.
  27626.  
  27627. `BENCHMARK(count,expr)'
  27628.      The `BENCHMARK()' function executes the expression `expr'
  27629.      repeatedly `count' times.  It may be used to time how fast MySQL
  27630.      processes the expression.  The result value is always `0'.  The
  27631.      intended use is in the `mysql' client, which reports query
  27632.      execution times:
  27633.  
  27634.           mysql> select BENCHMARK(1000000,encode("hello","goodbye"));
  27635.           +----------------------------------------------+
  27636.           | BENCHMARK(1000000,encode("hello","goodbye")) |
  27637.           +----------------------------------------------+
  27638.           |                                            0 |
  27639.           +----------------------------------------------+
  27640.           1 row in set (4.74 sec)
  27641.  
  27642.      The time reported is elapsed time on the client end, not CPU time
  27643.      on the server end.  It may be advisable to execute `BENCHMARK()'
  27644.      several times, and interpret the result with regard to how heavily
  27645.      loaded the server machine is.
  27646.  
  27647. `INET_NTOA(expr)'
  27648.      Returns the network address (4 or 8 byte) for the numeric
  27649.      expression:
  27650.  
  27651.           mysql> select INET_NTOA(3520061480);
  27652.                  ->  "209.207.224.40"
  27653.  
  27654. `INET_ATON(expr)'
  27655.      Returns an integer that represents the numeric value for a network
  27656.      address.  Addresses may be 4 or 8 byte addresses:
  27657.  
  27658.           mysql> select INET_ATON("209.207.224.40");
  27659.                  ->  3520061480
  27660.  
  27661.      The generated number is always in network byte order; For example
  27662.      the above number is calculated as `209*256^3 + 207*256^2 + 224*256
  27663.      +40'.
  27664.  
  27665. `MASTER_POS_WAIT(log_name, log_pos)'
  27666.      Blocks until the slave reaches the specified position in the
  27667.      master log during replication. If master information is not
  27668.      initialized, returns NULL. If the slave is not running, will block
  27669.      and wait until it is started and goes to or past the specified
  27670.      position. If the slave is already past the specified position,
  27671.      returns immediately. The return value is the number of log events
  27672.      it had to wait to get to the specified position, or NULL in case
  27673.      of error. Useful for control of master-slave synchronization, but
  27674.      was originally written to facilitate replication testing.
  27675.  
  27676. 
  27677. File: mysql.info,  Node: Data Manipulation,  Next: Data Definition,  Prev: Functions,  Up: Reference
  27678.  
  27679. Data Manipulation: `SELECT', `INSERT', `UPDATE', `DELETE'
  27680. =========================================================
  27681.  
  27682. * Menu:
  27683.  
  27684. * SELECT::                      `SELECT' Syntax
  27685. * INSERT::                      `INSERT' Syntax
  27686. * INSERT DELAYED::              `INSERT DELAYED' syntax
  27687. * UPDATE::                      `UPDATE' Syntax
  27688. * DELETE::                      `DELETE' Syntax
  27689. * TRUNCATE::                    `TRUNCATE' Syntax
  27690. * REPLACE::                     `REPLACE' Syntax
  27691. * LOAD DATA::                   `LOAD DATA INFILE' Syntax
  27692. * DO::                          `DO' Syntax
  27693.  
  27694. 
  27695. File: mysql.info,  Node: SELECT,  Next: INSERT,  Prev: Data Manipulation,  Up: Data Manipulation
  27696.  
  27697. `SELECT' Syntax
  27698. ---------------
  27699.  
  27700.      SELECT [STRAIGHT_JOIN] [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
  27701.             [HIGH_PRIORITY]
  27702.             [DISTINCT | DISTINCTROW | ALL]
  27703.          select_expression,...
  27704.          [INTO {OUTFILE | DUMPFILE} 'file_name' export_options]
  27705.          [FROM table_references
  27706.              [WHERE where_definition]
  27707.              [GROUP BY {unsigned_integer | col_name | formula} [ASC | DESC], ...]
  27708.              [HAVING where_definition]
  27709.              [ORDER BY {unsigned_integer | col_name | formula} [ASC | DESC] ,...]
  27710.              [LIMIT [offset,] rows]
  27711.              [PROCEDURE procedure_name]
  27712.              [FOR UPDATE | LOCK IN SHARE MODE]]
  27713.  
  27714. `SELECT' is used to retrieve rows selected from one or more tables.
  27715. `select_expression' indicates the columns you want to retrieve.
  27716. `SELECT' may also be used to retrieve rows computed without reference to
  27717. any table.  For example:
  27718.  
  27719.      mysql> SELECT 1 + 1;
  27720.               -> 2
  27721.  
  27722. All keywords used must be given in exactly the order shown above. For
  27723. example, a `HAVING' clause must come after any `GROUP BY' clause and
  27724. before any `ORDER BY' clause.
  27725.  
  27726.    * A `SELECT' expression may be given an alias using `AS'. The alias
  27727.      is used as the expression's column name and can be used with
  27728.      `ORDER BY' or `HAVING' clauses.  For example:
  27729.  
  27730.           mysql> select concat(last_name,', ',first_name) AS full_name
  27731.               from mytable ORDER BY full_name;
  27732.  
  27733.    * The `FROM table_references' clause indicates the tables from which
  27734.      to retrieve rows.  If you name more than one table, you are
  27735.      performing a join.  For information on join syntax, see *Note
  27736.      `JOIN': JOIN.
  27737.  
  27738.    * You can refer to a column as `col_name', `tbl_name.col_name', or
  27739.      `db_name.tbl_name.col_name'.  You need not specify a `tbl_name' or
  27740.      `db_name.tbl_name' prefix for a column reference in a `SELECT'
  27741.      statement unless the reference would be ambiguous.  See *Note
  27742.      Legal names::, for examples of ambiguity that require the more
  27743.      explicit column reference forms.
  27744.  
  27745.    * A table reference may be aliased using `tbl_name [AS] alias_name':
  27746.  
  27747.           mysql> select t1.name, t2.salary from employee AS t1, info AS t2
  27748.                      where t1.name = t2.name;
  27749.           mysql> select t1.name, t2.salary from employee t1, info t2
  27750.                      where t1.name = t2.name;
  27751.  
  27752.    * Columns selected for output may be referred to in `ORDER BY' and
  27753.      `GROUP BY' clauses using column names, column aliases, or column
  27754.      positions.  Column positions begin with 1:
  27755.  
  27756.           mysql> select college, region, seed from tournament
  27757.                      ORDER BY region, seed;
  27758.           mysql> select college, region AS r, seed AS s from tournament
  27759.                      ORDER BY r, s;
  27760.           mysql> select college, region, seed from tournament
  27761.                      ORDER BY 2, 3;
  27762.  
  27763.      To sort in reverse order, add the `DESC' (descending) keyword to
  27764.      the name of the column in the `ORDER BY' clause that you are
  27765.      sorting by.  The default is ascending order; this may be specified
  27766.      explicitly using the `ASC' keyword.
  27767.  
  27768.    * You can in the `WHERE' clause use any of the functions that MySQL
  27769.      support. *Note Functions::.
  27770.  
  27771.    * The `HAVING' clause can refer to any column or alias named in the
  27772.      `select_expression'. It is applied last, just before items are
  27773.      sent to the client, with no optimization. Don't use `HAVING' for
  27774.      items that should be in the `WHERE' clause.  For example, do not
  27775.      write this:
  27776.  
  27777.           mysql> select col_name from tbl_name HAVING col_name > 0;
  27778.  
  27779.      Write this instead:
  27780.  
  27781.           mysql> select col_name from tbl_name WHERE col_name > 0;
  27782.  
  27783.      In MySQL Version 3.22.5 or later, you can also write queries like
  27784.      this:
  27785.  
  27786.           mysql> select user,max(salary) from users
  27787.                      group by user HAVING max(salary)>10;
  27788.  
  27789.      In older MySQL versions, you can write this instead:
  27790.  
  27791.           mysql> select user,max(salary) AS sum from users
  27792.                      group by user HAVING sum>10;
  27793.  
  27794.    * `SQL_SMALL_RESULT', `SQL_BIG_RESULT', `SQL_BUFFER_RESULT',
  27795.      `STRAIGHT_JOIN', and `HIGH_PRIORITY' are MySQL extensions to ANSI
  27796.      SQL92.
  27797.  
  27798.    * `HIGH_PRIORITY' will give the `SELECT' higher priority than a
  27799.      statement that updates a table.  You should only use this for
  27800.      queries that are very fast and must be done at once.  A `SELECT
  27801.      HIGH_PRIORITY' query will run if the table is locked for read even
  27802.      if there is an update statement that is waiting for the table to
  27803.      be free.
  27804.  
  27805.    * `SQL_BIG_RESULT' can be used with `GROUP BY' or `DISTINCT' to tell
  27806.      the optimizer that the result set will have many rows.  In this
  27807.      case, MySQL will directly use disk-based temporary tables if
  27808.      needed.  MySQL will also, in this case, prefer sorting to doing a
  27809.      temporary table with a key on the `GROUP BY' elements.
  27810.  
  27811.    * `SQL_BUFFER_RESULT' will force the result to be put into a
  27812.      temporary table. This will help MySQL free the table locks early
  27813.      and will help in cases where it takes a long time to send the
  27814.      result set to the client.
  27815.  
  27816.    * `SQL_SMALL_RESULT', a MySQL-specific option, can be used with
  27817.      `GROUP BY' or `DISTINCT' to tell the optimizer that the result set
  27818.      will be small.  In this case, MySQL will use fast temporary tables
  27819.      to store the resulting table instead of using sorting. In MySQL
  27820.      Version 3.23 this shouldn't normally be needed.
  27821.  
  27822.    * If you use `GROUP BY', the output rows will be sorted according to
  27823.      the `GROUP BY' as if you would have had an `ORDER BY' over all the
  27824.      fields in the `GROUP BY'. MySQL has extended the `GROUP BY' so that
  27825.      you can also specify `ASC' and `DESC' to `GROUP BY':
  27826.  
  27827.           SELECT a,COUNT(b) FROM test_table GROUP BY a DESC
  27828.  
  27829.    * MySQL has extended the use of `GROUP BY' to allow you to select
  27830.      fields which are not mentioned in the `GROUP BY' clause.  If you
  27831.      are not getting the results you expect from your query, please
  27832.      read the `GROUP BY' description.  *Note Group by functions::.
  27833.  
  27834.    * `STRAIGHT_JOIN' forces the optimizer to join the tables in the
  27835.      order in which they are listed in the `FROM' clause. You can use
  27836.      this to speed up a query if the optimizer joins the tables in
  27837.      non-optimal order.  *Note `EXPLAIN': EXPLAIN.
  27838.  
  27839.    * The `LIMIT' clause can be used to constrain the number of rows
  27840.      returned by the `SELECT' statement.  `LIMIT' takes one or two
  27841.      numeric arguments.
  27842.  
  27843.      If two arguments are given, the first specifies the offset of the
  27844.      first row to return, the second specifies the maximum number of
  27845.      rows to return.  The offset of the initial row is 0 (not 1):
  27846.  
  27847.           mysql> select * from table LIMIT 5,10;  # Retrieve rows 6-15
  27848.  
  27849.      If one argument is given, it indicates the maximum number of rows
  27850.      to return:
  27851.  
  27852.           mysql> select * from table LIMIT 5;     # Retrieve first 5 rows
  27853.  
  27854.      In other words, `LIMIT n' is equivalent to `LIMIT 0,n'.
  27855.  
  27856.    * The `SELECT ... INTO OUTFILE 'file_name'' form of `SELECT' writes
  27857.      the selected rows to a file. The file is created on the server
  27858.      host and cannot already exist (among other things, this prevents
  27859.      database tables and files such as `/etc/passwd' from being
  27860.      destroyed).  You must have the *file* privilege on the server host
  27861.      to use this form of `SELECT'.
  27862.  
  27863.      `SELECT ... INTO OUTFILE' is mainly intended to let you very
  27864.      quickly dump a table on the server machine. If you want to create
  27865.      the resulting file on some other host than the server host you
  27866.      can't use `SELECT ... INTO OUTFILE'. In this case you should
  27867.      instead use some client program like `mysqldump --tab' or `mysql
  27868.      -e "SELECT ..." > outfile' to generate the file.
  27869.  
  27870.      `SELECT ...  INTO OUTFILE' is the complement of `LOAD DATA
  27871.      INFILE'; the syntax for the `export_options' part of the statement
  27872.      consists of the same `FIELDS' and `LINES' clauses that are used
  27873.      with the `LOAD DATA INFILE' statement.  *Note `LOAD DATA': LOAD
  27874.      DATA.
  27875.  
  27876.      In the resulting text file, only the following characters are
  27877.      escaped by the `ESCAPED BY' character:
  27878.  
  27879.         * The `ESCAPED BY' character
  27880.  
  27881.         * The first character in `FIELDS TERMINATED BY'
  27882.  
  27883.         * The first character in `LINES TERMINATED BY'
  27884.  
  27885.      Additionally, `ASCII 0' is converted to `ESCAPED BY' followed by 0
  27886.      (`ASCII 48').
  27887.  
  27888.      The reason for the above is that you MUST escape any `FIELDS
  27889.      TERMINATED BY', `ESCAPED BY', or `LINES TERMINATED BY' characters
  27890.      to reliably be able to read the file back. `ASCII 0' is escaped to
  27891.      make it easier to view with some pagers.
  27892.  
  27893.      As the resulting file doesn't have to conform to the SQL syntax,
  27894.      nothing else need be escaped.
  27895.  
  27896.      Here follows an example of getting a file in the format used by
  27897.      many old programs.
  27898.  
  27899.           SELECT a,b,a+b INTO OUTFILE "/tmp/result.text"
  27900.           FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
  27901.           LINES TERMINATED BY "\n"
  27902.           FROM test_table;
  27903.  
  27904.    * If you use `INTO DUMPFILE' instead of `INTO OUTFILE', MySQL will
  27905.      only write one row into the file, without any column or line
  27906.      terminations and without any escaping.  This is useful if you want
  27907.      to store a blob in a file.
  27908.  
  27909.    * Note that any file created by `INTO OUTFILE' and `INTO DUMPFILE'
  27910.      is going to be readable for all users!  The reason is that the
  27911.      MySQL server can't create a file that is owned by anyone else than
  27912.      the user it's running as (you should never run `mysqld' as root),
  27913.      the file has to be word readable so that you can retrieve the rows.
  27914.  
  27915.    * If you are using `FOR UPDATE' on a table handler with page/row
  27916.      locks, the examined rows will be write locked.
  27917.  
  27918. * Menu:
  27919.  
  27920. * JOIN::                        `JOIN' Syntax
  27921.  
  27922. 
  27923. File: mysql.info,  Node: JOIN,  Prev: SELECT,  Up: SELECT
  27924.  
  27925. `JOIN' Syntax
  27926. .............
  27927.  
  27928. MySQL supports the following `JOIN' syntaxes for use in `SELECT'
  27929. statements:
  27930.  
  27931.      table_reference, table_reference
  27932.      table_reference [CROSS] JOIN table_reference
  27933.      table_reference INNER JOIN table_reference join_condition
  27934.      table_reference STRAIGHT_JOIN table_reference
  27935.      table_reference LEFT [OUTER] JOIN table_reference join_condition
  27936.      table_reference LEFT [OUTER] JOIN table_reference
  27937.      table_reference NATURAL [LEFT [OUTER]] JOIN table_reference
  27938.      { oj table_reference LEFT OUTER JOIN table_reference ON conditional_expr }
  27939.      table_reference RIGHT [OUTER] JOIN table_reference join_condition
  27940.      table_reference RIGHT [OUTER] JOIN table_reference
  27941.      table_reference NATURAL [RIGHT [OUTER]] JOIN table_reference
  27942.  
  27943. Where `table_reference' is defined as:
  27944.      table_name [[AS] alias] [USE INDEX (key_list)] [IGNORE INDEX (key_list)]
  27945.  
  27946. and `join_condition' is defined as:
  27947.  
  27948.      ON conditional_expr |
  27949.      USING (column_list)
  27950.  
  27951. You should never have any conditions in the `ON' part that are used to
  27952. restrict which rows you have in the result set.  If you want to restrict
  27953. which rows should be in the result, you have to do this in the `WHERE'
  27954. clause.
  27955.  
  27956. Note that in versions before Version 3.23.17, the `INNER JOIN' didn't
  27957. take a `join_condition'!
  27958.  
  27959. The last `LEFT OUTER JOIN' syntax shown above exists only for
  27960. compatibility with ODBC:
  27961.  
  27962.    * A table reference may be aliased using `tbl_name AS alias_name' or
  27963.      `tbl_name alias_name':
  27964.  
  27965.           mysql> select t1.name, t2.salary from employee AS t1, info AS t2
  27966.                      where t1.name = t2.name;
  27967.  
  27968.    * The `ON' conditional is any conditional of the form that may be
  27969.      used in a `WHERE' clause.
  27970.  
  27971.    * If there is no matching record for the right table in the `ON' or
  27972.      `USING' part in a `LEFT JOIN', a row with all columns set to
  27973.      `NULL' is used for the right table.  You can use this fact to find
  27974.      records in a table that have no counterpart in another table:
  27975.  
  27976.           mysql> select table1.* from table1
  27977.                      LEFT JOIN table2 ON table1.id=table2.id
  27978.                      where table2.id is NULL;
  27979.  
  27980.      This example finds all rows in `table1' with an `id' value that is
  27981.      not present in `table2' (that is, all rows in `table1' with no
  27982.      corresponding row in `table2').  This assumes that `table2.id' is
  27983.      declared `NOT NULL', of course. *Note LEFT JOIN optimization::.
  27984.  
  27985.    * The `USING' `(column_list)' clause names a list of columns that
  27986.      must exist in both tables.  A `USING' clause such as:
  27987.  
  27988.           A LEFT JOIN B USING (C1,C2,C3,...)
  27989.  
  27990.      is defined to be semantically identical to an `ON' expression like
  27991.      this:
  27992.  
  27993.           A.C1=B.C1 AND A.C2=B.C2 AND A.C3=B.C3,...
  27994.  
  27995.    * The `NATURAL [LEFT] JOIN' of two tables is defined to be
  27996.      semantically equivalent to an `INNER JOIN' or a `LEFT JOIN' with a
  27997.      `USING' clause that names all columns that exist in both tables.
  27998.  
  27999.    * `RIGHT JOIN' works analogously as `LEFT JOIN'.  To keep code
  28000.      portable across databases, it's recommended to use `LEFT JOIN'
  28001.      instead of `RIGHT JOIN'.
  28002.  
  28003.    * `STRAIGHT_JOIN' is identical to `JOIN', except that the left table
  28004.      is always read before the right table. This can be used for those
  28005.      (few) cases where the join optimizer puts the tables in the wrong
  28006.      order.
  28007.  
  28008.    * As of MySQL Version 3.23.12, you can give hints about which index
  28009.      MySQL should use when retrieving information from a table. This is
  28010.      useful if `EXPLAIN' shows that MySQL is using the wrong index.  By
  28011.      specifying `USE INDEX (key_list)', you can tell MySQL to use only
  28012.      one of the specified indexes to find rows in the table.  The
  28013.      alternative syntax `IGNORE INDEX (key_list)' can be used to tell
  28014.      MySQL to not use some particular index.
  28015.  
  28016. Some examples:
  28017.  
  28018.      mysql> select * from table1,table2 where table1.id=table2.id;
  28019.      mysql> select * from table1 LEFT JOIN table2 ON table1.id=table2.id;
  28020.      mysql> select * from table1 LEFT JOIN table2 USING (id);
  28021.      mysql> select * from table1 LEFT JOIN table2 ON table1.id=table2.id
  28022.                 LEFT JOIN table3 ON table2.id=table3.id;
  28023.      mysql> select * from table1 USE INDEX (key1,key2) WHERE key1=1 and key2=2 AND
  28024.             key3=3;
  28025.      mysql> select * from table1 IGNORE INDEX (key3) WHERE key1=1 and key2=2 AND
  28026.             key3=3;
  28027.  
  28028. *Note `LEFT JOIN' optimization: LEFT JOIN optimization.
  28029.  
  28030. 
  28031. File: mysql.info,  Node: INSERT,  Next: INSERT DELAYED,  Prev: SELECT,  Up: Data Manipulation
  28032.  
  28033. `INSERT' Syntax
  28034. ---------------
  28035.  
  28036.          INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
  28037.              [INTO] tbl_name [(col_name,...)]
  28038.              VALUES (expression,...),(...),...
  28039.      or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
  28040.              [INTO] tbl_name [(col_name,...)]
  28041.              SELECT ...
  28042.      or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
  28043.              [INTO] tbl_name
  28044.              SET col_name=expression, col_name=expression, ...
  28045.  
  28046. `INSERT' inserts new rows into an existing table.  The `INSERT ...
  28047. VALUES' form of the statement inserts rows based on explicitly
  28048. specified values.  The `INSERT ... SELECT' form inserts rows selected
  28049. from another table or tables.  The `INSERT ... VALUES' form with
  28050. multiple value lists is supported in MySQL Version 3.22.5 or later.
  28051. The `col_name=expression' syntax is supported in MySQL Version 3.22.10
  28052. or later.
  28053.  
  28054. `tbl_name' is the table into which rows should be inserted.  The column
  28055. name list or the `SET' clause indicates which columns the statement
  28056. specifies values for:
  28057.  
  28058.    * If you specify no column list for `INSERT ... VALUES' or `INSERT
  28059.      ... SELECT', values for all columns must be provided in the
  28060.      `VALUES()' list or by the `SELECT'.  If you don't know the order of
  28061.      the columns in the table, use `DESCRIBE tbl_name' to find out.
  28062.  
  28063.    * Any column not explicitly given a value is set to its default
  28064.      value.  For example, if you specify a column list that doesn't
  28065.      name all the columns in the table, unnamed columns are set to
  28066.      their default values.  Default value assignment is described in
  28067.      *Note `CREATE TABLE': CREATE TABLE.
  28068.  
  28069.    * An `expression' may refer to any column that was set earlier in a
  28070.      value list.  For example, you can say this:
  28071.  
  28072.           mysql> INSERT INTO tbl_name (col1,col2) VALUES(15,col1*2);
  28073.  
  28074.      But not this:
  28075.  
  28076.           mysql> INSERT INTO tbl_name (col1,col2) VALUES(col2*2,15);
  28077.  
  28078.    * If you specify the keyword `LOW_PRIORITY', execution of the
  28079.      `INSERT' is delayed until no other clients are reading from the
  28080.      table.  In this case the client has to wait until the insert
  28081.      statement is completed, which may take a long time if the table is
  28082.      in heavy use. This is in contrast to `INSERT DELAYED', which lets
  28083.      the client continue at once.  *Note INSERT DELAYED::.  Note that
  28084.      `LOW_PRIORITY' should normally not be used with `MyISAM' tables as
  28085.      this disables concurrent inserts. *Note MyISAM::.
  28086.  
  28087.    * If you specify the keyword `IGNORE' in an `INSERT' with many value
  28088.      rows, any rows that duplicate an existing `PRIMARY' or `UNIQUE'
  28089.      key in the table are ignored and are not inserted.  If you do not
  28090.      specify `IGNORE', the insert is aborted if there is any row that
  28091.      duplicates an existing key value.  You can determine with the C
  28092.      API function `mysql_info()' how many rows were inserted into the
  28093.      table.
  28094.  
  28095.    * If MySQL was configured using the `DONT_USE_DEFAULT_FIELDS'
  28096.      option, `INSERT' statements generate an error unless you explicitly
  28097.      specify values for all columns that require a non-`NULL' value.
  28098.      *Note `configure' options: configure options.
  28099.  
  28100.    * You can find the value used for an `AUTO_INCREMENT' column with
  28101.      the `mysql_insert_id' function.  *Note `mysql_insert_id()':
  28102.      mysql_insert_id.
  28103.  
  28104. If you use `INSERT ... SELECT' or an `INSERT ... VALUES' statement with
  28105. multiple value lists, you can use the C API function `mysql_info()' to
  28106. get information about the query.  The format of the information string
  28107. is shown below:
  28108.  
  28109.      Records: 100 Duplicates: 0 Warnings: 0
  28110.  
  28111. `Duplicates' indicates the number of rows that couldn't be inserted
  28112. because they would duplicate some existing unique index value.
  28113. `Warnings' indicates the number of attempts to insert column values that
  28114. were problematic in some way. Warnings can occur under any of the
  28115. following conditions:
  28116.  
  28117.    * Inserting `NULL' into a column that has been declared `NOT NULL'.
  28118.      The column is set to its default value.
  28119.  
  28120.    * Setting a numeric column to a value that lies outside the column's
  28121.      range.  The value is clipped to the appropriate endpoint of the
  28122.      range.
  28123.  
  28124.    * Setting a numeric column to a value such as `'10.34 a''.  The
  28125.      trailing garbage is stripped and the remaining numeric part is
  28126.      inserted.  If the value doesn't make sense as a number at all, the
  28127.      column is set to `0'.
  28128.  
  28129.    * Inserting a string into a `CHAR', `VARCHAR', `TEXT', or `BLOB'
  28130.      column that exceeds the column's maximum length.  The value is
  28131.      truncated to the column's maximum length.
  28132.  
  28133.    * Inserting a value into a date or time column that is illegal for
  28134.      the column type.  The column is set to the appropriate zero value
  28135.      for the type.
  28136.  
  28137. * Menu:
  28138.  
  28139. * INSERT SELECT::               `INSERT ... SELECT' Syntax
  28140.  
  28141. 
  28142. File: mysql.info,  Node: INSERT SELECT,  Prev: INSERT,  Up: INSERT
  28143.  
  28144. `INSERT ... SELECT' Syntax
  28145. ..........................
  28146.  
  28147.      INSERT [LOW_PRIORITY] [IGNORE] [INTO] tbl_name [(column list)] SELECT ...
  28148.  
  28149. With `INSERT ... SELECT' statement you can quickly insert many rows
  28150. into a table from one or many tables.
  28151.  
  28152.      INSERT INTO tblTemp2 (fldID) SELECT tblTemp1.fldOrder_ID FROM tblTemp1 WHERE
  28153.      tblTemp1.fldOrder_ID > 100;
  28154.  
  28155. The following conditions hold for an `INSERT ... SELECT' statement:
  28156.  
  28157.    - The target table of the `INSERT' statement cannot appear in the
  28158.      `FROM' clause of the `SELECT' part of the query because it's
  28159.      forbidden in ANSI SQL to `SELECT' from the same table into which
  28160.      you are inserting.  (The problem is that the `SELECT' possibly
  28161.      would find records that were inserted earlier during the same run.
  28162.      When using sub-select clauses, the situation could easily be very
  28163.      confusing!)
  28164.  
  28165.    - `AUTO_INCREMENT' columns work as usual.
  28166.  
  28167.    - You can use the C API function `mysql_info()' to get information
  28168.      about the query. *Note INSERT::.
  28169.  
  28170.    - To ensure that the update log/binary log can be used to re-create
  28171.      the original tables, MySQL will not allow concurrent inserts during
  28172.      `INSERT .... SELECT'.
  28173.  
  28174. You can of course also use `REPLACE' instead of `INSERT' to overwrite
  28175. old rows.
  28176.  
  28177. 
  28178. File: mysql.info,  Node: INSERT DELAYED,  Next: UPDATE,  Prev: INSERT,  Up: Data Manipulation
  28179.  
  28180. `INSERT DELAYED' syntax
  28181. -----------------------
  28182.  
  28183.      INSERT DELAYED ...
  28184.  
  28185. The `DELAYED' option for the `INSERT' statement is a MySQL-specific
  28186. option that is very useful if you have clients that can't wait for the
  28187. `INSERT' to complete.  This is a common problem when you use MySQL for
  28188. logging and you also periodically run `SELECT' and `UPDATE' statements
  28189. that take a long time to complete.  `DELAYED' was introduced in MySQL
  28190. Version 3.22.15.  It is a MySQL extension to ANSI SQL92.
  28191.  
  28192. `INSERT DELAYED' only works with `ISAM' and `MyISAM' tables.  Note that
  28193. as `MyISAM' tables supports concurrent `SELECT' and `INSERT', if there
  28194. is no free blocks in the middle of the data file, you very seldom need
  28195. to use `INSERT DELAYED' with `MyISAM'. *Note MyISAM::.
  28196.  
  28197. When you use `INSERT DELAYED', the client will get an OK at once and
  28198. the row will be inserted when the table is not in use by any other
  28199. thread.
  28200.  
  28201. Another major benefit of using `INSERT DELAYED' is that inserts from
  28202. many clients are bundled together and written in one block. This is much
  28203. faster than doing many separate inserts.
  28204.  
  28205. Note that currently the queued rows are only stored in memory until
  28206. they are inserted into the table.  This means that if you kill `mysqld'
  28207. the hard way (`kill -9') or if `mysqld' dies unexpectedly, any queued
  28208. rows that weren't written to disk are lost!
  28209.  
  28210. The following describes in detail what happens when you use the
  28211. `DELAYED' option to `INSERT' or `REPLACE'.  In this description, the
  28212. "thread" is the thread that received an `INSERT DELAYED' command and
  28213. "handler" is the thread that handles all `INSERT DELAYED' statements
  28214. for a particular table.
  28215.  
  28216.    * When a thread executes a `DELAYED' statement for a table, a handler
  28217.      thread is created to process all `DELAYED' statements for the
  28218.      table, if no such handler already exists.
  28219.  
  28220.    * The thread checks whether or not the handler has acquired a
  28221.      `DELAYED' lock already; if not, it tells the handler thread to do
  28222.      so.  The `DELAYED' lock can be obtained even if other threads have
  28223.      a `READ' or `WRITE' lock on the table.  However, the handler will
  28224.      wait for all `ALTER TABLE' locks or `FLUSH TABLES' to ensure that
  28225.      the table structure is up to date.
  28226.  
  28227.    * The thread executes the `INSERT' statement, but instead of writing
  28228.      the row to the table, it puts a copy of the final row into a queue
  28229.      that is managed by the handler thread. Any syntax errors are
  28230.      noticed by the thread and reported to the client program.
  28231.  
  28232.    * The client can't report the number of duplicates or the
  28233.      `AUTO_INCREMENT' value for the resulting row; it can't obtain them
  28234.      from the server, because the `INSERT' returns before the insert
  28235.      operation has been completed.  If you use the C API, the
  28236.      `mysql_info()' function doesn't return anything meaningful, for
  28237.      the same reason.
  28238.  
  28239.    * The update log is updated by the handler thread when the row is
  28240.      inserted into the table.  In case of multiple-row inserts, the
  28241.      update log is updated when the first row is inserted.
  28242.  
  28243.    * After every `delayed_insert_limit' rows are written, the handler
  28244.      checks whether or not any `SELECT' statements are still pending.
  28245.      If so, it allows these to execute before continuing.
  28246.  
  28247.    * When the handler has no more rows in its queue, the table is
  28248.      unlocked.  If no new `INSERT DELAYED' commands are received within
  28249.      `delayed_insert_timeout' seconds, the handler terminates.
  28250.  
  28251.    * If more than `delayed_queue_size' rows are pending already in a
  28252.      specific handler queue, the thread requesting `INSERT DELAYED'
  28253.      waits until there is room in the queue.  This is done to ensure
  28254.      that the `mysqld' server doesn't use all memory for the delayed
  28255.      memory queue.
  28256.  
  28257.    * The handler thread will show up in the MySQL process list with
  28258.      `delayed_insert' in the `Command' column.  It will be killed if
  28259.      you execute a `FLUSH TABLES' command or kill it with `KILL
  28260.      thread_id'. However, it will first store all queued rows into the
  28261.      table before exiting. During this time it will not accept any new
  28262.      `INSERT' commands from another thread. If you execute an `INSERT
  28263.      DELAYED' command after this, a new handler thread will be created.
  28264.  
  28265.    * Note that the above means that `INSERT DELAYED' commands have
  28266.      higher priority than normal `INSERT' commands if there is an
  28267.      `INSERT DELAYED' handler already running!  Other update commands
  28268.      will have to wait until the `INSERT DELAYED' queue is empty,
  28269.      someone kills the handler thread (with `KILL thread_id'), or
  28270.      someone executes `FLUSH TABLES'.
  28271.  
  28272.    * The following status variables provide information about `INSERT
  28273.      DELAYED' commands:
  28274.  
  28275.      *Variable*              *Meaning*
  28276.      `Delayed_insert_threads'Number of handler threads
  28277.      `Delayed_writes'        Number of rows written with `INSERT DELAYED'
  28278.      `Not_flushed_delayed_rows'Number of rows waiting to be written
  28279.  
  28280.      You can view these variables by issuing a `SHOW STATUS' statement
  28281.      or by executing a `mysqladmin extended-status' command.
  28282.  
  28283. Note that `INSERT DELAYED' is slower than a normal INSERT if the table
  28284. is not in use.  There is also the additional overhead for the server to
  28285. handle a separate thread for each table on which you use `INSERT
  28286. DELAYED'.  This means that you should only use `INSERT DELAYED' when
  28287. you are really sure you need it!
  28288.  
  28289. 
  28290. File: mysql.info,  Node: UPDATE,  Next: DELETE,  Prev: INSERT DELAYED,  Up: Data Manipulation
  28291.  
  28292. `UPDATE' Syntax
  28293. ---------------
  28294.  
  28295.      UPDATE [LOW_PRIORITY] [IGNORE] tbl_name
  28296.          SET col_name1=expr1, [col_name2=expr2, ...]
  28297.          [WHERE where_definition]
  28298.          [LIMIT #]
  28299.  
  28300. `UPDATE' updates columns in existing table rows with new values.  The
  28301. `SET' clause indicates which columns to modify and the values they
  28302. should be given.  The `WHERE' clause, if given, specifies which rows
  28303. should be updated.  Otherwise all rows are updated. If the `ORDER BY'
  28304. clause is specified, the rows will be updated in the order that is
  28305. specified.
  28306.  
  28307. If you specify the keyword `LOW_PRIORITY', execution of the `UPDATE' is
  28308. delayed until no other clients are reading from the table.
  28309.  
  28310. If you specify the keyword `IGNORE', the update statement will not
  28311. abort even if we get duplicate key errors during the update.  Rows that
  28312. would cause conflicts will not be updated.
  28313.  
  28314. If you access a column from `tbl_name' in an expression, `UPDATE' uses
  28315. the current value of the column.  For example, the following statement
  28316. sets the `age' column to one more than its current value:
  28317.  
  28318.      mysql> UPDATE persondata SET age=age+1;
  28319.  
  28320. `UPDATE' assignments are evaluated from left to right.  For example, the
  28321. following statement doubles the `age' column, then increments it:
  28322.  
  28323.      mysql> UPDATE persondata SET age=age*2, age=age+1;
  28324.  
  28325. If you set a column to the value it currently has, MySQL notices this
  28326. and doesn't update it.
  28327.  
  28328. `UPDATE' returns the number of rows that were actually changed.  In
  28329. MySQL Version 3.22 or later, the C API function `mysql_info()' returns
  28330. the number of rows that were matched and updated and the number of
  28331. warnings that occurred during the `UPDATE'.
  28332.  
  28333. In MySQL Version 3.23, you can use `LIMIT #' to ensure that only a
  28334. given number of rows are changed.
  28335.  
  28336. 
  28337. File: mysql.info,  Node: DELETE,  Next: TRUNCATE,  Prev: UPDATE,  Up: Data Manipulation
  28338.  
  28339. `DELETE' Syntax
  28340. ---------------
  28341.  
  28342.      DELETE [LOW_PRIORITY] FROM tbl_name
  28343.          [WHERE where_definition]
  28344.          [LIMIT rows]
  28345.  
  28346. `DELETE' deletes rows from `tbl_name' that satisfy the condition given
  28347. by `where_definition', and returns the number of records deleted.
  28348.  
  28349. If you issue a `DELETE' with no `WHERE' clause, all rows are deleted.
  28350. If you do this in `AUTOCOMMIT' mode, this works as `TRUNCATE'. *Note
  28351. TRUNCATE::. One problem with this is that `DELETE' will return zero as
  28352. the number of affected records, but this will be fixed in 4.0.
  28353.  
  28354. If you really want to know how many records are deleted when you are
  28355. deleting all rows, and are willing to suffer a speed penalty, you can
  28356. use a `DELETE' statement of this form:
  28357.  
  28358.      mysql> DELETE FROM tbl_name WHERE 1>0;
  28359.  
  28360. Note that this is MUCH slower than `DELETE FROM tbl_name' with no
  28361. `WHERE' clause, because it deletes rows one at a time.
  28362.  
  28363. If you specify the keyword `LOW_PRIORITY', execution of the `DELETE' is
  28364. delayed until no other clients are reading from the table.
  28365.  
  28366. Deleted records are maintained in a linked list and subsequent `INSERT'
  28367. operations reuse old record positions. To reclaim unused space and
  28368. reduce file sizes, use the `OPTIMIZE TABLE' statement or the `myisamchk'
  28369. utility to reorganize tables.  `OPTIMIZE TABLE' is easier, but
  28370. `myisamchk' is faster.  See *Note `OPTIMIZE TABLE': OPTIMIZE TABLE and
  28371. *Note Optimization::.
  28372.  
  28373. The MySQL-specific `LIMIT rows' option to `DELETE' tells the server the
  28374. maximum number of rows to be deleted before control is returned to the
  28375. client.  This can be used to ensure that a specific `DELETE' command
  28376. doesn't take too much time.  You can simply repeat the `DELETE' command
  28377. until the number of affected rows is less than the `LIMIT' value.
  28378.  
  28379. 
  28380. File: mysql.info,  Node: TRUNCATE,  Next: REPLACE,  Prev: DELETE,  Up: Data Manipulation
  28381.  
  28382. `TRUNCATE' Syntax
  28383. -----------------
  28384.  
  28385.      TRUNCATE TABLE table_name
  28386.  
  28387. Is in 3.23 and the same thing as `DELETE FROM table_name'. *Note
  28388. DELETE::.  The differences are:
  28389.  
  28390.    * Implemented as a drop and re-create of the table, which makes this
  28391.      much faster when deleting many rows.
  28392.  
  28393.    * Not transaction-safe; `TRUNCATE TABLE' will automatically end the
  28394.      current transaction as if `COMMIT' would have been called.
  28395.  
  28396.    * Doesn't return the number of deleted rows.
  28397.  
  28398.    * As long as the table definition file `table_name.frm' is valid,
  28399.      the table can be re-created this way, even if the data or index
  28400.      files have become corrupted.
  28401.  
  28402. `TRUNCATE' is an Oracle SQL extension.
  28403.  
  28404. 
  28405. File: mysql.info,  Node: REPLACE,  Next: LOAD DATA,  Prev: TRUNCATE,  Up: Data Manipulation
  28406.  
  28407. `REPLACE' Syntax
  28408. ----------------
  28409.  
  28410.          REPLACE [LOW_PRIORITY | DELAYED]
  28411.              [INTO] tbl_name [(col_name,...)]
  28412.              VALUES (expression,...),(...),...
  28413.      or  REPLACE [LOW_PRIORITY | DELAYED]
  28414.              [INTO] tbl_name [(col_name,...)]
  28415.              SELECT ...
  28416.      or  REPLACE [LOW_PRIORITY | DELAYED]
  28417.              [INTO] tbl_name
  28418.              SET col_name=expression, col_name=expression,...
  28419.  
  28420. `REPLACE' works exactly like `INSERT', except that if an old record in
  28421. the table has the same value as a new record on a unique index, the old
  28422. record is deleted before the new record is inserted.  *Note `INSERT':
  28423. INSERT.
  28424.  
  28425. In other words, you can't access the values of the old row from a
  28426. `REPLACE' statement.  In some old MySQL version it looked like you
  28427. could do this, but that was a bug that has been corrected.
  28428.  
  28429. When one uses a `REPLACE' command, `mysql_affected_rows()' will return
  28430. 2 if the new row replaced and old row.  This is because in this case
  28431. one row was inserted and then the duplicate was deleted.
  28432.  
  28433. The above makes it easy to check if `REPLACE' added or replaced a row.
  28434.  
  28435. 
  28436. File: mysql.info,  Node: LOAD DATA,  Next: DO,  Prev: REPLACE,  Up: Data Manipulation
  28437.  
  28438. `LOAD DATA INFILE' Syntax
  28439. -------------------------
  28440.  
  28441.      LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name.txt'
  28442.          [REPLACE | IGNORE]
  28443.          INTO TABLE tbl_name
  28444.          [FIELDS
  28445.              [TERMINATED BY '\t']
  28446.              [[OPTIONALLY] ENCLOSED BY '']
  28447.              [ESCAPED BY '\\' ]
  28448.          ]
  28449.          [LINES TERMINATED BY '\n']
  28450.          [IGNORE number LINES]
  28451.          [(col_name,...)]
  28452.  
  28453. The `LOAD DATA INFILE' statement reads rows from a text file into a
  28454. table at a very high speed.  If the `LOCAL' keyword is specified, the
  28455. file is read from the client host.  If `LOCAL' is not specified, the
  28456. file must be located on the server.  (`LOCAL' is available in MySQL
  28457. Version 3.22.6 or later.)
  28458.  
  28459. For security reasons, when reading text files located on the server, the
  28460. files must either reside in the database directory or be readable by
  28461. all.  Also, to use `LOAD DATA INFILE' on server files, you must have the
  28462. *file* privilege on the server host.  *Note Privileges provided::.
  28463.  
  28464. If you specify the keyword `LOW_PRIORITY', execution of the `LOAD DATA'
  28465. statement is delayed until no other clients are reading from the table.
  28466.  
  28467. If you specify the keyword `CONCURRENT' with a `MyISAM' table, then
  28468. other threads can retrieve data from the table while `LOAD DATA' is
  28469. executing. Using this option will of course affect the performance of
  28470. `LOAD DATA' a bit even if no other thread is using the table at the
  28471. same time.
  28472.  
  28473. Using `LOCAL' will be a bit slower than letting the server access the
  28474. files directly, because the contents of the file must travel from the
  28475. client host to the server host.  On the other hand, you do not need the
  28476. *file* privilege to load local files.
  28477.  
  28478. If you are using MySQL before Version 3.23.24 you can't read from a
  28479. FIFO with `LOAD DATA INFILE'.  If you need to read from a FIFO (for
  28480. example the output from gunzip), use `LOAD DATA LOCAL INFILE' instead.
  28481.  
  28482. You can also load data files by using the `mysqlimport' utility; it
  28483. operates by sending a `LOAD DATA INFILE' command to the server.  The
  28484. `--local' option causes `mysqlimport' to read data files from the
  28485. client host.  You can specify the `--compress' option to get better
  28486. performance over slow networks if the client and server support the
  28487. compressed protocol.
  28488.  
  28489. When locating files on the server host, the server uses the following
  28490. rules:
  28491.  
  28492.    * If an absolute pathname is given, the server uses the pathname as
  28493.      is.
  28494.  
  28495.    * If a relative pathname with one or more leading components is
  28496.      given, the server searches for the file relative to the server's
  28497.      data directory.
  28498.  
  28499.    * If a filename with no leading components is given, the server
  28500.      looks for the file in the database directory of the current
  28501.      database.
  28502.  
  28503. Note that these rules mean a file given as `./myfile.txt' is read from
  28504. the server's data directory, whereas a file given as `myfile.txt' is
  28505. read from the database directory of the current database.  For example,
  28506. the following `LOAD DATA' statement reads the file `data.txt' from the
  28507. database directory for `db1' because `db1' is the current database,
  28508. even though the statement explicitly loads the file into a table in the
  28509. `db2' database:
  28510.  
  28511.      mysql> USE db1;
  28512.      mysql> LOAD DATA INFILE "data.txt" INTO TABLE db2.my_table;
  28513.  
  28514. The `REPLACE' and `IGNORE' keywords control handling of input records
  28515. that duplicate existing records on unique key values.  If you specify
  28516. `REPLACE', new rows replace existing rows that have the same unique key
  28517. value. If you specify `IGNORE', input rows that duplicate an existing
  28518. row on a unique key value are skipped.  If you don't specify either
  28519. option, an error occurs when a duplicate key value is found, and the
  28520. rest of the text file is ignored.
  28521.  
  28522. If you load data from a local file using the `LOCAL' keyword, the server
  28523. has no way to stop transmission of the file in the middle of the
  28524. operation, so the default bahavior is the same as if `IGNORE' is
  28525. specified.
  28526.  
  28527. If you use `LOAD DATA INFILE' on an empty `MyISAM' table, all
  28528. non-unique indexes are created in a separate batch (like in `REPAIR').
  28529. This normally makes `LOAD DATA INFILE' much faster when you have many
  28530. indexes.
  28531.  
  28532. `LOAD DATA INFILE' is the complement of `SELECT ... INTO OUTFILE'.
  28533. *Note `SELECT': SELECT.  To write data from a database to a file, use
  28534. `SELECT ... INTO OUTFILE'.  To read the file back into the database,
  28535. use `LOAD DATA INFILE'.  The syntax of the `FIELDS' and `LINES' clauses
  28536. is the same for both commands.  Both clauses are optional, but `FIELDS'
  28537. must precede `LINES' if both are specified.
  28538.  
  28539. If you specify a `FIELDS' clause, each of its subclauses (`TERMINATED
  28540. BY', `[OPTIONALLY] ENCLOSED BY', and `ESCAPED BY') is also optional,
  28541. except that you must specify at least one of them.
  28542.  
  28543. If you don't specify a `FIELDS' clause, the defaults are the same as if
  28544. you had written this:
  28545.  
  28546.      FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\'
  28547.  
  28548. If you don't specify a `LINES' clause, the default is the same as if
  28549. you had written this:
  28550.  
  28551.      LINES TERMINATED BY '\n'
  28552.  
  28553. In other words, the defaults cause `LOAD DATA INFILE' to act as follows
  28554. when reading input:
  28555.  
  28556.    * Look for line boundaries at newlines.
  28557.  
  28558.    * Break lines into fields at tabs.
  28559.  
  28560.    * Do not expect fields to be enclosed within any quoting characters.
  28561.  
  28562.    * Interpret occurrences of tab, newline, or `\' preceded by `\' as
  28563.      literal characters that are part of field values.
  28564.  
  28565. Conversely, the defaults cause `SELECT ... INTO OUTFILE' to act as
  28566. follows when writing output:
  28567.  
  28568.    * Write tabs between fields.
  28569.  
  28570.    * Do not enclose fields within any quoting characters.
  28571.  
  28572.    * Use `\' to escape instances of tab, newline or `\' that occur
  28573.      within field values.
  28574.  
  28575.    * Write newlines at the ends of lines.
  28576.  
  28577. Note that to write `FIELDS ESCAPED BY '\\'', you must specify two
  28578. backslashes for the value to be read as a single backslash.
  28579.  
  28580. The `IGNORE number LINES' option can be used to ignore a header of
  28581. column names at the start of the file:
  28582.  
  28583.      mysql> LOAD DATA INFILE "/tmp/file_name" into table test IGNORE 1 LINES;
  28584.  
  28585. When you use `SELECT ... INTO OUTFILE' in tandem with `LOAD DATA
  28586. INFILE' to write data from a database into a file and then read the
  28587. file back into the database later, the field and line handling options
  28588. for both commands must match.  Otherwise, `LOAD DATA INFILE' will not
  28589. interpret the contents of the file properly.  Suppose you use `SELECT
  28590. ... INTO OUTFILE' to write a file with fields delimited by commas:
  28591.  
  28592.      mysql> SELECT * INTO OUTFILE 'data.txt'
  28593.                 FIELDS TERMINATED BY ','
  28594.                 FROM ...;
  28595.  
  28596. To read the comma-delimited file back in, the correct statement would
  28597. be:
  28598.  
  28599.      mysql> LOAD DATA INFILE 'data.txt' INTO TABLE table2
  28600.                 FIELDS TERMINATED BY ',';
  28601.  
  28602. If instead you tried to read in the file with the statement shown
  28603. below, it wouldn't work because it instructs `LOAD DATA INFILE' to look
  28604. for tabs between fields:
  28605.  
  28606.      mysql> LOAD DATA INFILE 'data.txt' INTO TABLE table2
  28607.                 FIELDS TERMINATED BY '\t';
  28608.  
  28609. The likely result is that each input line would be interpreted as a
  28610. single field.
  28611.  
  28612. `LOAD DATA INFILE' can be used to read files obtained from external
  28613. sources, too. For example, a file in dBASE format will have fields
  28614. separated by commas and enclosed in double quotes.  If lines in the
  28615. file are terminated by newlines, the command shown below illustrates
  28616. the field and line handling options you would use to load the file:
  28617.  
  28618.      mysql> LOAD DATA INFILE 'data.txt' INTO TABLE tbl_name
  28619.                 FIELDS TERMINATED BY ',' ENCLOSED BY '"'
  28620.                 LINES TERMINATED BY '\n';
  28621.  
  28622. Any of the field or line handling options may specify an empty string
  28623. (`''').  If not empty, the `FIELDS [OPTIONALLY] ENCLOSED BY' and
  28624. `FIELDS ESCAPED BY' values must be a single character.  The `FIELDS
  28625. TERMINATED BY' and `LINES TERMINATED BY' values may be more than one
  28626. character.  For example, to write lines that are terminated by carriage
  28627. return-linefeed pairs, or to read a file containing such lines, specify
  28628. a `LINES TERMINATED BY '\r\n'' clause.
  28629.  
  28630. For example, to read a file of jokes, that are separated with a line of
  28631. `%%', into a SQL table you can do:
  28632.  
  28633.      create table jokes (a int not null auto_increment primary key, joke text
  28634.      not null);
  28635.      load data infile "/tmp/jokes.txt" into table jokes fields terminated by ""
  28636.      lines terminated by "\n%%\n" (joke);
  28637.  
  28638. `FIELDS [OPTIONALLY] ENCLOSED BY' controls quoting of fields.  For
  28639. output (`SELECT ... INTO OUTFILE'), if you omit the word `OPTIONALLY',
  28640. all fields are enclosed by the `ENCLOSED BY' character.  An example of
  28641. such output (using a comma as the field delimiter) is shown below:
  28642.  
  28643.      "1","a string","100.20"
  28644.      "2","a string containing a , comma","102.20"
  28645.      "3","a string containing a \" quote","102.20"
  28646.      "4","a string containing a \", quote and comma","102.20"
  28647.  
  28648. If you specify `OPTIONALLY', the `ENCLOSED BY' character is used only
  28649. to enclose `CHAR' and `VARCHAR' fields:
  28650.  
  28651.      1,"a string",100.20
  28652.      2,"a string containing a , comma",102.20
  28653.      3,"a string containing a \" quote",102.20
  28654.      4,"a string containing a \", quote and comma",102.20
  28655.  
  28656. Note that occurrences of the `ENCLOSED BY' character within a field
  28657. value are escaped by prefixing them with the `ESCAPED BY' character.
  28658. Also note that if you specify an empty `ESCAPED BY' value, it is
  28659. possible to generate output that cannot be read properly by `LOAD DATA
  28660. INFILE'. For example, the output just shown above would appear as shown
  28661. below if the escape character is empty.  Observe that the second field
  28662. in the fourth line contains a comma following the quote, which
  28663. (erroneously) appears to terminate the field:
  28664.  
  28665.      1,"a string",100.20
  28666.      2,"a string containing a , comma",102.20
  28667.      3,"a string containing a " quote",102.20
  28668.      4,"a string containing a ", quote and comma",102.20
  28669.  
  28670. For input, the `ENCLOSED BY' character, if present, is stripped from the
  28671. ends of field values.  (This is true whether or not `OPTIONALLY' is
  28672. specified; `OPTIONALLY' has no effect on input interpretation.)
  28673. Occurrences of the `ENCLOSED BY' character preceded by the `ESCAPED BY'
  28674. character are interpreted as part of the current field value.  In
  28675. addition, duplicated `ENCLOSED BY' characters occurring within fields
  28676. are interpreted as single `ENCLOSED BY' characters if the field itself
  28677. starts with that character.  For example, if `ENCLOSED BY '"'' is
  28678. specified, quotes are handled as shown below:
  28679.  
  28680.      "The ""BIG"" boss"  -> The "BIG" boss
  28681.      The "BIG" boss      -> The "BIG" boss
  28682.      The ""BIG"" boss    -> The ""BIG"" boss
  28683.  
  28684. `FIELDS ESCAPED BY' controls how to write or read special characters.
  28685. If the `FIELDS ESCAPED BY' character is not empty, it is used to prefix
  28686. the following characters on output:
  28687.    * The `FIELDS ESCAPED BY' character
  28688.  
  28689.    * The `FIELDS [OPTIONALLY] ENCLOSED BY' character
  28690.  
  28691.    * The first character of the `FIELDS TERMINATED BY' and `LINES
  28692.      TERMINATED BY' values
  28693.  
  28694.    * ASCII `0' (what is actually written following the escape character
  28695.      is ASCII `'0'', not a zero-valued byte)
  28696.  
  28697. If the `FIELDS ESCAPED BY' character is empty, no characters are
  28698. escaped.  It is probably not a good idea to specify an empty escape
  28699. character, particularly if field values in your data contain any of the
  28700. characters in the list just given.
  28701.  
  28702. For input, if the `FIELDS ESCAPED BY' character is not empty,
  28703. occurrences of that character are stripped and the following character
  28704. is taken literally as part of a field value.  The exceptions are an
  28705. escaped `0' or `N' (for example, `\0' or `\N' if the escape character is
  28706. `\').  These sequences are interpreted as ASCII `0' (a zero-valued
  28707. byte) and `NULL'.  See below for the rules on `NULL' handling.
  28708.  
  28709. For more information about `\'-escape syntax, see *Note Literals::.
  28710.  
  28711. In certain cases, field and line handling options interact:
  28712.  
  28713.    * If `LINES TERMINATED BY' is an empty string and `FIELDS TERMINATED
  28714.      BY' is non-empty, lines are also terminated with `FIELDS
  28715.      TERMINATED BY'.
  28716.  
  28717.    * If the `FIELDS TERMINATED BY' and `FIELDS ENCLOSED BY' values are
  28718.      both empty (`'''), a fixed-row (non-delimited) format is used.
  28719.      With fixed-row format, no delimiters are used between fields.
  28720.      Instead, column values are written and read using the "display"
  28721.      widths of the columns.  For example, if a column is declared as
  28722.      `INT(7)', values for the column are written using 7-character
  28723.      fields.  On input, values for the column are obtained by reading 7
  28724.      characters.  Fixed-row format also affects handling of `NULL'
  28725.      values; see below.  Note that fixed-size format will not work if
  28726.      you are using a multi-byte character set.
  28727.  
  28728. Handling of `NULL' values varies, depending on the `FIELDS' and `LINES'
  28729. options you use:
  28730.  
  28731.    * For the default `FIELDS' and `LINES' values, `NULL' is written as
  28732.      `\N' for output and `\N' is read as `NULL' for input (assuming the
  28733.      `ESCAPED BY' character is `\').
  28734.  
  28735.    * If `FIELDS ENCLOSED BY' is not empty, a field containing the
  28736.      literal word `NULL' as its value is read as a `NULL' value (this
  28737.      differs from the word `NULL' enclosed within `FIELDS ENCLOSED BY'
  28738.      characters, which is read as the string `'NULL'').
  28739.  
  28740.    * If `FIELDS ESCAPED BY' is empty, `NULL' is written as the word
  28741.      `NULL'.
  28742.  
  28743.    * With fixed-row format (which happens when `FIELDS TERMINATED BY'
  28744.      and `FIELDS ENCLOSED BY' are both empty), `NULL' is written as an
  28745.      empty string.  Note that this causes both `NULL' values and empty
  28746.      strings in the table to be indistinguishable when written to the
  28747.      file because they are both written as empty strings.  If you need
  28748.      to be able to tell the two apart when reading the file back in,
  28749.      you should not use fixed-row format.
  28750.  
  28751. Some cases are not supported by `LOAD DATA INFILE':
  28752.    * Fixed-size rows (`FIELDS TERMINATED BY' and `FIELDS ENCLOSED BY'
  28753.      both empty) and `BLOB' or `TEXT' columns.
  28754.  
  28755.    * If you specify one separator that is the same as or a prefix of
  28756.      another, `LOAD DATA INFILE' won't be able to interpret the input
  28757.      properly.  For example, the following `FIELDS' clause would cause
  28758.      problems:
  28759.  
  28760.           FIELDS TERMINATED BY '"' ENCLOSED BY '"'
  28761.  
  28762.    * If `FIELDS ESCAPED BY' is empty, a field value that contains an
  28763.      occurrence of `FIELDS ENCLOSED BY' or `LINES TERMINATED BY'
  28764.      followed by the `FIELDS TERMINATED BY' value will cause `LOAD DATA
  28765.      INFILE' to stop reading a field or line too early.  This happens
  28766.      because `LOAD DATA INFILE' cannot properly determine where the
  28767.      field or line value ends.
  28768.  
  28769. The following example loads all columns of the `persondata' table:
  28770.  
  28771.      mysql> LOAD DATA INFILE 'persondata.txt' INTO TABLE persondata;
  28772.  
  28773. No field list is specified, so `LOAD DATA INFILE' expects input rows to
  28774. contain a field for each table column.  The default `FIELDS' and
  28775. `LINES' values are used.
  28776.  
  28777. If you wish to load only some of a table's columns, specify a field
  28778. list:
  28779.  
  28780.      mysql> LOAD DATA INFILE 'persondata.txt'
  28781.                 INTO TABLE persondata (col1,col2,...);
  28782.  
  28783. You must also specify a field list if the order of the fields in the
  28784. input file differs from the order of the columns in the table.
  28785. Otherwise, MySQL cannot tell how to match up input fields with table
  28786. columns.
  28787.  
  28788. If a row has too few fields, the columns for which no input field is
  28789. present are set to default values.  Default value assignment is
  28790. described in *Note `CREATE TABLE': CREATE TABLE.
  28791.  
  28792. An empty field value is interpreted differently than if the field value
  28793. is missing:
  28794.  
  28795.    * For string types, the column is set to the empty string.
  28796.  
  28797.    * For numeric types, the column is set to `0'.
  28798.  
  28799.    * For date and time types, the column is set to the appropriate
  28800.      "zero" value for the type.  *Note Date and time types::.
  28801.  
  28802. Note that these are the same values that result if you assign an empty
  28803. string explicitly to a string, numeric, or date or time type explicitly
  28804. in an `INSERT' or `UPDATE' statement.
  28805.  
  28806. `TIMESTAMP' columns are only set to the current date and time if there
  28807. is a `NULL' value for the column, or (for the first `TIMESTAMP' column
  28808. only) if the `TIMESTAMP' column is left out from the field list when a
  28809. field list is specified.
  28810.  
  28811. If an input row has too many fields, the extra fields are ignored and
  28812. the number of warnings is incremented.
  28813.  
  28814. `LOAD DATA INFILE' regards all input as strings, so you can't use
  28815. numeric values for `ENUM' or `SET' columns the way you can with
  28816. `INSERT' statements.  All `ENUM' and `SET' values must be specified as
  28817. strings!
  28818.  
  28819. If you are using the C API, you can get information about the query by
  28820. calling the API function `mysql_info()' when the `LOAD DATA INFILE'
  28821. query finishes.  The format of the information string is shown below:
  28822.  
  28823.      Records: 1  Deleted: 0  Skipped: 0  Warnings: 0
  28824.  
  28825. Warnings occur under the same circumstances as when values are inserted
  28826. via the `INSERT' statement (*note `INSERT': INSERT.), except that `LOAD
  28827. DATA INFILE' also generates warnings when there are too few or too many
  28828. fields in the input row.  The warnings are not stored anywhere; the
  28829. number of warnings can only be used as an indication if everything went
  28830. well.  If you get warnings and want to know exactly why you got them,
  28831. one way to do this is to use `SELECT ... INTO OUTFILE' into another
  28832. file and compare this to your original input file.
  28833.  
  28834. If you need `LOAD DATA' to read from a pipe, you can use the following
  28835. trick:
  28836.  
  28837.      mkfifo /mysql/db/x/x
  28838.      chmod 666 /mysql/db/x/x
  28839.      cat < /dev/tcp/10.1.1.12/4711 > /nt/mysql/db/x/x
  28840.      mysql -e "LOAD DATA INFILE 'x' INTO TABLE x" x
  28841.  
  28842. If you are using a version of MySQL older than 3.23.25 you can only do
  28843. the above with `LOAD DATA LOCAL INFILE'.
  28844.  
  28845. For more information about the efficiency of `INSERT' versus `LOAD DATA
  28846. INFILE' and speeding up `LOAD DATA INFILE', *Note Insert speed::.
  28847.  
  28848. 
  28849. File: mysql.info,  Node: DO,  Prev: LOAD DATA,  Up: Data Manipulation
  28850.  
  28851. `DO' Syntax
  28852. -----------
  28853.  
  28854.      DO expression, [expression, ...]
  28855.  
  28856. Execute the expression but don't return any results.  This is a
  28857. shorthand of `SELECT expression, expression', but has the advantage
  28858. that it's slightly faster when you don't care about the result.
  28859.  
  28860. This is mainly useful with functions that has side effects, like
  28861. `RELEASE_LOCK'.
  28862.  
  28863. 
  28864. File: mysql.info,  Node: Data Definition,  Next: Basic User Commands,  Prev: Data Manipulation,  Up: Reference
  28865.  
  28866. Data Definition: `CREATE', `DROP', `ALTER'
  28867. ==========================================
  28868.  
  28869. * Menu:
  28870.  
  28871. * CREATE DATABASE::             `CREATE DATABASE' Syntax
  28872. * DROP DATABASE::               `DROP DATABASE' Syntax
  28873. * CREATE TABLE::                `CREATE TABLE' Syntax
  28874. * ALTER TABLE::                 `ALTER TABLE' Syntax
  28875. * RENAME TABLE::                `RENAME TABLE' Syntax
  28876. * DROP TABLE::                  `DROP TABLE' Syntax
  28877. * CREATE INDEX::                `CREATE INDEX' Syntax
  28878. * DROP INDEX::                  `DROP INDEX' Syntax
  28879.  
  28880. 
  28881. File: mysql.info,  Node: CREATE DATABASE,  Next: DROP DATABASE,  Prev: Data Definition,  Up: Data Definition
  28882.  
  28883. `CREATE DATABASE' Syntax
  28884. ------------------------
  28885.  
  28886.      CREATE DATABASE [IF NOT EXISTS] db_name
  28887.  
  28888. `CREATE DATABASE' creates a database with the given name.  Rules for
  28889. allowable database names are given in *Note Legal names::.  An error
  28890. occurs if the database already exists and you didn't specify `IF NOT
  28891. EXISTS'.
  28892.  
  28893. Databases in MySQL are implemented as directories containing files that
  28894. correspond to tables in the database.  Because there are no tables in a
  28895. database when it is initially created, the `CREATE DATABASE' statement
  28896. only creates a directory under the MySQL data directory.
  28897.  
  28898. You can also create databases with `mysqladmin'.  *Note Client-Side
  28899. Scripts::.
  28900.  
  28901. 
  28902. File: mysql.info,  Node: DROP DATABASE,  Next: CREATE TABLE,  Prev: CREATE DATABASE,  Up: Data Definition
  28903.  
  28904. `DROP DATABASE' Syntax
  28905. ----------------------
  28906.  
  28907.      DROP DATABASE [IF EXISTS] db_name
  28908.  
  28909. `DROP DATABASE' drops all tables in the database and deletes the
  28910. database.  If you do a `DROP DATABASE' on a symbolic linked database,
  28911. both the link and the original database is deleted. *Be VERY careful
  28912. with this command!*
  28913.  
  28914. `DROP DATABASE' returns the number of files that were removed from the
  28915. database directory.  Normally, this is three times the number of
  28916. tables, because normally each table corresponds to a `.MYD' file, a
  28917. `.MYI' file, and a `.frm' file.
  28918.  
  28919. The `DROP DATABASE' command removes from the given database directory
  28920. all files with the following extensions:
  28921.  
  28922. .BAK               .DAT               .HSH               .ISD
  28923. .ISM               .ISM               .MRG               .MYD
  28924. .MYI               .db                .frm               
  28925.  
  28926. All subdirectories that consists of 2 digits (`RAID' directories) are
  28927. also removed.
  28928.  
  28929. In MySQL Version 3.22 or later, you can use the keywords `IF EXISTS' to
  28930. prevent an error from occurring if the database doesn't exist.
  28931.  
  28932. You can also drop databases with `mysqladmin'. *Note Client-Side
  28933. Scripts::.
  28934.  
  28935. * Menu:
  28936.  
  28937. * CREATE TABLE::                `CREATE TABLE' Syntax
  28938. * ALTER TABLE::                 `ALTER TABLE' Syntax
  28939. * RENAME TABLE::                `RENAME TABLE' Syntax
  28940. * DROP TABLE::                  `DROP TABLE' Syntax
  28941. * CREATE INDEX::                `CREATE INDEX' Syntax
  28942. * DROP INDEX::                  `DROP INDEX' Syntax
  28943.  
  28944. 
  28945. File: mysql.info,  Node: CREATE TABLE,  Next: ALTER TABLE,  Prev: DROP DATABASE,  Up: Data Definition
  28946.  
  28947. `CREATE TABLE' Syntax
  28948. ---------------------
  28949.  
  28950. * Menu:
  28951.  
  28952. * Silent column changes::       Silent column changes
  28953.  
  28954.      CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]
  28955.      [table_options] [select_statement]
  28956.      
  28957.      create_definition:
  28958.        col_name type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT]
  28959.                  [PRIMARY KEY] [reference_definition]
  28960.        or    PRIMARY KEY (index_col_name,...)
  28961.        or    KEY [index_name] (index_col_name,...)
  28962.        or    INDEX [index_name] (index_col_name,...)
  28963.        or    UNIQUE [INDEX] [index_name] (index_col_name,...)
  28964.        or    FULLTEXT [INDEX] [index_name] (index_col_name,...)
  28965.        or    [CONSTRAINT symbol] FOREIGN KEY index_name (index_col_name,...)
  28966.                  [reference_definition]
  28967.        or    CHECK (expr)
  28968.      
  28969.      type:
  28970.              TINYINT[(length)] [UNSIGNED] [ZEROFILL]
  28971.        or    SMALLINT[(length)] [UNSIGNED] [ZEROFILL]
  28972.        or    MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL]
  28973.        or    INT[(length)] [UNSIGNED] [ZEROFILL]
  28974.        or    INTEGER[(length)] [UNSIGNED] [ZEROFILL]
  28975.        or    BIGINT[(length)] [UNSIGNED] [ZEROFILL]
  28976.        or    REAL[(length,decimals)] [UNSIGNED] [ZEROFILL]
  28977.        or    DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL]
  28978.        or    FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL]
  28979.        or    DECIMAL(length,decimals) [UNSIGNED] [ZEROFILL]
  28980.        or    NUMERIC(length,decimals) [UNSIGNED] [ZEROFILL]
  28981.        or    CHAR(length) [BINARY]
  28982.        or    VARCHAR(length) [BINARY]
  28983.        or    DATE
  28984.        or    TIME
  28985.        or    TIMESTAMP
  28986.        or    DATETIME
  28987.        or    TINYBLOB
  28988.        or    BLOB
  28989.        or    MEDIUMBLOB
  28990.        or    LONGBLOB
  28991.        or    TINYTEXT
  28992.        or    TEXT
  28993.        or    MEDIUMTEXT
  28994.        or    LONGTEXT
  28995.        or    ENUM(value1,value2,value3,...)
  28996.        or    SET(value1,value2,value3,...)
  28997.      
  28998.      index_col_name:
  28999.              col_name [(length)]
  29000.      
  29001.      reference_definition:
  29002.              REFERENCES tbl_name [(index_col_name,...)]
  29003.                         [MATCH FULL | MATCH PARTIAL]
  29004.                         [ON DELETE reference_option]
  29005.                         [ON UPDATE reference_option]
  29006.      
  29007.      reference_option:
  29008.              RESTRICT | CASCADE | SET NULL | NO ACTION | SET DEFAULT
  29009.      
  29010.      table_options:
  29011.          TYPE = {BDB | HEAP | ISAM | InnoDB | MERGE | MYISAM }
  29012.      or    AUTO_INCREMENT = #
  29013.      or    AVG_ROW_LENGTH = #
  29014.      or    CHECKSUM = {0 | 1}
  29015.      or    COMMENT = "string"
  29016.      or    MAX_ROWS = #
  29017.      or    MIN_ROWS = #
  29018.      or    PACK_KEYS = {0 | 1}
  29019.      or    PASSWORD = "string"
  29020.      or    DELAY_KEY_WRITE = {0 | 1}
  29021.      or      ROW_FORMAT= { default | dynamic | fixed | compressed }
  29022.      or    RAID_TYPE= {1 | STRIPED | RAID0 } RAID_CHUNKS=#  RAID_CHUNKSIZE=#
  29023.      or    UNION = (table_name,[table_name...])
  29024.      or      DATA DIRECTORY="directory"
  29025.      or      INDEX DIRECTORY="directory"
  29026.      
  29027.      select_statement:
  29028.          [IGNORE | REPLACE] SELECT ...  (Some legal select statement)
  29029.  
  29030. `CREATE TABLE' creates a table with the given name in the current
  29031. database.  Rules for allowable table names are given in *Note Legal
  29032. names::.  An error occurs if there is no current database or if the
  29033. table already exists.
  29034.  
  29035. In MySQL Version 3.22 or later, the table name can be specified as
  29036. `db_name.tbl_name'.  This works whether or not there is a current
  29037. database.
  29038.  
  29039. In MySQL Version 3.23, you can use the `TEMPORARY' keyword when you
  29040. create a table.  A temporary table will automatically be deleted if a
  29041. connection dies and the name is per connection.  This means that two
  29042. different connections can both use the same temporary table name
  29043. without conflicting with each other or with an existing table of the
  29044. same name. (The existing table is hidden until the temporary table is
  29045. deleted).
  29046.  
  29047. In MySQL Version 3.23 or later, you can use the keywords `IF NOT
  29048. EXISTS' so that an error does not occur if the table already exists.
  29049. Note that there is no verification that the table structures are
  29050. identical.
  29051.  
  29052. Each table `tbl_name' is represented by some files in the database
  29053. directory. In the case of MyISAM-type tables you will get:
  29054.  
  29055. *File*         *Purpose*
  29056. `tbl_name.frm' Table definition (form) file
  29057. `tbl_name.MYD' Data file
  29058. `tbl_name.MYI' Index file
  29059.  
  29060. For more information on the properties of the various column types, see
  29061. *Note Column types:::
  29062.  
  29063.    * If neither `NULL' nor `NOT NULL' is specified, the column is
  29064.      treated as though `NULL' had been specified.
  29065.  
  29066.    * An integer column may have the additional attribute
  29067.      `AUTO_INCREMENT'.  When you insert a value of `NULL' (recommended)
  29068.      or `0' into an `AUTO_INCREMENT' column, the column is set to
  29069.      `value+1', where `value' is the largest value for the column
  29070.      currently in the table.  `AUTO_INCREMENT' sequences begin with `1'.
  29071.      *Note `mysql_insert_id()': mysql_insert_id.
  29072.  
  29073.      If you delete the row containing the maximum value for an
  29074.      `AUTO_INCREMENT' column, the value will be reused with an `ISAM',
  29075.      or `BDB' table but not with a `MyISAM' or `InnoDB' table.  If you
  29076.      delete all rows in the table with `DELETE FROM table_name'
  29077.      (without a `WHERE') in `AUTOCOMMIT' mode, the sequence starts over
  29078.      for all table types.
  29079.  
  29080.      *NOTE:* There can be only one `AUTO_INCREMENT' column per table,
  29081.      and it must be indexed. MySQL Version 3.23 will also only work
  29082.      properly if the auto_increment column only has positive values.
  29083.      Inserting a negative number is regarded as inserting a very large
  29084.      positive number.  This is done to avoid precision problems when
  29085.      numbers 'wrap' over from positive to negative and also to ensure
  29086.      that one doesn't accidentally get an auto_increment column that
  29087.      contains 0.
  29088.  
  29089.      To make MySQL compatible with some ODBC applications, you can find
  29090.      the last inserted row with the following query:
  29091.  
  29092.           SELECT * FROM tbl_name WHERE auto_col IS NULL
  29093.  
  29094.    * `NULL' values are handled differently for `TIMESTAMP' columns than
  29095.      for other column types.  You cannot store a literal `NULL' in a
  29096.      `TIMESTAMP' column; setting the column to `NULL' sets it to the
  29097.      current date and time.  Because `TIMESTAMP' columns behave this
  29098.      way, the `NULL' and `NOT NULL' attributes do not apply in the
  29099.      normal way and are ignored if you specify them.
  29100.  
  29101.      On the other hand, to make it easier for MySQL clients to use
  29102.      `TIMESTAMP' columns, the server reports that such columns may be
  29103.      assigned `NULL' values (which is true), even though `TIMESTAMP'
  29104.      never actually will contain a `NULL' value.  You can see this when
  29105.      you use `DESCRIBE tbl_name' to get a description of your table.
  29106.  
  29107.      Note that setting a `TIMESTAMP' column to `0' is not the same as
  29108.      setting it to `NULL', because `0' is a valid `TIMESTAMP' value.
  29109.  
  29110.    * If no `DEFAULT' value is specified for a column, MySQL
  29111.      automatically assigns one.
  29112.  
  29113.      If the column may take `NULL' as a value, the default value is
  29114.      `NULL'.
  29115.  
  29116.      If the column is declared as `NOT NULL', the default value depends
  29117.      on the column type:
  29118.  
  29119.         - For numeric types other than those declared with the
  29120.           `AUTO_INCREMENT' attribute, the default is `0'.  For an
  29121.           `AUTO_INCREMENT' column, the default value is the next value
  29122.           in the sequence.
  29123.  
  29124.         - For date and time types other than `TIMESTAMP', the default
  29125.           is the appropriate zero value for the type.  For the first
  29126.           `TIMESTAMP' column in a table, the default value is the
  29127.           current date and time.  *Note Date and time types::.
  29128.  
  29129.         - For string types other than `ENUM', the default value is the
  29130.           empty string.  For `ENUM', the default is the first
  29131.           enumeration value.
  29132.  
  29133.      Default values must be constants. This means, for example, that
  29134.      you cannot set the default for a date column to be the value of a
  29135.      function such as `NOW()' or `CURRENT_DATE'.
  29136.  
  29137.    * `KEY' is a synonym for `INDEX'.
  29138.  
  29139.    * In MySQL, a `UNIQUE' key can have only distinct values. An error
  29140.      occurs if you try to add a new row with a key that matches an
  29141.      existing row.
  29142.  
  29143.    * A `PRIMARY KEY' is a unique `KEY' with the extra constraint that
  29144.      all key columns must be defined as `NOT NULL'.  In MySQL the key
  29145.      is named `PRIMARY'. A table can have only one `PRIMARY KEY'.  If
  29146.      you don't have a `PRIMARY KEY' and some applications ask for the
  29147.      `PRIMARY KEY' in your tables, MySQL will return the first `UNIQUE'
  29148.      key, which doesn't have any `NULL' columns, as the `PRIMARY KEY'.
  29149.  
  29150.    * A `PRIMARY KEY' can be a multiple-column index.  However, you
  29151.      cannot create a multiple-column index using the `PRIMARY KEY' key
  29152.      attibute in a column specification.  Doing so will mark only that
  29153.      single column as primary.  You must use the `PRIMARY
  29154.      KEY(index_col_name, ...)' syntax.
  29155.  
  29156.    * If the `PRIMARY' or `UNIQUE' key consists of only one column and
  29157.      this is of type integer, you can also refer to it as `_rowid' (new
  29158.      in Version 3.23.11).
  29159.  
  29160.    * If you don't assign a name to an index, the index will be assigned
  29161.      the same name as the first `index_col_name', with an optional
  29162.      suffix (`_2', `_3', `...') to make it unique.  You can see index
  29163.      names for a table using `SHOW INDEX FROM tbl_name'.  *Note `SHOW':
  29164.      SHOW.
  29165.  
  29166.    * Only the `MyISAM' table type supports indexes on columns that can
  29167.      have `NULL' values. In other cases you must declare such columns
  29168.      `NOT NULL' or an error results.
  29169.  
  29170.    * With `col_name(length)' syntax, you can specify an index that uses
  29171.      only a part of a `CHAR' or `VARCHAR' column. This can make the
  29172.      index file much smaller.  *Note Indexes::.
  29173.  
  29174.    * Only the `MyISAM' table type supports indexing on `BLOB' and
  29175.      `TEXT' columns.  When putting an index on a `BLOB' or `TEXT'
  29176.      column you MUST always specify the length of the index:
  29177.           CREATE TABLE test (blob_col BLOB, index(blob_col(10)));
  29178.  
  29179.    * When you use `ORDER BY' or `GROUP BY' with a `TEXT' or `BLOB'
  29180.      column, only the first `max_sort_length' bytes are used.  *Note
  29181.      `BLOB': BLOB.
  29182.  
  29183.    * In MySQL Version 3.23.23 or later, you can also create special
  29184.      *FULLTEXT* indexes. They are used for full-text search. Only the
  29185.      `MyISAM' table type supports `FULLTEXT' indexes. They can be
  29186.      created only from `VARCHAR' and `TEXT' columns.  Indexing always
  29187.      happens over the entire column, partial indexing is not supported.
  29188.      See *Note Fulltext Search:: for details of operation.
  29189.  
  29190.    * The `FOREIGN KEY', `CHECK', and `REFERENCES' clauses don't
  29191.      actually do anything.  The syntax for them is provided only for
  29192.      compatibility, to make it easier to port code from other SQL
  29193.      servers and to run applications that create tables with references.
  29194.      *Note Missing functions::.
  29195.  
  29196.    * Each `NULL' column takes one bit extra, rounded up to the nearest
  29197.      byte.
  29198.  
  29199.    * The maximum record length in bytes can be calculated as follows:
  29200.  
  29201.           row length = 1
  29202.                        + (sum of column lengths)
  29203.                        + (number of NULL columns + 7)/8
  29204.                        + (number of variable-length columns)
  29205.  
  29206.    * The `table_options' and `SELECT' options are only implemented in
  29207.      MySQL Version 3.23 and above.
  29208.  
  29209.      The different table types are:
  29210.  
  29211.      BDB or        Transaction-safe tables with page locking. *Note
  29212.      Berkeley_db   BDB::.
  29213.      HEAP          The data for this table is only stored in memory.
  29214.                    *Note HEAP::.
  29215.      ISAM          The original table handler. *Note ISAM::.
  29216.      InnoDB        Transaction-safe tables with row locking. *Note
  29217.                    InnoDB::.
  29218.      MERGE         A collection of MyISAM tables used as one table.
  29219.                    *Note MERGE::.
  29220.      MyISAM        The new binary portable table handler that is
  29221.                    replacing ISAM. *Note MyISAM::.
  29222.      *Note Table types::.
  29223.  
  29224.      If a table type is specified, and that particular type is not
  29225.      available, MySQL will choose the closest table type to the one
  29226.      that you have specified.  For example, if `TYPE=BDB' is specified,
  29227.      and that distribution of MySQL does not support `BDB' tables, the
  29228.      table will be created as `MyISAM' instead.
  29229.  
  29230.      The other table options are used to optimize the behavior of the
  29231.      table. In most cases, you don't have to specify any of them.  The
  29232.      options work for all table types, if not otherwise indicated:
  29233.  
  29234.      `AUTO_INCREMENT'The next auto_increment value you want to set for
  29235.                    your table (MyISAM).
  29236.      `AVG_ROW_LENGTH'An approximation of the average row length for your
  29237.                    table. You only need to set this for large tables
  29238.                    with variable size records.
  29239.      `CHECKSUM'    Set this to 1 if you want MySQL to maintain a
  29240.                    checksum for all rows (makes the table a little
  29241.                    slower to update but makes it easier to find
  29242.                    corrupted tables) (MyISAM).
  29243.      `COMMENT'     A 60-character comment for your table.
  29244.      `MAX_ROWS'    Max number of rows you plan to store in the table.
  29245.      `MIN_ROWS'    Minimum number of rows you plan to store in the table.
  29246.      `PACK_KEYS'   Set this to 1 if you want to have a smaller index.
  29247.                    This usually makes updates slower and reads faster
  29248.                    (MyISAM, ISAM).
  29249.      `PASSWORD'    Encrypt the `.frm' file with a password.  This option
  29250.                    doesn't do anything in the standard MySQL version.
  29251.      `DELAY_KEY_WRITE'Set this to 1 if want to delay key table updates
  29252.                    until the table is closed (MyISAM).
  29253.      `ROW_FORMAT'  Defines how the rows should be stored. Currently you
  29254.                    can only use the DYNAMIC and STATIC options for
  29255.                    MyISAM tables.
  29256.  
  29257.      When you use a `MyISAM' table, MySQL uses the product of `max_rows
  29258.      * avg_row_length' to decide how big the resulting table will be.
  29259.      If you don't specify any of the above options, the maximum size
  29260.      for a table will be 4G (or 2G if your operating systems only
  29261.      supports 2G tables). The reason for this is just to keep down the
  29262.      pointer sizes to make the index smaller and faster if you don't
  29263.      really need big files.
  29264.  
  29265.      If you don't use `PACK_KEYS', the default is to only pack strings,
  29266.      not numbers.  If you use `PACK_KEYS=1', numbers will be packed as
  29267.      well.
  29268.  
  29269.      When packing binary number keys, MySQL will use prefix compression.
  29270.      This means that you will only get a big benefit of this if you have
  29271.      many numbers that are the same.  Prefix compression means that
  29272.      every key needs one extra byte to indicate how many bytes of the
  29273.      previous key are the same for the next key (note that the pointer
  29274.      to the row is stored in high-byte-first-order directly after the
  29275.      key, to improve compression.)  This means that if you have many
  29276.      equal keys on two rows in a row, all following 'same' keys will
  29277.      usually only take 2 bytes (including the pointer to the row).
  29278.      Compare this to the ordinary case where the following keys will
  29279.      take storage_size_for_key + pointer_size (usually 4).  On the
  29280.      other hand, if all keys are totally different, you will lose 1
  29281.      byte per key, if the key isn't a key that can have `NULL' values
  29282.      (In this case the packed key length will be stored in the same
  29283.      byte that is used to mark if a key is `NULL'.)
  29284.  
  29285.    * If you specify a `SELECT' after the `CREATE' statement, MySQL will
  29286.      create new fields for all elements in the `SELECT'.  For example:
  29287.  
  29288.           mysql> CREATE TABLE test (a int not null auto_increment,
  29289.                      primary key (a), key(b))
  29290.                      TYPE=MyISAM SELECT b,c from test2;
  29291.  
  29292.      This will create a `MyISAM' table with three columns, a, b, and c.
  29293.      Notice that the columns from the `SELECT' statement are appended to
  29294.      the right side of the table, not overlapped onto it.  Take the
  29295.      following example:
  29296.  
  29297.           mysql> select * from foo;
  29298.           +---+
  29299.           | n |
  29300.           +---+
  29301.           | 1 |
  29302.           +---+
  29303.           
  29304.           mysql> create table bar (m int) select n from foo;
  29305.           Query OK, 1 row affected (0.02 sec)
  29306.           Records: 1  Duplicates: 0  Warnings: 0
  29307.           
  29308.           mysql> select * from bar;
  29309.           +------+---+
  29310.           | m    | n |
  29311.           +------+---+
  29312.           | NULL | 1 |
  29313.           +------+---+
  29314.           1 row in set (0.00 sec)
  29315.  
  29316.      For each row in table `foo', a row is inserted in `bar' with the
  29317.      values from `foo' and default values for the new columns.
  29318.  
  29319.      `CREATE TABLE ... SELECT' will not automatically create any indexes
  29320.      for you.  This is done intentionally to make the command as
  29321.      flexible as possible.  If you want to have indexes in the created
  29322.      table, you should specify these before the `SELECT' statement:
  29323.  
  29324.           mysql> create table bar (unique (n)) select n from foo;
  29325.  
  29326.      If any errors occur while copying the data to the table, it will
  29327.      automatically be deleted.
  29328.  
  29329.      To ensure that the update log/binary log can be used to re-create
  29330.      the original tables, MySQL will not allow concurrent inserts during
  29331.      `CREATE TABLE .... SELECT'.
  29332.  
  29333.    * The `RAID_TYPE' option will help you to break the 2G/4G limit for
  29334.      the MyISAM data file (not the index file) on operating systems
  29335.      that don't support big files. You can get also more speed from the
  29336.      I/O bottleneck by putting `RAID' directories on different physical
  29337.      disks. `RAID_TYPE' will work on any OS, as long as you have
  29338.      configured MySQL with `--with-raid'.  For now the only allowed
  29339.      `RAID_TYPE' is `STRIPED' (`1' and `RAID0' are aliases for this).
  29340.  
  29341.      If you specify `RAID_TYPE=STRIPED' for a `MyISAM' table, `MyISAM'
  29342.      will create `RAID_CHUNKS' subdirectories named 00, 01, 02 in the
  29343.      database directory.  In each of these directories `MyISAM' will
  29344.      create a `table_name.MYD'.  When writing data to the data file,
  29345.      the `RAID' handler will map the first `RAID_CHUNKSIZE' *1024 bytes
  29346.      to the first file, the next `RAID_CHUNKSIZE' *1024 bytes to the
  29347.      next file and so on.
  29348.  
  29349.    * `UNION' is used when you want to use a collection of identical
  29350.      tables as one. This only works with MERGE tables. *Note MERGE::.
  29351.  
  29352.      For the moment you need to have `SELECT', `UPDATE', and `DELETE'
  29353.      privileges on the tables you map to a `MERGE' table.  All mapped
  29354.      tables must be in the same database as the `MERGE' table.
  29355.  
  29356.    * In the created table the `PRIMARY' key will be placed first,
  29357.      followed by all `UNIQUE' keys and then the normal keys.  This
  29358.      helps the MySQL optimizer to prioritize which key to use and also
  29359.      more quickly detect duplicated `UNIQUE' keys.
  29360.  
  29361.    * By using `DATA DIRECTORY="directory"' or `INDEX
  29362.      DIRECTORY="directory"' you can specify where the table handler
  29363.      should put it's table and index files.  This only works for
  29364.      `MyISAM' tables in `MySQL' 4.0, when you are not using the
  29365.      `--skip-symlink' option. *Note Symbolic links to tables::.
  29366.  
  29367.  
  29368. 
  29369. File: mysql.info,  Node: Silent column changes,  Prev: CREATE TABLE,  Up: CREATE TABLE
  29370.  
  29371. Silent Column Specification Changes
  29372. ...................................
  29373.  
  29374. In some cases, MySQL silently changes a column specification from that
  29375. given in a `CREATE TABLE' statement.  (This may also occur with `ALTER
  29376. TABLE'.):
  29377.  
  29378.    * `VARCHAR' columns with a length less than four are changed to
  29379.      `CHAR'.
  29380.  
  29381.    * If any column in a table has a variable length, the entire row is
  29382.      variable-length as a result.  Therefore, if a table contains any
  29383.      variable-length columns (`VARCHAR', `TEXT', or `BLOB'), all `CHAR'
  29384.      columns longer than three characters are changed to `VARCHAR'
  29385.      columns.  This doesn't affect how you use the columns in any way;
  29386.      in MySQL, `VARCHAR' is just a different way to store characters.
  29387.      MySQL performs this conversion because it saves space and makes
  29388.      table operations faster.  *Note Table types::.
  29389.  
  29390.    * `TIMESTAMP' display sizes must be even and in the range from 2 to
  29391.      14.  If you specify a display size of 0 or greater than 14, the
  29392.      size is coerced to 14.  Odd-valued sizes in the range from 1 to 13
  29393.      are coerced to the next higher even number.
  29394.  
  29395.    * You cannot store a literal `NULL' in a `TIMESTAMP' column; setting
  29396.      it to `NULL' sets it to the current date and time.  Because
  29397.      `TIMESTAMP' columns behave this way, the `NULL' and `NOT NULL'
  29398.      attributes do not apply in the normal way and are ignored if you
  29399.      specify them.  `DESCRIBE tbl_name' always reports that a
  29400.      `TIMESTAMP' column may be assigned `NULL' values.
  29401.  
  29402.    * MySQL maps certain column types used by other SQL database vendors
  29403.      to MySQL types.  *Note Other-vendor column types::.
  29404.  
  29405. If you want to see whether or not MySQL used a column type other than
  29406. the one you specified, issue a `DESCRIBE tbl_name' statement after
  29407. creating or altering your table.
  29408.  
  29409. Certain other column type changes may occur if you compress a table
  29410. using `myisampack'. *Note Compressed format::.
  29411.  
  29412. 
  29413. File: mysql.info,  Node: ALTER TABLE,  Next: RENAME TABLE,  Prev: CREATE TABLE,  Up: Data Definition
  29414.  
  29415. `ALTER TABLE' Syntax
  29416. --------------------
  29417.  
  29418.      ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec ...]
  29419.      
  29420.      alter_specification:
  29421.              ADD [COLUMN] create_definition [FIRST | AFTER column_name ]
  29422.        or    ADD [COLUMN] (create_definition, create_definition,...)
  29423.        or    ADD INDEX [index_name] (index_col_name,...)
  29424.        or    ADD PRIMARY KEY (index_col_name,...)
  29425.        or    ADD UNIQUE [index_name] (index_col_name,...)
  29426.        or    ADD FULLTEXT [index_name] (index_col_name,...)
  29427.        or    ADD [CONSTRAINT symbol] FOREIGN KEY index_name (index_col_name,...)
  29428.                  [reference_definition]
  29429.        or    ALTER [COLUMN] col_name {SET DEFAULT literal | DROP DEFAULT}
  29430.        or    CHANGE [COLUMN] old_col_name create_definition
  29431.        or    MODIFY [COLUMN] create_definition
  29432.        or    DROP [COLUMN] col_name
  29433.        or    DROP PRIMARY KEY
  29434.        or    DROP INDEX index_name
  29435.        or    RENAME [TO] new_tbl_name
  29436.        or    ORDER BY col
  29437.        or    table_options
  29438.  
  29439. `ALTER TABLE' allows you to change the structure of an existing table.
  29440. For example, you can add or delete columns, create or destroy indexes,
  29441. change the type of existing columns, or rename columns or the table
  29442. itself.  You can also change the comment for the table and type of the
  29443. table.  *Note `CREATE TABLE': CREATE TABLE.
  29444.  
  29445. If you use `ALTER TABLE' to change a column specification but `DESCRIBE
  29446. tbl_name' indicates that your column was not changed, it is possible
  29447. that MySQL ignored your modification for one of the reasons described
  29448. in *Note Silent column changes::.  For example, if you try to change a
  29449. `VARCHAR' column to `CHAR', MySQL will still use `VARCHAR' if the table
  29450. contains other variable-length columns.
  29451.  
  29452. `ALTER TABLE' works by making a temporary copy of the original table.
  29453. The alteration is performed on the copy, then the original table is
  29454. deleted and the new one is renamed. This is done in such a way that all
  29455. updates are automatically redirected to the new table without any
  29456. failed updates. While `ALTER TABLE' is executing, the original table is
  29457. readable by other clients. Updates and writes to the table are stalled
  29458. until the new table is ready.
  29459.  
  29460. Note that if you use any other option to `ALTER TABLE' than `RENAME',
  29461. MySQL will always create a temporary table, even if the data wouldn't
  29462. strictly need to be copied (like when you change the name of a column).
  29463. We plan to fix this in the future, but as one doesn't normally do
  29464. `ALTER TABLE' that often this isn't that high on our TODO.
  29465.  
  29466.    * To use `ALTER TABLE', you need *ALTER*, *INSERT*, and *CREATE*
  29467.      privileges on the table.
  29468.  
  29469.    * `IGNORE' is a MySQL extension to ANSI SQL92.  It controls how
  29470.      `ALTER TABLE' works if there are duplicates on unique keys in the
  29471.      new table.  If `IGNORE' isn't specified, the copy is aborted and
  29472.      rolled back.  If `IGNORE' is specified, then for rows with
  29473.      duplicates on a unique key, only the first row is used; the others
  29474.      are deleted.
  29475.  
  29476.    * You can issue multiple `ADD', `ALTER', `DROP', and `CHANGE'
  29477.      clauses in a single `ALTER TABLE' statement. This is a MySQL
  29478.      extension to ANSI SQL92, which allows only one of each clause per
  29479.      `ALTER TABLE' statement.
  29480.  
  29481.    * `CHANGE col_name', `DROP col_name', and `DROP INDEX' are MySQL
  29482.      extensions to ANSI SQL92.
  29483.  
  29484.    * `MODIFY' is an Oracle extension to `ALTER TABLE'.
  29485.  
  29486.    * The optional word `COLUMN' is a pure noise word and can be omitted.
  29487.  
  29488.    * If you use `ALTER TABLE tbl_name RENAME TO new_name' without any
  29489.      other options, MySQL simply renames the files that correspond to
  29490.      the table `tbl_name'.  There is no need to create the temporary
  29491.      table.  *Note `RENAME TABLE': RENAME TABLE.
  29492.  
  29493.    * `create_definition' clauses use the same syntax for `ADD' and
  29494.      `CHANGE' as for `CREATE TABLE'.  Note that this syntax includes
  29495.      the column name, not just the column type.  *Note `CREATE TABLE':
  29496.      CREATE TABLE.
  29497.  
  29498.    * You can rename a column using a `CHANGE old_col_name
  29499.      create_definition' clause.  To do so, specify the old and new
  29500.      column names and the type that the column currently has.  For
  29501.      example, to rename an `INTEGER' column from `a' to `b', you can do
  29502.      this:
  29503.  
  29504.           mysql> ALTER TABLE t1 CHANGE a b INTEGER;
  29505.  
  29506.      If you want to change a column's type but not the name, `CHANGE'
  29507.      syntax still requires two column names even if they are the same.
  29508.      For example:
  29509.  
  29510.           mysql> ALTER TABLE t1 CHANGE b b BIGINT NOT NULL;
  29511.  
  29512.      However, as of MySQL Version 3.22.16a, you can also use `MODIFY'
  29513.      to change a column's type without renaming it:
  29514.  
  29515.           mysql> ALTER TABLE t1 MODIFY b BIGINT NOT NULL;
  29516.  
  29517.    * If you use `CHANGE' or `MODIFY' to shorten a column for which an
  29518.      index exists on part of the column (for instance, if you have an
  29519.      index on the first 10 characters of a `VARCHAR' column), you
  29520.      cannot make the column shorter than the number of characters that
  29521.      are indexed.
  29522.  
  29523.    * When you change a column type using `CHANGE' or `MODIFY', MySQL
  29524.      tries to convert data to the new type as well as possible.
  29525.  
  29526.    * In MySQL Version 3.22 or later, you can use `FIRST' or `ADD ...
  29527.      AFTER col_name' to add a column at a specific position within a
  29528.      table row. The default is to add the column last.
  29529.  
  29530.    * `ALTER COLUMN' specifies a new default value for a column or
  29531.      removes the old default value.  If the old default is removed and
  29532.      the column can be `NULL', the new default is `NULL'. If the column
  29533.      cannot be `NULL', MySQL assigns a default value, as described in
  29534.      *Note `CREATE TABLE': CREATE TABLE.
  29535.  
  29536.    * `DROP INDEX' removes an index. This is a MySQL extension to ANSI
  29537.      SQL92. *Note DROP INDEX::.
  29538.  
  29539.    * If columns are dropped from a table, the columns are also removed
  29540.      from any index of which they are a part.  If all columns that make
  29541.      up an index are dropped, the index is dropped as well.
  29542.  
  29543.    * If a table contains only one column, the column cannot be dropped.
  29544.      If what you intend is to remove the table, use `DROP TABLE'
  29545.      instead.
  29546.  
  29547.    * `DROP PRIMARY KEY' drops the primary index. If no such index
  29548.      exists, it drops the first `UNIQUE' index in the table.  (MySQL
  29549.      marks the first `UNIQUE' key as the `PRIMARY KEY' if no `PRIMARY
  29550.      KEY' was specified explicitly.)
  29551.  
  29552.      If you add a `UNIQUE INDEX' or `PRIMARY KEY' to a table, this is
  29553.      stored before any not `UNIQUE' index so that MySQL can detect
  29554.      duplicate keys as early as possible.
  29555.  
  29556.    * `ORDER BY' allows you to create the new table with the rows in a
  29557.      specific order.  Note that the table will not remain in this order
  29558.      after inserts and deletes.  In some cases, it may make sorting
  29559.      easier for MySQL if the table is in order by the column that you
  29560.      wish to order it by later.  This option is mainly useful when you
  29561.      know that you are mostly going to query the rows in a certain
  29562.      order; By using this option after big changes to the table, you
  29563.      may be able to get higher performance.
  29564.  
  29565.    * If you use `ALTER TABLE' on a `MyISAM' table, all non-unique
  29566.      indexes are created in a separate batch (like in `REPAIR').  This
  29567.      should make `ALTER TABLE' much faster when you have many indexes.
  29568.  
  29569.    * With the C API function `mysql_info()', you can find out how many
  29570.      records were copied, and (when `IGNORE' is used) how many records
  29571.      were deleted due to duplication of unique key values.
  29572.  
  29573.    * The `FOREIGN KEY', `CHECK', and `REFERENCES' clauses don't
  29574.      actually do anything.  The syntax for them is provided only for
  29575.      compatibility, to make it easier to port code from other SQL
  29576.      servers and to run applications that create tables with references.
  29577.      *Note Missing functions::.
  29578.  
  29579. Here is an example that shows some of the uses of `ALTER TABLE'.  We
  29580. begin with a table `t1' that is created as shown below:
  29581.  
  29582.      mysql> CREATE TABLE t1 (a INTEGER,b CHAR(10));
  29583.  
  29584. To rename the table from `t1' to `t2':
  29585.  
  29586.      mysql> ALTER TABLE t1 RENAME t2;
  29587.  
  29588. To change column `a' from `INTEGER' to `TINYINT NOT NULL' (leaving the
  29589. name the same), and to change column `b' from `CHAR(10)' to `CHAR(20)'
  29590. as well as renaming it from `b' to `c':
  29591.  
  29592.      mysql> ALTER TABLE t2 MODIFY a TINYINT NOT NULL, CHANGE b c CHAR(20);
  29593.  
  29594. To add a new `TIMESTAMP' column named `d':
  29595.  
  29596.      mysql> ALTER TABLE t2 ADD d TIMESTAMP;
  29597.  
  29598. To add an index on column `d', and make column `a' the primary key:
  29599.  
  29600.      mysql> ALTER TABLE t2 ADD INDEX (d), ADD PRIMARY KEY (a);
  29601.  
  29602. To remove column `c':
  29603.  
  29604.      mysql> ALTER TABLE t2 DROP COLUMN c;
  29605.  
  29606. To add a new `AUTO_INCREMENT' integer column named `c':
  29607.  
  29608.      mysql> ALTER TABLE t2 ADD c INT UNSIGNED NOT NULL AUTO_INCREMENT,
  29609.                 ADD INDEX (c);
  29610.  
  29611. Note that we indexed `c', because `AUTO_INCREMENT' columns must be
  29612. indexed, and also that we declare `c' as `NOT NULL', because indexed
  29613. columns cannot be `NULL'.
  29614.  
  29615. When you add an `AUTO_INCREMENT' column, column values are filled in
  29616. with sequence numbers for you automatically.  You can set the first
  29617. sequence number by executing `SET INSERT_ID=#' before `ALTER TABLE' or
  29618. using the `AUTO_INCREMENT = #' table option.  *Note SET OPTION::.
  29619.  
  29620. With MyISAM tables, if you don't change the `AUTO_INCREMENT' column,
  29621. the sequence number will not be affected. If you drop an
  29622. `AUTO_INCREMENT' column and then add another `AUTO_INCREMENT' column,
  29623. the numbers will start from 1 again.
  29624.  
  29625. *Note ALTER TABLE problems::.
  29626.  
  29627. 
  29628. File: mysql.info,  Node: RENAME TABLE,  Next: DROP TABLE,  Prev: ALTER TABLE,  Up: Data Definition
  29629.  
  29630. `RENAME TABLE' Syntax
  29631. ---------------------
  29632.  
  29633.      RENAME TABLE tbl_name TO new_table_name[, tbl_name2 TO new_table_name2,...]
  29634.  
  29635. The rename is done atomically, which means that no other thread can
  29636. access any of the tables while the rename is running. This makes it
  29637. possible to replace a table with an empty one:
  29638.  
  29639.      CREATE TABLE new_table (...);
  29640.      RENAME TABLE old_table TO backup_table, new_table TO old_table;
  29641.  
  29642. The rename is done from left to right, which means that if you want to
  29643. swap two tables names, you have to:
  29644.  
  29645.      RENAME TABLE old_table    TO backup_table,
  29646.                   new_table    TO old_table,
  29647.                   backup_table TO new_table;
  29648.  
  29649. As long as two databases are on the same disk you can also rename from
  29650. one database to another:
  29651.  
  29652.      RENAME TABLE current_database.table_name TO other_database.table_name;
  29653.  
  29654. When you execute `RENAME', you can't have any locked tables or active
  29655. transactions.  You must also have the `ALTER' and `DROP' privilege on
  29656. the original table and `CREATE' and `INSERT' privilege on the new table.
  29657.  
  29658. If MySQL encounters any errors in a multiple table rename, it will do a
  29659. reverse rename for all renamed tables to get everything back to the
  29660. original state.
  29661.  
  29662. 
  29663. File: mysql.info,  Node: DROP TABLE,  Next: CREATE INDEX,  Prev: RENAME TABLE,  Up: Data Definition
  29664.  
  29665. `DROP TABLE' Syntax
  29666. -------------------
  29667.  
  29668.      DROP TABLE [IF EXISTS] tbl_name [, tbl_name,...] [RESTRICT | CASCADE]
  29669.  
  29670. `DROP TABLE' removes one or more tables. All table data and the table
  29671. definition are _removed_, so *be careful* with this command!
  29672.  
  29673. In MySQL Version 3.22 or later, you can use the keywords `IF EXISTS' to
  29674. prevent an error from occurring for tables that don't exist.
  29675.  
  29676. `RESTRICT' and `CASCADE' are allowed to make porting easier.  For the
  29677. moment they don't do anything.
  29678.  
  29679. *NOTE*: `DROP TABLE' is not transaction-safe and will automatically
  29680. commit any active transactions.
  29681.  
  29682. 
  29683. File: mysql.info,  Node: CREATE INDEX,  Next: DROP INDEX,  Prev: DROP TABLE,  Up: Data Definition
  29684.  
  29685. `CREATE INDEX' Syntax
  29686. ---------------------
  29687.  
  29688.      CREATE [UNIQUE|FULLTEXT] INDEX index_name ON tbl_name (col_name[(length)],... )
  29689.  
  29690. The `CREATE INDEX' statement doesn't do anything in MySQL prior to
  29691. Version 3.22.  In Version 3.22 or later, `CREATE INDEX' is mapped to an
  29692. `ALTER TABLE' statement to create indexes.  *Note `ALTER TABLE': ALTER
  29693. TABLE.
  29694.  
  29695. Normally, you create all indexes on a table at the time the table itself
  29696. is created with `CREATE TABLE'.  *Note `CREATE TABLE': CREATE TABLE.
  29697. `CREATE INDEX' allows you to add indexes to existing tables.
  29698.  
  29699. A column list of the form `(col1,col2,...)' creates a multiple-column
  29700. index.  Index values are formed by concatenating the values of the given
  29701. columns.
  29702.  
  29703. For `CHAR' and `VARCHAR' columns, indexes can be created that use only
  29704. part of a column, using `col_name(length)' syntax.  (On `BLOB' and
  29705. `TEXT' columns the length is required). The statement shown below
  29706. creates an index using the first 10 characters of the `name' column:
  29707.  
  29708.      mysql> CREATE INDEX part_of_name ON customer (name(10));
  29709.  
  29710. Because most names usually differ in the first 10 characters, this
  29711. index should not be much slower than an index created from the entire
  29712. `name' column.  Also, using partial columns for indexes can make the
  29713. index file much smaller, which could save a lot of disk space and might
  29714. also speed up `INSERT' operations!
  29715.  
  29716. Note that you can only add an index on a column that can have `NULL'
  29717. values or on a `BLOB'/`TEXT' column if you are using MySQL Version
  29718. 3.23.2 or newer and are using the `MyISAM' table type.
  29719.  
  29720. For more information about how MySQL uses indexes, see *Note MySQL
  29721. indexes: MySQL indexes.
  29722.  
  29723. `FULLTEXT' indexes can index only `VARCHAR' and `TEXT' columns, and
  29724. only in `MyISAM' tables. `FULLTEXT' indexes are available in MySQL
  29725. Version 3.23.23 and later.  *Note Fulltext Search::.
  29726.  
  29727. 
  29728. File: mysql.info,  Node: DROP INDEX,  Prev: CREATE INDEX,  Up: Data Definition
  29729.  
  29730. `DROP INDEX' Syntax
  29731. -------------------
  29732.  
  29733.      DROP INDEX index_name ON tbl_name
  29734.  
  29735. `DROP INDEX' drops the index named `index_name' from the table
  29736. `tbl_name'.  `DROP INDEX' doesn't do anything in MySQL prior to Version
  29737. 3.22.  In Version 3.22 or later, `DROP INDEX' is mapped to an `ALTER
  29738. TABLE' statement to drop the index.  *Note `ALTER TABLE': ALTER TABLE.
  29739.  
  29740. 
  29741. File: mysql.info,  Node: Basic User Commands,  Next: Transactional Commands,  Prev: Data Definition,  Up: Reference
  29742.  
  29743. Basic MySQL User Utility Commands
  29744. =================================
  29745.  
  29746. * Menu:
  29747.  
  29748. * USE::                         `USE' Syntax
  29749. * DESCRIBE::                    `DESCRIBE' Syntax (Get Information About Columns)
  29750.  
  29751. 
  29752. File: mysql.info,  Node: USE,  Next: DESCRIBE,  Prev: Basic User Commands,  Up: Basic User Commands
  29753.  
  29754. `USE' Syntax
  29755. ------------
  29756.  
  29757.      USE db_name
  29758.  
  29759. The `USE db_name' statement tells MySQL to use the `db_name' database
  29760. as the default database for subsequent queries.  The database remains
  29761. current until the end of the session or until another `USE' statement
  29762. is issued:
  29763.  
  29764.      mysql> USE db1;
  29765.      mysql> SELECT count(*) FROM mytable;      # selects from db1.mytable
  29766.      mysql> USE db2;
  29767.      mysql> SELECT count(*) FROM mytable;      # selects from db2.mytable
  29768.  
  29769. Making a particular database current by means of the `USE' statement
  29770. does not preclude you from accessing tables in other databases.  The
  29771. example below accesses the `author' table from the `db1' database and
  29772. the `editor' table from the `db2' database:
  29773.  
  29774.      mysql> USE db1;
  29775.      mysql> SELECT author_name,editor_name FROM author,db2.editor
  29776.                 WHERE author.editor_id = db2.editor.editor_id;
  29777.  
  29778. The `USE' statement is provided for Sybase compatibility.
  29779.  
  29780. 
  29781. File: mysql.info,  Node: DESCRIBE,  Prev: USE,  Up: Basic User Commands
  29782.  
  29783. `DESCRIBE' Syntax (Get Information About Columns)
  29784. -------------------------------------------------
  29785.  
  29786.      {DESCRIBE | DESC} tbl_name {col_name | wild}
  29787.  
  29788. `DESCRIBE' is a shortcut for `SHOW COLUMNS FROM'.  *Note SHOW DATABASE
  29789. INFO::.
  29790.  
  29791. `DESCRIBE' provides information about a table's columns.  `col_name'
  29792. may be a column name or a string containing the SQL `%' and `_'
  29793. wild-card characters.
  29794.  
  29795. If the column types are different than you expect them to be based on a
  29796. `CREATE TABLE' statement, note that MySQL sometimes changes column
  29797. types.  *Note Silent column changes::.
  29798.  
  29799. This statement is provided for Oracle compatibility.
  29800.  
  29801. The `SHOW' statement provides similar information.  *Note `SHOW': SHOW.
  29802.  
  29803. 
  29804. File: mysql.info,  Node: Transactional Commands,  Next: Fulltext Search,  Prev: Basic User Commands,  Up: Reference
  29805.  
  29806. MySQL Transactional and Locking Commands
  29807. ========================================
  29808.  
  29809. * Menu:
  29810.  
  29811. * COMMIT::                      `BEGIN/COMMIT/ROLLBACK' Syntax
  29812. * LOCK TABLES::                 `LOCK TABLES/UNLOCK TABLES' Syntax
  29813. * SET TRANSACTION::             `SET TRANSACTION' Syntax
  29814.  
  29815. 
  29816. File: mysql.info,  Node: COMMIT,  Next: LOCK TABLES,  Prev: Transactional Commands,  Up: Transactional Commands
  29817.  
  29818. `BEGIN/COMMIT/ROLLBACK' Syntax
  29819. ------------------------------
  29820.  
  29821. By default, MySQL runs in `autocommit' mode. This means that as soon as
  29822. you execute an update, MySQL will store the update on disk.
  29823.  
  29824. If you are using transactions safe tables (like `BDB', `InnoDB', you
  29825. can put MySQL into non-`autocommit' mode with the following command:
  29826.  
  29827.      SET AUTOCOMMIT=0
  29828.  
  29829. After this you must use `COMMIT' to store your changes to disk or
  29830. `ROLLBACK' if you want to ignore the changes you have made since the
  29831. beginning of your transaction.
  29832.  
  29833. If you want to switch from `AUTOCOMMIT' mode for one series of
  29834. statements, you can use the `BEGIN' or `BEGIN WORK' statement:
  29835.  
  29836.      BEGIN;
  29837.      SELECT @A:=SUM(salary) FROM table1 WHERE type=1;
  29838.      UPDATE table2 SET summmary=@A WHERE type=1;
  29839.      COMMIT;
  29840.  
  29841. Note that if you are using non-transaction-safe tables, the changes
  29842. will be stored at once, independent of the status of the `autocommit'
  29843. mode.
  29844.  
  29845. If you do a `ROLLBACK' when you have updated a non-transactional table
  29846. you will get an error (`ER_WARNING_NOT_COMPLETE_ROLLBACK') as a
  29847. warning.  All transactional safe tables will be restored but any
  29848. non-transactional table will not change.
  29849.  
  29850. If you are using `BEGIN' or `SET AUTOCOMMIT=0', you should use the
  29851. MySQL binary log for backups instead of the older update log.
  29852. Transactions are stored in the binary log in one chunk, upon `COMMIT',
  29853. to ensure that transactions which are rolled back are not stored.
  29854. *Note Binary log::.
  29855.  
  29856. The following commands automatically end a transaction (as if you had
  29857. done a `COMMIT' before executing the command):
  29858.  
  29859. `ALTER TABLE'            `BEGIN'                  `CREATE INDEX'
  29860. `DROP DATABASE'          `DROP TABLE'             `RENAME TABLE'
  29861. `TRUNCATE'                                        
  29862.  
  29863. You can change the isolation level for transactions with `SET
  29864. TRANSACTION ISOLATION LEVEL ...'. *Note SET TRANSACTION::.
  29865.  
  29866. 
  29867. File: mysql.info,  Node: LOCK TABLES,  Next: SET TRANSACTION,  Prev: COMMIT,  Up: Transactional Commands
  29868.  
  29869. `LOCK TABLES/UNLOCK TABLES' Syntax
  29870. ----------------------------------
  29871.  
  29872.      LOCK TABLES tbl_name [AS alias] {READ | [READ LOCAL] | [LOW_PRIORITY] WRITE}
  29873.                  [, tbl_name {READ | [LOW_PRIORITY] WRITE} ...]
  29874.      ...
  29875.      UNLOCK TABLES
  29876.  
  29877. `LOCK TABLES' locks tables for the current thread.  `UNLOCK TABLES'
  29878. releases any locks held by the current thread.  All tables that are
  29879. locked by the current thread are automatically unlocked when the thread
  29880. issues another `LOCK TABLES', or when the connection to the server is
  29881. closed.
  29882.  
  29883. The main reasons to use `LOCK TABLES' are for emulating transactions or
  29884. getting more speed when updating tables.  This is explained in more
  29885. detail later.
  29886.  
  29887. If a thread obtains a `READ' lock on a table, that thread (and all other
  29888. threads) can only read from the table. If a thread obtains a `WRITE'
  29889. lock on a table, then only the thread holding the lock can `READ' from
  29890. or `WRITE' to the table.  Other threads are blocked.
  29891.  
  29892. The difference between `READ LOCAL' and `READ' is that `READ LOCAL'
  29893. allows non-conflicting `INSERT' statements to execute while the lock is
  29894. held.  This can't however be used if you are going to manipulate the
  29895. database files outside MySQL while you hold the lock.
  29896.  
  29897. When you use `LOCK TABLES', you must lock all tables that you are going
  29898. to use and you must use the same alias that you are going to use in
  29899. your queries!  If you are using a table multiple times in a query (with
  29900. aliases), you must get a lock for each alias!
  29901.  
  29902. `WRITE' locks normally have higher priority than `READ' locks, to
  29903. ensure that updates are processed as soon as possible. This means that
  29904. if one thread obtains a `READ' lock and then another thread requests a
  29905. `WRITE' lock, subsequent `READ' lock requests will wait until the
  29906. `WRITE' thread has gotten the lock and released it.  You can use
  29907. `LOW_PRIORITY WRITE' locks to allow other threads to obtain `READ'
  29908. locks while the thread is waiting for the `WRITE' lock. You should only
  29909. use `LOW_PRIORITY WRITE' locks if you are sure that there will
  29910. eventually be a time when no threads will have a `READ' lock.
  29911.  
  29912. `LOCK TABLES' works as follows:
  29913.   1. Sort all tables to be locked in a internally defined order (from
  29914.      the user standpoint the order is undefined).
  29915.  
  29916.   2. If a table is locked with a read and a write lock, put the write
  29917.      lock before the read lock.
  29918.  
  29919.   3. Lock one table at a time until the thread gets all locks.
  29920.  
  29921. This policy ensures that table locking is deadlock free. There is
  29922. however other things one needs to be aware of with this schema:
  29923.  
  29924. If you are using a `LOW_PRIORITY_WRITE' lock for a table, this means
  29925. only that MySQL will wait for this particlar lock until there is no
  29926. threads that wants a `READ' lock.  When the thread has got the `WRITE'
  29927. lock and is waiting to get the lock for the next table in the lock
  29928. table list, all other threads will wait for the `WRITE' lock to be
  29929. released.  If this becomes a serious problem with your application, you
  29930. should consider converting some of your tables to transactions safe
  29931. tables.
  29932.  
  29933. You can safely kill a thread that is waiting for a table lock with
  29934. `KILL'.  *Note KILL::.
  29935.  
  29936. Note that you should *NOT* lock any tables that you are using with
  29937. `INSERT DELAYED'.  This is because that in this case the `INSERT' is
  29938. done by a separate thread.
  29939.  
  29940. Normally, you don't have to lock tables, as all single `UPDATE'
  29941. statements are atomic; no other thread can interfere with any other
  29942. currently executing SQL statement. There are a few cases when you would
  29943. like to lock tables anyway:
  29944.  
  29945.    * If you are going to run many operations on a bunch of tables, it's
  29946.      much faster to lock the tables you are going to use.  The downside
  29947.      is, of course, that no other thread can update a `READ'-locked
  29948.      table and no other thread can read a `WRITE'-locked table.
  29949.  
  29950.      The reason some things are faster under `LOCK TABLES' is that
  29951.      MySQL will not flush the key cache for the locked tables until
  29952.      `UNLOCK TABLES' is called (normally the key cache is flushed after
  29953.      each SQL statement). This speeds up inserting/updateing/deletes on
  29954.      `MyISAM' tables.
  29955.  
  29956.    * If you are using a table handler in MySQL that doesn't support
  29957.      transactions, you must use `LOCK TABLES' if you want to ensure that
  29958.      no other thread comes between a `SELECT' and an `UPDATE'. The
  29959.      example shown below requires `LOCK TABLES' in order to execute
  29960.      safely:
  29961.  
  29962.           mysql> LOCK TABLES trans READ, customer WRITE;
  29963.           mysql> select sum(value) from trans where customer_id= some_id;
  29964.           mysql> update customer set total_value=sum_from_previous_statement
  29965.                      where customer_id=some_id;
  29966.           mysql> UNLOCK TABLES;
  29967.  
  29968.      Without `LOCK TABLES', there is a chance that another thread might
  29969.      insert a new row in the `trans' table between execution of the
  29970.      `SELECT' and `UPDATE' statements.
  29971.  
  29972. By using incremental updates (`UPDATE customer SET
  29973. value=value+new_value') or the `LAST_INSERT_ID()' function, you can
  29974. avoid using `LOCK TABLES' in many cases.
  29975.  
  29976. You can also solve some cases by using the user-level lock functions
  29977. `GET_LOCK()' and `RELEASE_LOCK()'.  These locks are saved in a hash
  29978. table in the server and implemented with `pthread_mutex_lock()' and
  29979. `pthread_mutex_unlock()' for high speed.  *Note Miscellaneous
  29980. functions::.
  29981.  
  29982. See *Note Internal locking::, for more information on locking policy.
  29983.  
  29984. You can lock all tables in all databases with read locks with the
  29985. `FLUSH TABLES WITH READ LOCK' command. *Note FLUSH::. This is very
  29986. convenient way to get backups if you have a file system, like Veritas,
  29987. that can take snapshots in time.
  29988.  
  29989. *NOTE*: `LOCK TABLES' is not transaction-safe and will automatically
  29990. commit any active transactions before attempting to lock the tables.
  29991.  
  29992. 
  29993. File: mysql.info,  Node: SET TRANSACTION,  Prev: LOCK TABLES,  Up: Transactional Commands
  29994.  
  29995. `SET TRANSACTION' Syntax
  29996. ------------------------
  29997.  
  29998.      SET [GLOBAL | SESSION] TRANSACTION ISOLATION LEVEL
  29999.      [READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE]
  30000.  
  30001. Sets the transaction isolation level for the global, whole session or
  30002. the next transaction.
  30003.  
  30004. The default behavior is to set the isolation level for the next (not
  30005. started) transaction.
  30006.  
  30007. If you set the `GLOBAL' privilege it will affect all new created
  30008. threads.  You will need the `PROCESS' privilege to do do this.
  30009.  
  30010. Setting the `SESSION' privilege will affect the following and all
  30011. future transactions.
  30012.  
  30013. You can set the default isolation level for `mysqld' with
  30014. `--transaction-isolation=...'. *Note Command-line options::.
  30015.  
  30016. 
  30017. File: mysql.info,  Node: Fulltext Search,  Prev: Transactional Commands,  Up: Reference
  30018.  
  30019. MySQL Full-text Search
  30020. ======================
  30021.  
  30022. Since Version 3.23.23, MySQL has support for full-text indexing and
  30023. searching.  Full-text indexes in MySQL are an index of type `FULLTEXT'.
  30024. `FULLTEXT' indexes can be created from `VARCHAR' and `TEXT' columns at
  30025. `CREATE TABLE' time or added later with `ALTER TABLE' or `CREATE
  30026. INDEX'.  For large datasets, adding `FULLTEXT' index with `ALTER TABLE'
  30027. (or `CREATE INDEX') would be much faster than inserting rows into the
  30028. empty table with a `FULLTEXT' index.
  30029.  
  30030. Full-text search is performed with the `MATCH' function.
  30031.  
  30032.      mysql> CREATE TABLE articles (
  30033.          ->   id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
  30034.          ->   title VARCHAR(200),
  30035.          ->   body TEXT,
  30036.          ->   FULLTEXT (title,body)
  30037.          -> );
  30038.      Query OK, 0 rows affected (0.00 sec)
  30039.      
  30040.      mysql> INSERT INTO articles VALUES
  30041.          -> (0,'MySQL Tutorial', 'DBMS stands for DataBase Management ...'),
  30042.          -> (0,'How To Use MySQL Efficiently', 'After you went through a ...'),
  30043.          -> (0,'Optimizing MySQL','In this tutorial we will show how to ...'),
  30044.          -> (0,'1001 MySQL Trick','1. Never run mysqld as root. 2. Normalize ...'),
  30045.          -> (0,'MySQL vs. YourSQL', 'In the following database comparison we ...'),
  30046.          -> (0,'MySQL Security', 'When configured properly, MySQL could be ...');
  30047.      Query OK, 5 rows affected (0.00 sec)
  30048.      Records: 5  Duplicates: 0  Warnings: 0
  30049.      
  30050.      mysql> SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('database');
  30051.      +----+-------------------+---------------------------------------------+
  30052.      | id | title             | body                                        |
  30053.      +----+-------------------+---------------------------------------------+
  30054.      |  5 | MySQL vs. YourSQL | In the following database comparison we ... |
  30055.      |  1 | MySQL Tutorial    | DBMS stands for DataBase Management ...     |
  30056.      +----+-------------------+---------------------------------------------+
  30057.      2 rows in set (0.00 sec)
  30058.  
  30059. The function `MATCH' matches a natural language query `AGAINST' a text
  30060. collection (which is simply the set of columns covered by a `FULLTEXT'
  30061. index).  For every row in a table it returns relevance - a similarity
  30062. measure between the text in that row (in the columns that are part of
  30063. the collection) and the query.  When it is used in a `WHERE' clause
  30064. (see example above) the rows returned are automatically sorted with
  30065. relevance decreasing.  Relevance is a non-negative floating-point
  30066. number.  Zero relevance means no similarity.  Relevance is computed
  30067. based on the number of words in the row, the number of unique words in
  30068. that row, the total number of words in the collection, and the number
  30069. of documents (rows) that contain a particular word.
  30070.  
  30071. The above is a basic example of using `MATCH' function. Rows are
  30072. returned with relevance decreasing.
  30073.  
  30074.      mysql> SELECT id,MATCH (title,body) AGAINST ('Tutorial') FROM articles;
  30075.      +----+-----------------------------------------+
  30076.      | id | MATCH (title,body) AGAINST ('Tutorial') |
  30077.      +----+-----------------------------------------+
  30078.      |  1 |                        0.64840710366884 |
  30079.      |  2 |                                       0 |
  30080.      |  3 |                        0.66266459031789 |
  30081.      |  4 |                                       0 |
  30082.      |  5 |                                       0 |
  30083.      |  6 |                                       0 |
  30084.      +----+-----------------------------------------+
  30085.      5 rows in set (0.00 sec)
  30086.  
  30087. This example shows how to retrieve the relevances. As neither `WHERE'
  30088. nor `ORDER BY' clauses are present, returned rows are not ordered.
  30089.  
  30090.      mysql> SELECT id, body, MATCH (title,body) AGAINST (
  30091.          -> 'Security implications of running MySQL as root') AS score
  30092.          -> FROM articles WHERE MATCH (title,body) AGAINST
  30093.          -> ('Security implications of running MySQL as root');
  30094.      +----+-----------------------------------------------+-----------------+
  30095.      | id | body                                          | score           |
  30096.      +----+-----------------------------------------------+-----------------+
  30097.      |  4 | 1. Never run mysqld as root. 2. Normalize ... | 1.5055546709332 |
  30098.      |  6 | When configured properly, MySQL could be ...  |   1.31140957288 |
  30099.      +----+-----------------------------------------------+-----------------+
  30100.      2 rows in set (0.00 sec)
  30101.  
  30102. This is more complex example - the query returns the relevance and still
  30103. sorts the rows with relevance decreasing. To achieve it one should
  30104. specify `MATCH' twice. Note, that this will cause no additional
  30105. overhead, as MySQL optimizer will notice that these two `MATCH' calls
  30106. are identical and will call full-text search code only once.
  30107.  
  30108. MySQL uses a very simple parser to split text into words.  A "word" is
  30109. any sequence of letters, numbers, `'', and `_'.  Any "word" that is
  30110. present in the stopword list or just too short (3 characters or less)
  30111. is ignored.
  30112.  
  30113. Every correct word in the collection and in the query is weighted,
  30114. according to its significance in the query or collection.  This way, a
  30115. word that is present in many documents will have lower weight (and may
  30116. even have a zero weight), because it has lower semantic value in this
  30117. particular collection.  Otherwise, if the word is rare, it will receive
  30118. a higher weight.  The weights of the words are then combined to compute
  30119. the relevance of the row.
  30120.  
  30121. Such a technique works best with large collections (in fact, it was
  30122. carefully tuned this way).  For very small tables, word distribution
  30123. does not reflect adequately their semantical value, and this model may
  30124. sometimes produce bizarre results.
  30125.  
  30126.      mysql> SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('MySQL');
  30127.      Empty set (0.00 sec)
  30128.  
  30129. Search for the word `MySQL' produces no results in the above example.
  30130. Word `MySQL' is present in more than half of rows, and as such, is
  30131. effectively treated as a stopword (that is, with semantical value zero).
  30132. It is, really, the desired behavior - a natural language query should
  30133. not return every second row in 1GB table.
  30134.  
  30135. A word that matches half of rows in a table is less likely to locate
  30136. relevant documents.  In fact, it will most likely find plenty of
  30137. irrelevant documents.  We all know this happens far too often when we
  30138. are trying to find something on the Internet with a search engine.  It
  30139. is with this reasoning that such rows have been assigned a low
  30140. semantical value in *this particular dataset*.
  30141.  
  30142. * Menu:
  30143.  
  30144. * Fulltext restrictions::       Fulltext restrictions
  30145. * Fulltext Fine-tuning::        Fine-tuning MySQL Full-text Search
  30146. * Fulltext Features to Appear in MySQL 4.0::  New Features of Full-text Search to Appear in MySQL 4.0
  30147. * Fulltext TODO::               Full-text Search TODO
  30148.  
  30149. 
  30150. File: mysql.info,  Node: Fulltext restrictions,  Next: Fulltext Fine-tuning,  Prev: Fulltext Search,  Up: Fulltext Search
  30151.  
  30152. Fulltext restrictions
  30153. ---------------------
  30154.  
  30155.    * All parameters to the `MATCH' function must be columns from the
  30156.      same table that is part of the same fulltext index.
  30157.  
  30158.    * The argument to `AGAINST' must be a constant string.
  30159.  
  30160. 
  30161. File: mysql.info,  Node: Fulltext Fine-tuning,  Next: Fulltext Features to Appear in MySQL 4.0,  Prev: Fulltext restrictions,  Up: Fulltext Search
  30162.  
  30163. Fine-tuning MySQL Full-text Search
  30164. ----------------------------------
  30165.  
  30166. Unfortunately, full-text search has no user-tunable parameters yet,
  30167. although adding some is very high on the TODO.  However, if you have a
  30168. MySQL source distribution (*Note Installing source::.), you can
  30169. somewhat alter the full-text search behavior.
  30170.  
  30171. Note that full-text search was carefully tuned for the best searching
  30172. effectiveness.  Modifying the default behavior will, in most cases,
  30173. only make the search results worse.  Do not alter the MySQL sources
  30174. unless you know what you are doing!
  30175.  
  30176.    * Minimal length of word to be indexed is defined in
  30177.      `myisam/ftdefs.h' file by the line
  30178.           #define MIN_WORD_LEN 4
  30179.      Change it to the value you prefer, recompile MySQL, and rebuild
  30180.      your `FULLTEXT' indexes.
  30181.  
  30182.    * The stopword list is defined in `myisam/ft_static.c' Modify it to
  30183.      your taste, recompile MySQL and rebuild your `FULLTEXT' indexes.
  30184.  
  30185.    * The 50% threshold is caused by the particular weighting scheme
  30186.      chosen. To disable it, change the following line in
  30187.      `myisam/ftdefs.h':
  30188.           #define GWS_IN_USE GWS_PROB
  30189.      to
  30190.           #define GWS_IN_USE GWS_FREQ
  30191.      and recompile MySQL.  There is no need to rebuild the indexes in
  30192.      this case.
  30193.  
  30194.  
  30195. 
  30196. File: mysql.info,  Node: Fulltext Features to Appear in MySQL 4.0,  Next: Fulltext TODO,  Prev: Fulltext Fine-tuning,  Up: Fulltext Search
  30197.  
  30198. New Features of Full-text Search to Appear in MySQL 4.0
  30199. -------------------------------------------------------
  30200.  
  30201. This section includes a list of the fulltext features that are already
  30202. implemented in the 4.0 tree. It explains *More functions for full-text
  30203. search* entry of *Note TODO MySQL 4.0::.
  30204.  
  30205.    * `REPAIR TABLE' with `FULLTEXT' indexes, `ALTER TABLE' with
  30206.      `FULLTEXT' indexes, and `OPTIMIZE TABLE' with `FULLTEXT' indexes
  30207.      are now up to 100 times faster.
  30208.  
  30209.    * `MATCH ... AGAINST' is going to supports the following *boolean
  30210.      operators*:
  30211.  
  30212.         * `+'word means the that word *must* be present in every row
  30213.           returned.
  30214.  
  30215.         * `-'word means the that word *must not* be present in every
  30216.           row returned.
  30217.  
  30218.         * `<' and `>' can be used to decrease and increase word weight
  30219.           in the query.
  30220.  
  30221.         * `~' can be used to assign a *negative* weight to a noise word.
  30222.  
  30223.         * `*' is a truncation operator.
  30224.  
  30225.      Boolean search utilizes a more simplistic way of calculating the
  30226.      relevance, that does not have a 50% threshold.
  30227.  
  30228.    * Searches are now up to 2 times faster due to optimized search
  30229.      algorithm.
  30230.  
  30231.    * Utility program `ft_dump' added for low-level `FULLTEXT' index
  30232.      operations (querying/dumping/statistics).
  30233.  
  30234.  
  30235. 
  30236. File: mysql.info,  Node: Fulltext TODO,  Prev: Fulltext Features to Appear in MySQL 4.0,  Up: Fulltext Search
  30237.  
  30238. Full-text Search TODO
  30239. ---------------------
  30240.  
  30241.    * Make all operations with `FULLTEXT' index *faster*.
  30242.  
  30243.    * Support for braces `()' in boolean full-text search.
  30244.  
  30245.    * Phrase search, proximity operators
  30246.  
  30247.    * Boolean search can work without `FULLTEXT' index (yes, *very*
  30248.      slow).
  30249.  
  30250.    * Support for "always-index words". They could be any strings the
  30251.      user wants to treat as words, examples are "C++", "AS/400",
  30252.      "TCP/IP", etc.
  30253.  
  30254.    * Support for full-text search in `MERGE' tables.
  30255.  
  30256.    * Support for multi-byte charsets.
  30257.  
  30258.    * Make stopword list to depend of the language of the data.
  30259.  
  30260.    * Stemming (dependent of the language of the data, of course).
  30261.  
  30262.    * Generic user-supplyable UDF (?) preparser.
  30263.  
  30264.    * Make the model more flexible (by adding some adjustable parameters
  30265.      to `FULLTEXT' in `CREATE/ALTER TABLE').
  30266.  
  30267. 
  30268. File: mysql.info,  Node: Table types,  Next: Clients,  Prev: Reference,  Up: Top
  30269.  
  30270. MySQL Table Types
  30271. *****************
  30272.  
  30273. As of MySQL Version 3.23.6, you can choose between three basic table
  30274. formats (`ISAM', `HEAP' and `MyISAM'.  Newer MySQL may support
  30275. additional table type (`BDB', or `InnoDB'), depending on how you
  30276. compile it.
  30277.  
  30278. When you create a new table, you can tell MySQL which table type it
  30279. should use for the table.  MySQL will always create a `.frm' file to
  30280. hold the table and column definitions.  Depending on the table type,
  30281. the index and data will be stored in other files.
  30282.  
  30283. Note that to use `InnoDB' tables you have to use at least the
  30284. `innodb_data_file_path' startup option. *Note InnoDB start::.
  30285.  
  30286. The default table type in MySQL is `MyISAM'. If you are trying to use a
  30287. table type that is not compiled-in or activated, MySQL will instead
  30288. create a table of type `MyISAM'.  This is a very useful feature when
  30289. you want to copy tables between different SQL servers that supports
  30290. different table types (like copying tables to a slave that is optimized
  30291. for speed by not having transactional tables).  This automatic table
  30292. changing can however also be very confusing for new MySQL users. We
  30293. plan to fix this by introducing warnings in MySQL 4.0 and giving a
  30294. warning when a table type is automatically changed.
  30295.  
  30296. You can convert tables between different types with the `ALTER TABLE'
  30297. statement. *Note `ALTER TABLE': ALTER TABLE.
  30298.  
  30299. Note that MySQL supports two different kinds of tables.
  30300. Transaction-safe tables (`BDB', `InnoDB' and not transaction-safe
  30301. tables (`HEAP', `ISAM', `MERGE', and `MyISAM').
  30302.  
  30303. Advantages of transaction-safe tables (TST):
  30304.  
  30305.    * Safer. Even if MySQL crashes or you get hardware problems, you can
  30306.      get your data back, either by automatic recovery or from a backup
  30307.      + the transaction log.
  30308.  
  30309.    * You can combine many statements and accept these all in one go with
  30310.      the `COMMIT' command.
  30311.  
  30312.    * You can execute `ROLLBACK' to ignore your changes (if you are not
  30313.      running in auto commit mode).
  30314.  
  30315.    * If an update fails, all your changes will be restored. (With NTST
  30316.      tables all changes that have taken place are permanent)
  30317.  
  30318. Advantages of not transaction-safe tables (NTST):
  30319.  
  30320.    * Much faster as there is no transaction overhead.
  30321.  
  30322.    * Will use less disk space as there is no overhead of transactions.
  30323.  
  30324.    * Will use less memory to do updates.
  30325.  
  30326. You can combine TST and NTST tables in the same statements to get the
  30327. best of both worlds.
  30328.  
  30329. * Menu:
  30330.  
  30331. * MyISAM::                      MyISAM tables
  30332. * MERGE::                       MERGE tables
  30333. * ISAM::                        ISAM tables
  30334. * HEAP::                        HEAP tables
  30335. * BDB::                         BDB or Berkeley_db tables
  30336. * InnoDB::                      InnoDB tables
  30337.  
  30338. 
  30339. File: mysql.info,  Node: MyISAM,  Next: MERGE,  Prev: Table types,  Up: Table types
  30340.  
  30341. MyISAM Tables
  30342. =============
  30343.  
  30344. `MyISAM' is the default table type in MySQL Version 3.23. It's based on
  30345. the `ISAM' code and has a lot of useful extensions.
  30346.  
  30347. The index is stored in a file with the `.MYI' (MYIndex) extension, and
  30348. the data is stored in a file with the `.MYD' (MYData) extension.  You
  30349. can check/repair `MyISAM' tables with the `myisamchk' utility. *Note
  30350. Crash recovery::. You can compress `MyISAM' tables with `myisampack' to
  30351. take up much less space. *Note myisampack::.
  30352.  
  30353. The following is new in `MyISAM':
  30354.  
  30355.    * There is a flag in the `MyISAM' file that indicates whether or not
  30356.      the table was closed correctly.  If `mysqld' is started with
  30357.      `--myisam-recover', `MyISAM' tables will automatically be checked
  30358.      and/or repaired on open if the table wasn't closed properly.
  30359.  
  30360.    * You can `INSERT' new rows in a table that doesn't have free blocks
  30361.      in the middle of the data file, at the same time other threads are
  30362.      reading from the table (concurrent insert).  An free block can
  30363.      come from an update of a dynamic length row with much data to a
  30364.      row with less data or when deleting rows. When all free blocks are
  30365.      used up, all future inserts will be concurrent again.
  30366.  
  30367.    * Support for big files (63-bit) on filesystems/operating systems
  30368.      that support big files.
  30369.  
  30370.    * All data is stored with the low byte first. This makes the data
  30371.      machine and OS independent. The only requirement is that the
  30372.      machine uses two's-complement signed integers (as every machine
  30373.      for the last 20 years has) and IEEE floating-point format (also
  30374.      totally dominant among mainstream machines). The only area of
  30375.      machines that may not support binary compatibility are embedded
  30376.      systems (because they sometimes have peculiar processors).
  30377.  
  30378.      There is no big speed penalty in storing data low byte first; The
  30379.      bytes in a table row is normally unaligned and it doesn't take
  30380.      that much more power to read an unaligned byte in order than in
  30381.      reverse order.  The actual fetch-column-value code is also not
  30382.      time critical compared to other code.
  30383.  
  30384.    * All number keys are stored with high byte first to give better
  30385.      index compression.
  30386.  
  30387.    * Internal handling of one `AUTO_INCREMENT' column. `MyISAM' will
  30388.      automatically update this on `INSERT/UPDATE'. The `AUTO_INCREMENT'
  30389.      value can be reset with `myisamchk'. This will make
  30390.      `AUTO_INCREMENT' columns faster (at least 10 %) and old numbers
  30391.      will not be reused as with the old `ISAM'. Note that when an
  30392.      `AUTO_INCREMENT' is defined on the end of a multi-part-key the old
  30393.      behavior is still present.
  30394.  
  30395.    * When inserted in sorted order (as when you are using an
  30396.      `AUTO_INCREMENT' column) the key tree will be split so that the
  30397.      high node only contains one key. This will improve the space
  30398.      utilization in the key tree.
  30399.  
  30400.    * `BLOB' and `TEXT' columns can be indexed.
  30401.  
  30402.    * `NULL' values are allowed in indexed columns.  This takes 0-1
  30403.      bytes/key.
  30404.  
  30405.    * Maximum key length is 500 bytes by default (can be changed by
  30406.      recompiling).  In cases of keys longer than 250 bytes, a bigger key
  30407.      block size than the default of 1024 bytes is used for this key.
  30408.  
  30409.    * Maximum number of keys/table is 32 as default. This can be
  30410.      enlarged to 64 without having to recompile `myisamchk'.
  30411.  
  30412.    * `myisamchk' will mark tables as checked if one runs it with
  30413.      `--update-state'. `myisamchk --fast' will only check those tables
  30414.      that don't have this mark.
  30415.  
  30416.    * `myisamchk -a' stores statistics for key parts (and not only for
  30417.      whole keys as in `ISAM').
  30418.  
  30419.    * Dynamic size rows will now be much less fragmented when mixing
  30420.      deletes with updates and inserts.  This is done by automatically
  30421.      combining adjacent deleted blocks and by extending blocks if the
  30422.      next block is deleted.
  30423.  
  30424.    * `myisampack' can pack `BLOB' and `VARCHAR' columns.
  30425.  
  30426.    * You can use put the datafile and index file on different
  30427.      directories to get more speed (with the `DATA/INDEX
  30428.      DIRECTORY="path"' option to `CREATE TABLE'). *Note CREATE TABLE::.
  30429.  
  30430. `MyISAM' also supports the following things, which MySQL will be able
  30431. to use in the near future:
  30432.  
  30433.    * Support for a true `VARCHAR' type; A `VARCHAR' column starts with
  30434.      a length stored in 2 bytes.
  30435.  
  30436.    * Tables with `VARCHAR' may have fixed or dynamic record length.
  30437.  
  30438.    * `VARCHAR' and `CHAR' may be up to 64K.  All key segments have
  30439.      their own language definition. This will enable MySQL to have
  30440.      different language definitions per column.
  30441.  
  30442.    * A hashed computed index can be used for `UNIQUE'. This will allow
  30443.      you to have `UNIQUE' on any combination of columns in a table. (You
  30444.      can't search on a `UNIQUE' computed index, however.)
  30445.  
  30446. Note that index files are usually much smaller with `MyISAM' than with
  30447. `ISAM'. This means that `MyISAM' will normally use less system
  30448. resources than `ISAM', but will need more CPU when inserting data into
  30449. a compressed index.
  30450.  
  30451. The following options to `mysqld' can be used to change the behavior of
  30452. `MyISAM' tables. *Note SHOW VARIABLES::.
  30453.  
  30454. *Option*                      *Meaning*
  30455. `--myisam-recover=#'          Automatic recover of crashed tables.
  30456. `-O                           Buffer used when recovering tables.
  30457. myisam_sort_buffer_size=#'    
  30458. `--delay-key-write-for-all-tables'Don't flush key buffers between writes for
  30459.                               any MyISAM table
  30460. `-O                           Used to help MySQL to decide when to use
  30461. myisam_max_extra_sort_file_size=#'the slow but safe key cache index create
  30462.                               method. *NOTE* that this parameter is
  30463.                               given in megabytes!
  30464. `-O                           Don't use the fast sort index method to
  30465. myisam_max_sort_file_size=#'  created index if the temporary file would
  30466.                               get bigger than this.  *NOTE* that this
  30467.                               paramter is given in megabytes!
  30468.  
  30469. The automatic recovery is activated if you start `mysqld' with
  30470. `--myisam-recover=#'. *Note Command-line options::.  On open, the table
  30471. is checked if it's marked as crashed or if the open count variable for
  30472. the table is not 0 and you are running with `--skip-locking'.  If
  30473. either of the above is true the following happens.
  30474.  
  30475.    * The table is checked for errors.
  30476.  
  30477.    * If we found an error, try to do a fast repair (with sorting and
  30478.      without re-creating the data file) of the table.
  30479.  
  30480.    * If the repair fails because of an error in the data file (for
  30481.      example a duplicate key error), we try again, but this time we
  30482.      re-create the data file.
  30483.  
  30484.    * If the repair fails, retry once more with the old repair option
  30485.      method (write row by row without sorting) which should be able to
  30486.      repair any type of error with little disk requirements..
  30487.  
  30488. If the recover wouldn't be able to recover all rows from a previous
  30489. completed statement and you didn't specify `FORCE' as an option to
  30490. `myisam-recover', then the automatic repair will abort with an error
  30491. message in the error file:
  30492.  
  30493.      Error: Couldn't repair table: test.g00pages
  30494.  
  30495. If you in this case had used the `FORCE' option you would instead have
  30496. got a warning in the error file:
  30497.  
  30498.      Warning: Found 344 of 354 rows when repairing ./test/g00pages
  30499.  
  30500. Note that if you run automatic recover with the `BACKUP' option, you
  30501. should have a cron script that automatically moves file with names like
  30502. `tablename-datetime.BAK' from the database directories to a backup
  30503. media.
  30504.  
  30505. *Note Command-line options::.
  30506.  
  30507. * Menu:
  30508.  
  30509. * Key space::                   Space needed for keys
  30510. * MyISAM table formats::        MyISAM table formats
  30511. * MyISAM table problems::       MyISAM table problems.
  30512.  
  30513. 
  30514. File: mysql.info,  Node: Key space,  Next: MyISAM table formats,  Prev: MyISAM,  Up: MyISAM
  30515.  
  30516. Space Needed for Keys
  30517. ---------------------
  30518.  
  30519. MySQL can support different index types, but the normal type is ISAM or
  30520. MyISAM.  These use a B-tree index, and you can roughly calculate the
  30521. size for the index file as `(key_length+4)/0.67', summed over all keys.
  30522. (This is for the worst case when all keys are inserted in sorted order
  30523. and we don't have any compressed keys.)
  30524.  
  30525. String indexes are space compressed. If the first index part is a
  30526. string, it will also be prefix compressed.  Space compression makes the
  30527. index file smaller than the above figures if the string column has a lot
  30528. of trailing space or is a `VARCHAR' column that is not always used to
  30529. the full length. Prefix compression is used on keys that start with a
  30530. string.  Prefix compression helps if there are many strings with an
  30531. identical prefix.
  30532.  
  30533. In `MyISAM' tables, you can also prefix compress numbers by specifying
  30534. `PACK_KEYS=1' when you create the table.  This helps when you have many
  30535. integer keys that have an identical prefix when the numbers are stored
  30536. high-byte first.
  30537.  
  30538. 
  30539. File: mysql.info,  Node: MyISAM table formats,  Next: MyISAM table problems,  Prev: Key space,  Up: MyISAM
  30540.  
  30541. MyISAM Table Formats
  30542. --------------------
  30543.  
  30544. *MyISAM* supports 3 different table types. Two of them are chosen
  30545. automatically depending on the type of columns you are using. The third,
  30546. compressed tables, can only be created with the `myisampack' tool.
  30547.  
  30548. * Menu:
  30549.  
  30550. * Static format::               Static (Fixed-length) table characteristics
  30551. * Dynamic format::              Dynamic table characteristics
  30552. * Compressed format::           Compressed table characteristics
  30553.  
  30554. 
  30555. File: mysql.info,  Node: Static format,  Next: Dynamic format,  Prev: MyISAM table formats,  Up: MyISAM table formats
  30556.  
  30557. Static (Fixed-length) Table Characteristics
  30558. ...........................................
  30559.  
  30560. This is the default format. It's used when the table contains no
  30561. `VARCHAR', `BLOB', or `TEXT' columns.
  30562.  
  30563. This format is the simplest and most secure format. It is also the
  30564. fastest of the on-disk formats. The speed comes from the easy way data
  30565. can be found on disk. When looking up something with an index and static
  30566. format it is very simple. Just multiply the row number by the row
  30567. length.
  30568.  
  30569. Also, when scanning a table it is very easy to read a constant number of
  30570. records with each disk read.
  30571.  
  30572. The security is evidenced if your computer crashes when writing to a
  30573. fixed-size MyISAM file, in which case `myisamchk' can easily figure out
  30574. where each row starts and ends. So it can usually reclaim all records
  30575. except the partially written one. Note that in MySQL all indexes can
  30576. always be reconstructed:
  30577.  
  30578.    * All `CHAR', `NUMERIC', and `DECIMAL' columns are space-padded to
  30579.      the column width.
  30580.  
  30581.    * Very quick.
  30582.  
  30583.    * Easy to cache.
  30584.  
  30585.    * Easy to reconstruct after a crash, because records are located in
  30586.      fixed positions.
  30587.  
  30588.    * Doesn't have to be reorganized (with `myisamchk') unless a huge
  30589.      number of records are deleted and you want to return free disk
  30590.      space to the operating system.
  30591.  
  30592.    * Usually requires more disk space than dynamic tables.
  30593.  
  30594. 
  30595. File: mysql.info,  Node: Dynamic format,  Next: Compressed format,  Prev: Static format,  Up: MyISAM table formats
  30596.  
  30597. Dynamic Table Characteristics
  30598. .............................
  30599.  
  30600. This format is used if the table contains any `VARCHAR', `BLOB', or
  30601. `TEXT' columns or if the table was created with `ROW_FORMAT=dynamic'.
  30602.  
  30603. This format is a little more complex because each row has to have a
  30604. header that says how long it is. One record can also end up at more
  30605. than one location when it is made longer at an update.
  30606.  
  30607. You can use `OPTIMIZE table' or `myisamchk' to defragment a table. If
  30608. you have static data that you access/change a lot in the same table as
  30609. some `VARCHAR' or `BLOB' columns, it might be a good idea to move the
  30610. dynamic columns to other tables just to avoid fragmentation:
  30611.  
  30612.    * All string columns are dynamic (except those with a length less
  30613.      than 4).
  30614.  
  30615.    * Each record is preceded by a bitmap indicating which columns are
  30616.      empty (`''') for string columns, or zero for numeric columns.
  30617.      (This isn't the same as columns containing `NULL' values.) If a
  30618.      string column has a length of zero after removal of trailing
  30619.      spaces, or a numeric column has a value of zero, it is marked in
  30620.      the bit map and not saved to disk.  Non-empty strings are saved as
  30621.      a length byte plus the string contents.
  30622.  
  30623.    * Usually takes much less disk space than fixed-length tables.
  30624.  
  30625.    * Each record uses only as much space as is required. If a record
  30626.      becomes larger, it is split into as many pieces as are required.
  30627.      This results in record fragmentation.
  30628.  
  30629.    * If you update a row with information that extends the row length,
  30630.      the row will be fragmented.  In this case, you may have to run
  30631.      `myisamchk -r' from time to time to get better performance.  Use
  30632.      `myisamchk -ei tbl_name' for some statistics.
  30633.  
  30634.    * Not as easy to reconstruct after a crash, because a record may be
  30635.      fragmented into many pieces and a link (fragment) may be missing.
  30636.  
  30637.    * The expected row length for dynamic sized records is:
  30638.  
  30639.           3
  30640.           + (number of columns + 7) / 8
  30641.           + (number of char columns)
  30642.           + packed size of numeric columns
  30643.           + length of strings
  30644.           + (number of NULL columns + 7) / 8
  30645.  
  30646.      There is a penalty of 6 bytes for each link. A dynamic record is
  30647.      linked whenever an update causes an enlargement of the record.
  30648.      Each new link will be at least 20 bytes, so the next enlargement
  30649.      will probably go in the same link.  If not, there will be another
  30650.      link. You may check how many links there are with `myisamchk -ed'.
  30651.      All links may be removed with `myisamchk -r'.
  30652.  
  30653. 
  30654. File: mysql.info,  Node: Compressed format,  Prev: Dynamic format,  Up: MyISAM table formats
  30655.  
  30656. Compressed Table Characteristics
  30657. ................................
  30658.  
  30659. This is a read-only type that is generated with the optional
  30660. `myisampack' tool (`pack_isam' for `ISAM' tables):
  30661.  
  30662.    * All MySQL distributions, even those that existed before MySQL went
  30663.      GPL, can read tables that were compressed with `myisampack'.
  30664.  
  30665.    * Compressed tables take very little disk space. This minimizes disk
  30666.      usage, which is very nice when using slow disks (like CD-ROMs).
  30667.  
  30668.    * Each record is compressed separately (very little access
  30669.      overhead).  The header for a record is fixed (1-3 bytes) depending
  30670.      on the biggest record in the table.  Each column is compressed
  30671.      differently. Some of the compression types are:
  30672.         - There is usually a different Huffman table for each column.
  30673.  
  30674.         - Suffix space compression.
  30675.  
  30676.         - Prefix space compression.
  30677.  
  30678.         - Numbers with value `0' are stored using 1 bit.
  30679.  
  30680.         - If values in an integer column have a small range, the column
  30681.           is stored using the smallest possible type. For example, a
  30682.           `BIGINT' column (8 bytes) may be stored as a `TINYINT' column
  30683.           (1 byte) if all values are in the range `0' to `255'.
  30684.  
  30685.         - If a column has only a small set of possible values, the
  30686.           column type is converted to `ENUM'.
  30687.  
  30688.         - A column may use a combination of the above compressions.
  30689.  
  30690.    * Can handle fixed- or dynamic-length records, but not `BLOB' or
  30691.      `TEXT' columns.
  30692.  
  30693.    * Can be uncompressed with `myisamchk'.
  30694.  
  30695. 
  30696. File: mysql.info,  Node: MyISAM table problems,  Prev: MyISAM table formats,  Up: MyISAM
  30697.  
  30698. MyISAM table problems.
  30699. ----------------------
  30700.  
  30701. The file format that MySQL uses to store data has been extensively
  30702. tested, but there are always circumstances that may cause database
  30703. tables to become corrupted.
  30704.  
  30705. * Menu:
  30706.  
  30707. * Corrupted MyISAM tables::     Corrupted MyISAM tables.
  30708. * MyISAM table close::          Clients is using or hasn't closed the table properly
  30709.  
  30710. 
  30711. File: mysql.info,  Node: Corrupted MyISAM tables,  Next: MyISAM table close,  Prev: MyISAM table problems,  Up: MyISAM table problems
  30712.  
  30713. Corrupted MyISAM tables.
  30714. ........................
  30715.  
  30716. Even if the MyISAM table format is very reliable (all changes to a table
  30717. is written before the SQL statements returns) , you can still get
  30718. corrupted tables if some of the following things happens:
  30719.  
  30720.    * The `mysqld' process being killed in the middle of a write.
  30721.  
  30722.    * Unexpected shutdown of the computer (for example, if the computer
  30723.      is turned off).
  30724.  
  30725.    * A hardware error.
  30726.  
  30727.    * You are using an external program (like myisamchk) on a live table.
  30728.  
  30729.    * A software bug in the MySQL or MyISAM code.
  30730.  
  30731. Typial typical symptoms for a corrupt table is:
  30732.  
  30733.    * You get the error `Incorrect key file for table: '...'. Try to
  30734.      repair it' while selecting data from the table.
  30735.  
  30736.    * Queries doesn't find rows in the table or returns incomplete data.
  30737.  
  30738. You can check if a table is ok with the command `CHECK TABLE'. *Note
  30739. CHECK TABLE::.
  30740.  
  30741. You can repair a corrupted table with `REPAIR TABLE'. *Note REPAIR
  30742. TABLE::.  You can also repair a table, when `mysqld' is not running with
  30743. the `myisamchk' command. `myisamchk syntax'.
  30744.  
  30745. If your tables get corrupted a lot you should try to find the reason for
  30746. this! *Note Crashing::.
  30747.  
  30748. In this case the most important thing to know is if the table got
  30749. corrupted if the `mysqld' died (one can easily verify this by checking
  30750. if there is a recent row `restarted mysqld' in the mysqld error file).
  30751. If this isn't the case, then you should try to make a test case of
  30752. this.  *Note Reproduceable test case::.
  30753.  
  30754. 
  30755. File: mysql.info,  Node: MyISAM table close,  Prev: Corrupted MyISAM tables,  Up: MyISAM table problems
  30756.  
  30757. Clients is using or hasn't closed the table properly
  30758. ....................................................
  30759.  
  30760. Each `MyISAM' `.MYI' file has in the header a counter that can be used
  30761. to check if a table has been closed properly.
  30762.  
  30763. If you get the following warning from `CHECK TABLE' or `myisamchk':
  30764.  
  30765.      # clients is using or hasn't closed the table properly
  30766.  
  30767. this means that this counter has come out of sync.  This doesn't mean
  30768. that the table is corrupted, but means that you should at least do a
  30769. check on the table to verify that it's ok.
  30770.  
  30771. The counter works as follows:
  30772.  
  30773.    * The first time a table is updated in MySQL, a counter in the
  30774.      header of the index files is incremented.
  30775.  
  30776.    * The counter is not changed during further updates.
  30777.  
  30778.    * When the last instance of a table is closed (because of a `FLUSH'
  30779.      or because there isn't room in the table cache) the counter is
  30780.      decremented if the table has been updated at any point.
  30781.  
  30782.    * When you repair the table or check the table and it was ok, the
  30783.      counter is reset to 0.
  30784.  
  30785.    * To avoid problems with interaction with other processes that may
  30786.      do a check on the table, the counter is not decremented on close
  30787.      if it was 0.
  30788.  
  30789. In other words, the only ways this can go out of sync are:
  30790.  
  30791.    * The `MyISAM' tables are copied without a `LOCK' and `FLUSH TABLES'.
  30792.  
  30793.    * MySQL has crashed between an update and the final close (Note that
  30794.      the table may still be ok, as MySQL always issues writes for
  30795.      everything between each statement).
  30796.  
  30797.    * Someone has done a `myisamchk --repair' or `myisamchk
  30798.      --update-state'on a table that was in use by `mysqld'.
  30799.  
  30800.    * Many `mysqld' servers are using the table and one has done a
  30801.      `REPAIR' or `CHECK' of the table while it was in use by another
  30802.      server.  In this setup the `CHECK' is safe to do (even if you will
  30803.      get the warning from other servers), but `REPAIR' should be
  30804.      avoided as it currently replaces the data file with a new one,
  30805.      which is not signaled to the other servers.
  30806.  
  30807. 
  30808. File: mysql.info,  Node: MERGE,  Next: ISAM,  Prev: MyISAM,  Up: Table types
  30809.  
  30810. MERGE Tables
  30811. ============
  30812.  
  30813. `MERGE' tables are new in MySQL Version 3.23.25. The code is still in
  30814. gamma, but should be resonable stable.
  30815.  
  30816. A `MERGE' table is a collection of identical `MyISAM' tables that can
  30817. be used as one.  You can only `SELECT', `DELETE', and `UPDATE' from the
  30818. collection of tables.  If you `DROP' the `MERGE' table, you are only
  30819. dropping the `MERGE' specification.
  30820.  
  30821. Note that `DELETE FROM merge_table' used without a `WHERE' will only
  30822. clear the mapping for the table, not delete everything in the mapped
  30823. tables. (We plan to fix this in 4.0).
  30824.  
  30825. With identical tables we mean that all tables are created with identical
  30826. column and key information.  You can't put a MERGE over tables where the
  30827. columns are packed differently, doesn't have exactly the same columns or
  30828. have the keys in different order.  Some of the tables can however be
  30829. compressed with `myisampack'.  *Note myisampack::.
  30830.  
  30831. When you create a `MERGE' table, you will get a `.frm' table definition
  30832. file and a `.MRG' table list file.  The `.MRG' just contains a list of
  30833. the index files (`.MYI' files) that should be used as one.  All used
  30834. tables must be in the same database as the `MERGE' table itself.
  30835.  
  30836. For the moment you need to have `SELECT', `UPDATE', and `DELETE'
  30837. privileges on the tables you map to a `MERGE' table.
  30838.  
  30839. `MERGE' tables can help you solve the following problems:
  30840.  
  30841.    * Easily manage a set of log tables. For example, you can put data
  30842.      from different months into separate files, compress some of them
  30843.      with `myisampack', and then create a `MERGE' to use these as one.
  30844.  
  30845.    * Give you more speed. You can split a big read-only table based on
  30846.      some criteria and then put the different table part on different
  30847.      disks.  A `MERGE' table on this could be much faster than using
  30848.      the big table. (You can, of course, also use a RAID to get the same
  30849.      kind of benefits.)
  30850.  
  30851.    * Do more efficient searches. If you know exactly what you are
  30852.      looking after, you can search in just one of the split tables for
  30853.      some queries and use *MERGE* table for others.  You can even have
  30854.      many different `MERGE' tables active, with possible overlapping
  30855.      files.
  30856.  
  30857.    * More efficient repairs. It's easier to repair the individual files
  30858.      that are mapped to a `MERGE' file than trying to repair a real big
  30859.      file.
  30860.  
  30861.    * Instant mapping of many files as one. A `MERGE' table uses the
  30862.      index of the individual tables. It doesn't need to maintain an
  30863.      index of its one.  This makes `MERGE' table collections VERY fast
  30864.      to make or remap.  Note that you must specify the key definitions
  30865.      when you create a `MERGE' table!.
  30866.  
  30867.    * If you have a set of tables that you join to a big table on demand
  30868.      or batch, you should instead create a `MERGE' table on them on
  30869.      demand.  This is much faster and will save a lot of disk space.
  30870.  
  30871.    * Go around the file size limit for the operating system.
  30872.  
  30873.    * You can create an alias/synonym for a table by just using MERGE
  30874.      over one table. There shouldn't be any really notable performance
  30875.      impacts of doing this (only a couple of indirect calls and
  30876.      memcpy's for each read).
  30877.  
  30878. The disadvantages with `MERGE' tables are:
  30879.  
  30880.    * You can't use `INSERT' on `MERGE' tables, as MySQL can't know in
  30881.      which of the tables we should insert the row.
  30882.  
  30883.    * You can only use identical `MyISAM' tables for a `MERGE' table.
  30884.  
  30885.    * `MERGE' tables uses more file descriptors. If you are using a
  30886.      *MERGE* that maps over 10 tables and 10 users are using this, you
  30887.      are using 10*10 + 10 file descriptors.  (10 data files for 10 users
  30888.      and 10 shared index files.)
  30889.  
  30890.    * Key reads are slower. When you do a read on a key, the `MERGE'
  30891.      handler will need to issue a read on all underlying tables to check
  30892.      which one most closely matches the given key.  If you then do a
  30893.      'read-next' then the merge table handler will need to search the
  30894.      read buffers to find the next key. Only when one key buffer is
  30895.      used up, the handler will need to read the next key block. This
  30896.      makes `MERGE' keys much slower on `eq_ref' searches, but not much
  30897.      slower on `ref' searches.  *Note EXPLAIN::.
  30898.  
  30899.    * You can't do `DROP TABLE', `ALTER TABLE' or `DELETE FROM
  30900.      table_name' without a `WHERE' clause on any of the table that is
  30901.      mapped by a `MERGE' table that is 'open'.  If you do this, the
  30902.      `MERGE' table may still refer to the original table and you will
  30903.      get unexpected results.
  30904.  
  30905. The following example shows you how to use `MERGE' tables:
  30906.  
  30907.      CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, message CHAR(20));
  30908.      CREATE TABLE t2 (a INT AUTO_INCREMENT PRIMARY KEY, message CHAR(20));
  30909.      INSERT INTO t1 (message) VALUES ("Testing"),("table"),("t1");
  30910.      INSERT INTO t2 (message) VALUES ("Testing"),("table"),("t2");
  30911.      CREATE TABLE total (a INT NOT NULL, message CHAR(20), KEY(a)) TYPE=MERGE UNION=(t1,t2);
  30912.  
  30913. Note that we didn't create a `UNIQUE' or `PRIMARY KEY' in the `total'
  30914. table as the key isn't going to be unique in the `total' table.
  30915.  
  30916. Note that you can also manipulate the `.MRG' file directly from the
  30917. outside of the MySQL server:
  30918.  
  30919.      shell> cd /mysql-data-directory/current-database
  30920.      shell> ls -1 t1.MYI t2.MYI > total.MRG
  30921.      shell> mysqladmin flush-tables
  30922.  
  30923. Now you can do things like:
  30924.  
  30925.      mysql> select * from total;
  30926.      +---+---------+
  30927.      | a | message |
  30928.      +---+---------+
  30929.      | 1 | Testing |
  30930.      | 2 | table   |
  30931.      | 3 | t1      |
  30932.      | 1 | Testing |
  30933.      | 2 | table   |
  30934.      | 3 | t2      |
  30935.      +---+---------+
  30936.  
  30937. To remap a `MERGE' table you can do one of the following:
  30938.  
  30939.    * `DROP' the table and re-create it
  30940.  
  30941.    * Use `ALTER TABLE table_name UNION(...)'
  30942.  
  30943.    * Change the `.MRG' file and issue a `FLUSH TABLE' on the `MERGE'
  30944.      table and all underlying tables to force the handler to read the
  30945.      new definition file.
  30946.  
  30947. 
  30948. File: mysql.info,  Node: ISAM,  Next: HEAP,  Prev: MERGE,  Up: Table types
  30949.  
  30950. ISAM Tables
  30951. ===========
  30952.  
  30953. You can also use the deprecated ISAM table type. This will disappear
  30954. rather soon because `MyISAM' is a better implementation of the same
  30955. thing. ISAM uses a `B-tree' index. The index is stored in a file with
  30956. the `.ISM' extension, and the data is stored in a file with the `.ISD'
  30957. extension.  You can check/repair ISAM tables with the `isamchk'
  30958. utility. *Note Crash recovery::.
  30959.  
  30960. `ISAM' has the following features/properties:
  30961.  
  30962.    * Compressed and fixed-length keys
  30963.  
  30964.    * Fixed and dynamic record length
  30965.  
  30966.    * 16 keys with 16 key parts/key
  30967.  
  30968.    * Max key length 256 (default)
  30969.  
  30970.    * Data is stored in machine format; this is fast, but is machine/OS
  30971.      dependent.
  30972.  
  30973. Most of the things true for `MyISAM' tables are also true for `ISAM'
  30974. tables. *Note MyISAM::. The major differences compared to `MyISAM'
  30975. tables are:
  30976.  
  30977.    * ISAM tables are not binary portable across OS/Platforms.
  30978.  
  30979.    * Can't handle tables > 4G.
  30980.  
  30981.    * Only support prefix compression on strings.
  30982.  
  30983.    * Smaller key limits.
  30984.  
  30985.    * Dynamic tables get more fragmented.
  30986.  
  30987.    * Tables are compressed with `pack_isam' rather than with
  30988.      `myisampack'.
  30989.  
  30990. If you want to convert an `ISAM' table to a `MyISAM' table so that you
  30991. can use utilities such as `mysqlcheck', use an `ALTER TABLE' statement:
  30992.  
  30993.      mysql> ALTER TABLE tbl_name TYPE = MYISAM;
  30994.  
  30995. 
  30996. File: mysql.info,  Node: HEAP,  Next: BDB,  Prev: ISAM,  Up: Table types
  30997.  
  30998. HEAP Tables
  30999. ===========
  31000.  
  31001. `HEAP' tables use a hashed index and are stored in memory.  This makes
  31002. them very fast, but if MySQL crashes you will lose all data stored in
  31003. them.  `HEAP' is very useful for temporary tables!
  31004.  
  31005. The MySQL internal HEAP tables use 100% dynamic hashing without
  31006. overflow areas. There is no extra space needed for free lists.  `HEAP'
  31007. tables also don't have problems with delete + inserts, which normally
  31008. is common with hashed tables:
  31009.  
  31010.      mysql> CREATE TABLE test TYPE=HEAP SELECT ip,SUM(downloads) as down
  31011.              FROM log_table GROUP BY ip;
  31012.      mysql> SELECT COUNT(ip),AVG(down) FROM test;
  31013.      mysql> DROP TABLE test;
  31014.  
  31015. Here are some things you should consider when you use `HEAP' tables:
  31016.  
  31017.    * You should always use specify `MAX_ROWS' in the `CREATE' statement
  31018.      to ensure that you accidentally do not use all memory.
  31019.  
  31020.    * Indexes will only be used with `=' and `<=>' (but are VERY fast).
  31021.  
  31022.    * `HEAP' tables can only use whole keys to search for a row; compare
  31023.      this to `MyISAM' tables where any prefix of the key can be used to
  31024.      find rows.
  31025.  
  31026.    * `HEAP' tables use a fixed record length format.
  31027.  
  31028.    * `HEAP' doesn't support `BLOB'/`TEXT' columns.
  31029.  
  31030.    * `HEAP' doesn't support `AUTO_INCREMENT' columns.
  31031.  
  31032.    * `HEAP' doesn't support an index on a `NULL' column.
  31033.  
  31034.    * You can have non-unique keys in a `HEAP' table (this isn't common
  31035.      for hashed tables).
  31036.  
  31037.    * `HEAP' tables are shared between all clients (just like any other
  31038.      table).
  31039.  
  31040.    * You can't search for the next entry in order (that is, to use the
  31041.      index to do an `ORDER BY').
  31042.  
  31043.    * Data for `HEAP' tables are allocated in small blocks. The tables
  31044.      are 100% dynamic (on inserting). No overflow areas and no extra key
  31045.      space are needed.  Deleted rows are put in a linked list and are
  31046.      reused when you insert new data into the table.
  31047.  
  31048.    * You need enough extra memory for all HEAP tables that you want to
  31049.      use at the same time.
  31050.  
  31051.    * To free memory, you should execute `DELETE FROM heap_table',
  31052.      `TRUNCATE heap_table' or `DROP TABLE heap_table'.
  31053.  
  31054.    * MySQL cannot find out approximately how many rows there are
  31055.      between two values (this is used by the range optimizer to decide
  31056.      which index to use).  This may affect some queries if you change a
  31057.      `MyISAM' table to a `HEAP' table.
  31058.  
  31059.    * To ensure that you accidentally don't do anything foolish, you
  31060.      can't create `HEAP' tables bigger than `max_heap_table_size'.
  31061.  
  31062. The memory needed for one row in a `HEAP' table is:
  31063.  
  31064.      SUM_OVER_ALL_KEYS(max_length_of_key + sizeof(char*) * 2)
  31065.      + ALIGN(length_of_row+1, sizeof(char*))
  31066.  
  31067. `sizeof(char*)' is 4 on 32-bit machines and 8 on 64-bit machines.
  31068.  
  31069. 
  31070. File: mysql.info,  Node: BDB,  Next: InnoDB,  Prev: HEAP,  Up: Table types
  31071.  
  31072. BDB or Berkeley_DB Tables
  31073. =========================
  31074.  
  31075. * Menu:
  31076.  
  31077. * BDB overview::                Overview of BDB Tables
  31078. * BDB install::                 Installing BDB
  31079. * BDB start::                   BDB startup options
  31080. * BDB characteristic::          Some characteristic of `BDB' tables:
  31081. * BDB TODO::                    Some things we need to fix for BDB in the near future:
  31082. * BDB portability::             Operating systems supported by *BDB*
  31083. * BDB errors::                  Errors You May Get When Using BDB Tables
  31084.  
  31085. 
  31086. File: mysql.info,  Node: BDB overview,  Next: BDB install,  Prev: BDB,  Up: BDB
  31087.  
  31088. Overview of BDB Tables
  31089. ----------------------
  31090.  
  31091. Support for BDB tables is included in the MySQL source distribution
  31092. starting from Version 3.23.34 and is activated in the MySQL-Max binary.
  31093.  
  31094. BerkeleyDB, available at `http://www.sleepycat.com/' has provided MySQL
  31095. with a transactional table handler.  By using BerkeleyDB tables, your
  31096. tables may have a greater chance of surviving crashes, and also
  31097. provides `COMMIT' and `ROLLBACK' on transactions.  The MySQL source
  31098. distribution comes with a BDB distribution that has a couple of small
  31099. patches to make it work more smoothly with MySQL.  You can't use a
  31100. non-patched `BDB' version with MySQL.
  31101.  
  31102. We at MySQL AB are working in close cooperation with Sleepycat to keep
  31103. the quality of the MySQL/BDB interface high.
  31104.  
  31105. When it comes to supporting BDB tables, we are committed to help our
  31106. users to locate the problem and help creating a reproducable test case
  31107. for any problems involving BDB tables.  Any such test case will be
  31108. forwarded to Sleepycat who in turn will help us find and fix the
  31109. problem.  As this is a two stage operation, any problems with BDB tables
  31110. may take a little longer for us to fix than for other table handlers.
  31111. However, as the BerkeleyDB code itself has been used by many other
  31112. applications than MySQL, we don't envision any big problems with this.
  31113. *Note Table handler support::.
  31114.  
  31115. 
  31116. File: mysql.info,  Node: BDB install,  Next: BDB start,  Prev: BDB overview,  Up: BDB
  31117.  
  31118. Installing BDB
  31119. --------------
  31120.  
  31121. If you have downloaded a binary version of MySQL that includes support
  31122. for BerkeleyDB, simply follow the instructions for installing a binary
  31123. version of MySQL.  *Note Installing binary::.  *Note `mysqld-max':
  31124. mysqld-max.
  31125.  
  31126. To compile MySQL with Berkeley DB support, download MySQL Version
  31127. 3.23.34 or newer and configure `MySQL' with the `--with-berkeley-db'
  31128. option.  *Note Installing source::.
  31129.  
  31130.      cd /path/to/source/of/mysql-3.23.34
  31131.      ./configure --with-berkeley-db
  31132.  
  31133. Please refer to the manual provided with the `BDB' distribution for
  31134. more updated information.
  31135.  
  31136. Even though Berkeley DB is in itself very tested and reliable, the
  31137. MySQL interface is still considered beta quality.  We are actively
  31138. improving and optimizing it to get it stable very soon.
  31139.  
  31140. 
  31141. File: mysql.info,  Node: BDB start,  Next: BDB characteristic,  Prev: BDB install,  Up: BDB
  31142.  
  31143. BDB startup options
  31144. -------------------
  31145.  
  31146. If you are running with `AUTOCOMMIT=0' then your changes in `BDB'
  31147. tables will not be updated until you execute `COMMIT'.  Instead of
  31148. commit you can execute `ROLLBACK' to forget your changes. *Note
  31149. COMMIT::.
  31150.  
  31151. If you are running with `AUTOCOMMIT=1' (the default), your changes will
  31152. be committed immediately.  You can start an extended transaction with
  31153. the `BEGIN WORK' SQL command, after which your changes will not be
  31154. committed until you execute `COMMIT' (or decide to `ROLLBACK' the
  31155. changes).
  31156.  
  31157. The following options to `mysqld' can be used to change the behavior of
  31158. BDB tables:
  31159.  
  31160. *Option*               *Meaning*
  31161. `--bdb-home=directory' Base directory for BDB tables. This should be the
  31162.                        same directory you use for -datadir.
  31163. `--bdb-lock-detect=#'  Berkeley lock detect. One of (DEFAULT, OLDEST,
  31164.                        RANDOM, or YOUNGEST).
  31165. `--bdb-logdir=directory'Berkeley DB log file directory.
  31166. `--bdb-no-sync'        Don't synchronously flush logs.
  31167. `--bdb-no-recover'     Don't start Berkeley DB in recover mode.
  31168. `--bdb-shared-data'    Start Berkeley DB in multi-process mode (Don't
  31169.                        use `DB_PRIVATE' when initializing Berkeley DB)
  31170. `--bdb-tmpdir=directory'Berkeley DB tempfile name.
  31171. `--skip-bdb'           Don't use berkeley db.
  31172. `-O                    Set the maximum number of locks possible. *Note
  31173. bdb_max_lock=1000'     SHOW VARIABLES::.
  31174.  
  31175. If you use `--skip-bdb', MySQL will not initialize the Berkeley DB
  31176. library and this will save a lot of memory. Of course, you cannot use
  31177. `BDB' tables if you are using this option.
  31178.  
  31179. Normally you should start `mysqld' without `--bdb-no-recover' if you
  31180. intend to use BDB tables.  This may, however, give you problems when you
  31181. try to start `mysqld' if the BDB log files are corrupted. *Note
  31182. Starting server::.
  31183.  
  31184. With `bdb_max_lock' you can specify the maximum number of locks (10000
  31185. by default) you can have active on a BDB table. You should increase
  31186. this if you get errors of type `bdb: Lock table is out of available
  31187. locks' or `Got error 12 from ...'  when you have do long transactions
  31188. or when `mysqld' has to examine a lot of rows to calculate the query.
  31189.  
  31190. You may also want to change `binlog_cache_size' and
  31191. `max_binlog_cache_size' if you are using big multi-line transactions.
  31192. *Note COMMIT::.
  31193.  
  31194. 
  31195. File: mysql.info,  Node: BDB characteristic,  Next: BDB TODO,  Prev: BDB start,  Up: BDB
  31196.  
  31197. Some characteristic of `BDB' tables:
  31198. ------------------------------------
  31199.  
  31200.    * To be able to rollback transactions BDB maintain log files.  For
  31201.      maximum performance you should place these on another disk than
  31202.      your databases by using the `--bdb_log_dir' options.
  31203.  
  31204.    * MySQL performs a checkpoint each time a new BDB log file is
  31205.      started, and removes any log files that are not needed for current
  31206.      transactions.  One can also run `FLUSH LOGS' at any time to
  31207.      checkpoint the Berkeley DB tables.
  31208.  
  31209.      For disaster recovery, one should use table backups plus MySQL's
  31210.      binary log. *Note Backup::.
  31211.  
  31212.      *Warning*: If you delete old log files that are in use, BDB will
  31213.      not be able to do recovery at all and you may lose data if
  31214.      something goes wrong.
  31215.  
  31216.    * MySQL requires a `PRIMARY KEY' in each BDB table to be able to
  31217.      refer to previously read rows. If you don't create one, MySQL will
  31218.      create an maintain a hidden `PRIMARY KEY' for you.  The hidden key
  31219.      has a length of 5 bytes and is incremented for each insert attempt.
  31220.  
  31221.    * If all columns you access in a `BDB' table are part of the same
  31222.      index or part of the primary key, then MySQL can execute the query
  31223.      without having to access the actual row.  In a `MyISAM' table the
  31224.      above holds only if the columns are part of the same index.
  31225.  
  31226.    * The `PRIMARY KEY' will be faster than any other key, as the
  31227.      `PRIMARY KEY' is stored together with the row data.  As the other
  31228.      keys are stored as the key data + the `PRIMARY KEY', it's
  31229.      important to keep the `PRIMARY KEY' as short as possible to save
  31230.      disk and get better speed.
  31231.  
  31232.    * `LOCK TABLES' works on `BDB' tables as with other tables.  If you
  31233.      don't use `LOCK TABLE', MYSQL will issue an internal
  31234.      multiple-write lock on the table to ensure that the table will be
  31235.      properly locked if another thread issues a table lock.
  31236.  
  31237.    * Internal locking in `BDB' tables is done on page level.
  31238.  
  31239.    * `SELECT COUNT(*) FROM table_name' is slow as `BDB' tables doesn't
  31240.      maintain a count of the number of rows in the table.
  31241.  
  31242.    * Scanning is slower than with `MyISAM' tables as one has data in BDB
  31243.      tables stored in B-trees and not in a separate data file.
  31244.  
  31245.    * The application must always be prepared to handle cases where any
  31246.      change of a `BDB' table may make an automatic rollback and any
  31247.      read may fail with a deadlock error.
  31248.  
  31249.    * Keys are not compressed to previous keys as with ISAM or MyISAM
  31250.      tables. In other words, the key information will take a little more
  31251.      space in `BDB' tables compared to MyISAM tables which don't use
  31252.      `PACK_KEYS=0'.
  31253.  
  31254.    * There is often holes in the BDB table to allow you to insert new
  31255.      rows in the middle of the key tree.  This makes BDB tables
  31256.      somewhat larger than MyISAM tables.
  31257.  
  31258.    * The optimizer needs to know an approximation of the number of rows
  31259.      in the table.  MySQL solves this by counting inserts and
  31260.      maintaining this in a separate segment in each BDB table.  If you
  31261.      don't do a lot of `DELETE' or `ROLLBACK':s this number should be
  31262.      accurate enough for the MySQL optimizer, but as MySQL only store
  31263.      the number on close, it may be wrong if MySQL dies unexpectedly.
  31264.      It should not be fatal even if this number is not 100 % correct.
  31265.      One can update the number of rows by executing `ANALYZE TABLE' or
  31266.      `OPTIMIZE TABLE'. *Note ANALYZE TABLE:: . *Note OPTIMIZE TABLE::.
  31267.  
  31268.    * If you get full disk with a `BDB' table, you will get an error
  31269.      (probably error 28) and the transaction should roll back.  This is
  31270.      in contrast with `MyISAM' and `ISAM' tables where `mysqld' will
  31271.      wait for enough free disk before continuing.
  31272.  
  31273. 
  31274. File: mysql.info,  Node: BDB TODO,  Next: BDB portability,  Prev: BDB characteristic,  Up: BDB
  31275.  
  31276. Some things we need to fix for BDB in the near future:
  31277. ------------------------------------------------------
  31278.  
  31279.    * It's very slow to open many BDB tables at the same time. If you are
  31280.      going to use BDB tables, you should not have a very big table
  31281.      cache (> 256 ?) and you should use `--no-auto-rehash' with the
  31282.      `mysql' client.  We plan to partly fix this in 4.0.
  31283.  
  31284.    * `SHOW TABLE STATUS' doesn't yet provide that much information for
  31285.      BDB tables.
  31286.  
  31287.    * Optimize performance.
  31288.  
  31289.    * Change to not use page locks at all when we are scanning tables.
  31290.  
  31291. 
  31292. File: mysql.info,  Node: BDB portability,  Next: BDB errors,  Prev: BDB TODO,  Up: BDB
  31293.  
  31294. Operating systems supported by *BDB*
  31295. ------------------------------------
  31296.  
  31297. If you after having built MySQL with support for BDB tables get the
  31298. following error in the log file when you start `mysqld':
  31299.  
  31300.      bdb: architecture lacks fast mutexes: applications cannot be threaded
  31301.      Can't init dtabases
  31302.  
  31303. This means that `BDB' tables are not supported for your architecture.
  31304. In this case you have to rebuild MySQL without BDB table support.
  31305.  
  31306. NOTE: The following list is not complete; We will update this as we get
  31307. more information about this.
  31308.  
  31309. Currently we know that BDB tables works with the following operating
  31310. system.
  31311.  
  31312.    * Linux 2.x intel
  31313.  
  31314.    * Solaris sparc
  31315.  
  31316.    * SCO OpenServer
  31317.  
  31318.    * SCO UnixWare 7.0.1
  31319.  
  31320. It doesn't work with the following operating systems:
  31321.  
  31322.    * Linux 2.x Alpha
  31323.  
  31324.    * Max OS X
  31325.  
  31326. 
  31327. File: mysql.info,  Node: BDB errors,  Prev: BDB portability,  Up: BDB
  31328.  
  31329. Errors You May Get When Using BDB Tables
  31330. ----------------------------------------
  31331.  
  31332.    * If you get the following error in the `hostname.err log' when
  31333.      starting `mysqld':
  31334.  
  31335.           bdb:  Ignoring log file: .../log.XXXXXXXXXX: unsupported log version #
  31336.      it means that the new `BDB' version doesn't support the old log
  31337.      file format.  In this case you have to delete all `BDB' log BDB
  31338.      from your database directory (the files that has the format
  31339.      `log.XXXXXXXXXX' ) and restart `mysqld'.  We would also recommend
  31340.      you to do a `mysqldump --opt' of your old `BDB' tables, delete the
  31341.      old table and restore the dump.
  31342.  
  31343.    * If you are running in not `auto_commit' mode and delete a table you
  31344.      are using by another thread you may get the following error
  31345.      messages in the MySQL error file:
  31346.  
  31347.           001119 23:43:56  bdb:  Missing log fileid entry
  31348.           001119 23:43:56  bdb:  txn_abort: Log undo failed for LSN: 1 3644744: Invalid
  31349.  
  31350.      This is not fatal but we don't recommend that you delete tables if
  31351.      you are not in `auto_commit' mode, until this problem is fixed
  31352.      (the fix is not trivial).
  31353.  
  31354. 
  31355. File: mysql.info,  Node: InnoDB,  Prev: BDB,  Up: Table types
  31356.  
  31357. InnoDB Tables
  31358. =============
  31359.  
  31360. * Menu:
  31361.  
  31362. * InnoDB overview::             InnoDB tables overview
  31363. * InnoDB start::                InnoDB startup options
  31364. * InnoDB init::                 Creating InnoDB table space.
  31365. * Using InnoDB tables::         Creating InnoDB tables
  31366. * Adding and removing::         Adding and removing InnoDB data and log files
  31367. * Backing up::                  Backing up and recovering an InnoDB database
  31368. * Moving::                      Moving an InnoDB database to another machine
  31369. * InnoDB transaction model::    InnoDB transaction model.
  31370. * Implementation::              Implementation of multiversioning
  31371. * Table and index::             Table and index structures
  31372. * File space management::       File space management and disk i/o
  31373. * Error handling::              Error handling
  31374. * InnoDB restrictions::         Some restrictions on InnoDB tables
  31375. * InnoDB contact information::  InnoDB contact information.
  31376.  
  31377. 
  31378. File: mysql.info,  Node: InnoDB overview,  Next: InnoDB start,  Prev: InnoDB,  Up: InnoDB
  31379.  
  31380. InnoDB tables overview
  31381. ----------------------
  31382.  
  31383. InnoDB tables are included in the MySQL source distribution starting
  31384. from 3.23.34a and are activated in the *MySQL -max* binary.
  31385.  
  31386. If you have downloaded a binary version of MySQL that includes support
  31387. for InnoDB (mysqld-max), simply follow the instructions for installing
  31388. a binary version of MySQL. *Note Installing binary::.  *Note
  31389. `mysqld-max': mysqld-max.
  31390.  
  31391. To compile MySQL with InnoDB support, download MySQL-3.23.37 or newer
  31392. and configure MySQL with the `--with-innodb' option.  *Note Installing
  31393. source::.
  31394.  
  31395.      cd /path/to/source/of/mysql-3.23.37
  31396.      ./configure --with-innodb
  31397.  
  31398. To get InnoDB to work you have to specify where the data for InnoDB
  31399. tables should be stored by specifying the `innodb_data_file_path'
  31400. option on the command line or in an MySQL option file. *Note InnoDB
  31401. start::.  If you have configured MySQL for InnoDB but you have not
  31402. specified the above option, `mysqld' will print at start:
  31403.  
  31404.      Can't initialize InnoDB as 'innodb_data_file_path' is not set
  31405.  
  31406. InnoDB provides MySQL with a transaction-safe table handler with
  31407. commit, rollback, and crash recovery capabilities. InnoDB does locking
  31408. on row level, and also provides an Oracle-style consistent non-locking
  31409. read in `SELECTS', which increases transaction concurrency. There is
  31410. not need for lock escalation in InnoDB, because row level locks in
  31411. InnoDB fit in very small space.
  31412.  
  31413. InnoDB has been designed for maximum performance when processing large
  31414. data volumes. Its CPU efficiency is probably not matched by any other
  31415. disk-based relational database engine.
  31416.  
  31417. You can find the latest information about InnoDB at
  31418. `http://www.innodb.com'. The most up-to-date version of the InnoDB
  31419. manual is always placed there, and you can also order commercial
  31420. support for InnoDB.
  31421.  
  31422. Technically, InnoDB is a database backend placed under MySQL. InnoDB
  31423. has its own buffer pool for caching data and indexes in main memory.
  31424. InnoDB stores its tables and indexes in a tablespace, which may consist
  31425. of several files. This is different from, for example, `MyISAM' tables
  31426. where each table is stored as a separate file.
  31427.  
  31428. InnoDB is distributed under the GNU GPL License Version 2 (of June
  31429. 1991).  In the source distribution of MySQL, InnoDB appears as a
  31430. subdirectory.
  31431.  
  31432. 
  31433. File: mysql.info,  Node: InnoDB start,  Next: InnoDB init,  Prev: InnoDB overview,  Up: InnoDB
  31434.  
  31435. InnoDB startup options
  31436. ----------------------
  31437.  
  31438. Beginning from MySQL-3.23.37 the prefix of the options is changed from
  31439. `innobase_...' to `innodb_...'.
  31440.  
  31441. To use InnoDB tables you *MUST* specify configuration parameters in the
  31442. MySQL configuration file in the `[mysqld]' section of the configuration
  31443. file `my.cnf'. *Note Option files::.
  31444.  
  31445. The only required parameter to use InnoDB is `innodb_data_file_path',
  31446. but you should set others if you want to get a better performance.
  31447.  
  31448. Suppose you have a Windows NT machine with 128 MB RAM and a single 10 GB
  31449. hard disk.  Below is an example of possible configuration parameters in
  31450. `my.cnf' for InnoDB:
  31451.  
  31452.      innodb_data_file_path = ibdata1:2000M;ibdata2:2000M
  31453.      innodb_data_home_dir = c:\ibdata
  31454.      set-variable = innodb_mirrored_log_groups=1
  31455.      innodb_log_group_home_dir = c:\iblogs
  31456.      set-variable = innodb_log_files_in_group=3
  31457.      set-variable = innodb_log_file_size=30M
  31458.      set-variable = innodb_log_buffer_size=8M
  31459.      innodb_flush_log_at_trx_commit=1
  31460.      innodb_log_arch_dir = c:\iblogs
  31461.      innodb_log_archive=0
  31462.      set-variable = innodb_buffer_pool_size=80M
  31463.      set-variable = innodb_additional_mem_pool_size=10M
  31464.      set-variable = innodb_file_io_threads=4
  31465.      set-variable = innodb_lock_wait_timeout=50
  31466.  
  31467. Note that data files must be < 4G, and < 2G on some file systems! The
  31468. total size of data files has to be >= 10 MB.  InnoDB does not create
  31469. directories: you have to create them yourself.
  31470.  
  31471. Suppose you have a Linux machine with 512 MB RAM and three 20 GB hard
  31472. disks (at directory paths `/', `/dr2' and `/dr3').  Below is an example
  31473. of possible configuration parameters in `my.cnf' for InnoDB:
  31474.  
  31475.      innodb_data_file_path = ibdata/ibdata1:2000M;dr2/ibdata/ibdata2:2000M
  31476.      innodb_data_home_dir = /
  31477.      set-variable = innodb_mirrored_log_groups=1
  31478.      innodb_log_group_home_dir = /dr3
  31479.      set-variable = innodb_log_files_in_group=3
  31480.      set-variable = innodb_log_file_size=50M
  31481.      set-variable = innodb_log_buffer_size=8M
  31482.      innodb_flush_log_at_trx_commit=1
  31483.      innodb_log_arch_dir = /dr3/iblogs
  31484.      innodb_log_archive=0
  31485.      set-variable = innodb_buffer_pool_size=400M
  31486.      set-variable = innodb_additional_mem_pool_size=20M
  31487.      set-variable = innodb_file_io_threads=4
  31488.      set-variable = innodb_lock_wait_timeout=50
  31489.  
  31490. Note that we have placed the two data files on different disks.  The
  31491. reason for the name `innodb_data_file_path' is that you can also
  31492. specify paths to your data files, and `innodb_data_home_dir' is just
  31493. textually catenated before your data file paths, adding a possible
  31494. slash or backslash in between. InnoDB will fill the tablespace formed
  31495. by the data files from bottom up. In some cases it will improve the
  31496. performance of the database if all data is not placed on the same
  31497. physical disk. Putting log files on a different disk from data is very
  31498. often beneficial for performance.
  31499.  
  31500. The meanings of the configuration parameters are the following:
  31501.  
  31502. `innodb_data_home_dir'  The common part of the directory path for all
  31503.                        InnoDB data files.
  31504. `innodb_data_file_path' Paths to individual data files and their sizes.
  31505.                        The full directory path to each data file is
  31506.                        acquired by concatenating innodb_data_home_dir to
  31507.                        the paths specified here. The file sizes are
  31508.                        specified in megabytes, hence the 'M' after the
  31509.                        size specification above. Do not set a file size
  31510.                        bigger than 4000M, and on most operating systems
  31511.                        not bigger than 2000M.  InnoDB also understands
  31512.                        the abbreviation 'G', 1G meaning 1024M.  The sum
  31513.                        of the sizes of the files must be at least 10 MB.
  31514. `innodb_mirrored_log_groups' Number of identical copies of log groups we keep
  31515.                        for the database. Currently this should be set to
  31516.                        1.
  31517. `innodb_log_group_home_dir' Directory path to InnoDB log files.
  31518. `innodb_log_files_in_group' Number of log files in the log group. InnoDB
  31519.                        writes to the files in a circular fashion. Value
  31520.                        3 is recommended here.
  31521. `innodb_log_file_size'  Size of each log file in a log group in
  31522.                        megabytes. Sensible values range from 1M to the
  31523.                        size of the buffer pool specified below. The
  31524.                        bigger the value, the less checkpoint flush
  31525.                        activity is needed in the buffer pool, saving
  31526.                        disk i/o. But bigger log files also mean that
  31527.                        recovery will be slower in case of a crash. File
  31528.                        size restriction as for a data file.
  31529. `innodb_log_buffer_size' The size of the buffer which InnoDB uses to
  31530.                        write log to the log files on disk.  Sensible
  31531.                        values range from 1M to half the combined size of
  31532.                        log files. A big log buffer allows large
  31533.                        transactions to run without a need to write the
  31534.                        log to disk until the transaction commit. Thus,
  31535.                        if you have big transactions, making the log
  31536.                        buffer big will save disk i/o.
  31537. `innodb_flush_log_at_trx_commit' Normally this is set to 1, meaning that at a
  31538.                        transaction commit the log is flushed to disk,
  31539.                        and the modifications made by the transaction
  31540.                        become permanent, and survive a database crash.
  31541.                        If you are willing to compromise this safety, and
  31542.                        you are running small transactions, you may set
  31543.                        this to 0 to reduce disk i/o to the logs.
  31544. `innodb_log_arch_dir'   The directory where fully written log files
  31545.                        would be archived if we used log archiving.  The
  31546.                        value of this parameter should currently be set
  31547.                        the same as `innodb_log_group_home_dir'.
  31548. `innodb_log_archive'    This value should currently be set to 0.  As
  31549.                        recovery from a backup is done by MySQL using its
  31550.                        own log files, there is currently no need to
  31551.                        archive InnoDB log files.
  31552. `innodb_buffer_pool_size' The size of the memory buffer InnoDB uses to
  31553.                        cache data and indexes of its tables.  The bigger
  31554.                        you set this the less disk i/o is needed to
  31555.                        access data in tables. On a dedicated database
  31556.                        server you may set this parameter up to 90 % of
  31557.                        the machine physical memory size. Do not set it
  31558.                        too large, though, because competition of the
  31559.                        physical memory may cause paging in the operating
  31560.                        system.
  31561. `innodb_additional_mem_pool_size' Size of a memory pool InnoDB uses to store data
  31562.                        dictionary information and other internal data
  31563.                        structures. A sensible value for this might be
  31564.                        2M, but the more tables you have in your
  31565.                        application the more you will need to allocate
  31566.                        here. If InnoDB runs out of memory in this pool,
  31567.                        it will start to allocate memory from the
  31568.                        operating system, and write warning messages to
  31569.                        the MySQL error log.
  31570. `innodb_file_io_threads' Number of file i/o threads in InnoDB. Normally,
  31571.                        this should be 4, but on Windows NT disk i/o may
  31572.                        benefit from a larger number.
  31573. `innodb_lock_wait_timeout' Timeout in seconds an InnoDB transaction may
  31574.                        wait for a lock before being rolled back.  InnoDB
  31575.                        automatically detects transaction deadlocks in
  31576.                        its own lock table and rolls back the
  31577.                        transaction. If you use `LOCK TABLES' command, or
  31578.                        other transaction-safe table handlers than InnoDB
  31579.                        in the same transaction, then a deadlock may
  31580.                        arise which InnoDB cannot notice. In cases like
  31581.                        this the timeout is useful to resolve the
  31582.                        situation.
  31583. `innodb_flush_method'   (Available from 3.23.40 up.)  The default value
  31584.                        for this is `fdatasync'.  Another option is
  31585.                        `O_DSYNC'.
  31586.  
  31587. 
  31588. File: mysql.info,  Node: InnoDB init,  Next: Using InnoDB tables,  Prev: InnoDB start,  Up: InnoDB
  31589.  
  31590. Creating InnoDB table space
  31591. ---------------------------
  31592.  
  31593. Suppose you have installed MySQL and have edited `my.cnf' so that it
  31594. contains the necessary InnoDB configuration parameters.  Before
  31595. starting MySQL you should check that the directories you have specified
  31596. for InnoDB data files and log files exist and that you have access
  31597. rights to those directories. InnoDB cannot create directories, only
  31598. files. Check also you have enough disk space for the data and log files.
  31599.  
  31600. When you now start MySQL, InnoDB will start creating your data files
  31601. and log files. InnoDB will print something like the following:
  31602.  
  31603.      ~/mysqlm/sql > mysqld
  31604.      InnoDB: The first specified data file /home/heikki/data/ibdata1 did not exist:
  31605.      InnoDB: a new database to be created!
  31606.      InnoDB: Setting file /home/heikki/data/ibdata1 size to 134217728
  31607.      InnoDB: Database physically writes the file full: wait...
  31608.      InnoDB: Data file /home/heikki/data/ibdata2 did not exist: new to be created
  31609.      InnoDB: Setting file /home/heikki/data/ibdata2 size to 262144000
  31610.      InnoDB: Database physically writes the file full: wait...
  31611.      InnoDB: Log file /home/heikki/data/logs/ib_logfile0 did not exist: new to be c
  31612.      reated
  31613.      InnoDB: Setting log file /home/heikki/data/logs/ib_logfile0 size to 5242880
  31614.      InnoDB: Log file /home/heikki/data/logs/ib_logfile1 did not exist: new to be c
  31615.      reated
  31616.      InnoDB: Setting log file /home/heikki/data/logs/ib_logfile1 size to 5242880
  31617.      InnoDB: Log file /home/heikki/data/logs/ib_logfile2 did not exist: new to be c
  31618.      reated
  31619.      InnoDB: Setting log file /home/heikki/data/logs/ib_logfile2 size to 5242880
  31620.      InnoDB: Started
  31621.      mysqld: ready for connections
  31622.  
  31623. A new InnoDB database has now been created. You can connect to the MySQL
  31624. server with the usual MySQL client programs like `mysql'.  When you
  31625. shut down the MySQL server with `mysqladmin shutdown', InnoDB output
  31626. will be like the following:
  31627.  
  31628.      010321 18:33:34  mysqld: Normal shutdown
  31629.      010321 18:33:34  mysqld: Shutdown Complete
  31630.      InnoDB: Starting shutdown...
  31631.      InnoDB: Shutdown completed
  31632.  
  31633. You can now look at the data files and logs directories and you will
  31634. see the files created. The log directory will also contain a small file
  31635. named `ib_arch_log_0000000000'. That file resulted from the database
  31636. creation, after which InnoDB switched off log archiving.  When MySQL is
  31637. again started, the output will be like the following:
  31638.  
  31639.      ~/mysqlm/sql > mysqld
  31640.      InnoDB: Started
  31641.      mysqld: ready for connections
  31642.  
  31643. * Menu:
  31644.  
  31645. * Error creating InnoDB::       If something goes wrong in database creation
  31646.  
  31647. 
  31648. File: mysql.info,  Node: Error creating InnoDB,  Prev: InnoDB init,  Up: InnoDB init
  31649.  
  31650. If something goes wrong in database creation
  31651. ............................................
  31652.  
  31653. If something goes wrong in an InnoDB database creation, you should
  31654. delete all files created by InnoDB. This means all data files, all log
  31655. files, the small archived log file, and in the case you already did
  31656. create some InnoDB tables, delete also the corresponding `.frm' files
  31657. for these tables from the MySQL database directories. Then you can try
  31658. the InnoDB database creation again.
  31659.  
  31660. 
  31661. File: mysql.info,  Node: Using InnoDB tables,  Next: Adding and removing,  Prev: InnoDB init,  Up: InnoDB
  31662.  
  31663. Creating InnoDB tables
  31664. ----------------------
  31665.  
  31666. Suppose you have started the MySQL client with the command `mysql test'.
  31667. To create a table in the InnoDB format you must specify `TYPE = InnoDB'
  31668. in the table creation SQL command:
  31669.  
  31670.      CREATE TABLE CUSTOMER (A INT, B CHAR (20), INDEX (A)) TYPE = InnoDB;
  31671.  
  31672. This SQL command will create a table and an index on column `A' into
  31673. the InnoDB tablespace consisting of the data files you specified in
  31674. `my.cnf'. In addition MySQL will create a file `CUSTOMER.frm' to the
  31675. MySQL database directory `test'.  Internally, InnoDB will add to its
  31676. own data dictionary an entry for table `'test/CUSTOMER''. Thus you can
  31677. create a table of the same name `CUSTOMER' in another database of
  31678. MySQL, and the table names will not collide inside InnoDB.
  31679.  
  31680. You can query the amount of free space in the InnoDB tablespace by
  31681. issuing the table status command of MySQL for any table you have
  31682. created with `TYPE = InnoDB'. Then the amount of free space in the
  31683. tablespace appears in the table comment section in the output of
  31684. `SHOW'. An example:
  31685.  
  31686.      SHOW TABLE STATUS FROM test LIKE 'CUSTOMER'
  31687.  
  31688. Note that the statistics `SHOW' gives about InnoDB tables are only
  31689. approximate: they are used in SQL optimization. Table and index
  31690. reserved sizes in bytes are accurate, though.
  31691.  
  31692. NOTE: `DROP DATABASE' does not currently work for InnoDB tables!  You
  31693. must drop the tables individually. Also take care not to delete or add
  31694. `.frm' files to your InnoDB database manually: use `CREATE TABLE' and
  31695. `DROP TABLE' commands.  InnoDB has its own internal data dictionary,
  31696. and you will get problems if the MySQL `.frm' files are out of 'sync'
  31697. with the InnoDB internal data dictionary.
  31698.  
  31699. Converting MyISAM tables to InnoDB
  31700. ..................................
  31701.  
  31702. InnoDB does not have a special optimization for separate index creation.
  31703. Therefore it does not pay to export and import the table and create
  31704. indexes afterwards.  The fastest way to alter a table to InnoDB is to
  31705. do the inserts directly to an InnoDB table, that is, use `ALTER TABLE
  31706. ... TYPE=INNODB', or create an empty InnoDB table with identical
  31707. definitions and insert the rows with `INSERT INTO ... SELECT * FROM
  31708. ...'.
  31709.  
  31710. To get better control over the insertion process, it may be good to
  31711. insert big tables in pieces:
  31712.  
  31713.      INSERT INTO newtable SELECT * FROM oldtable WHERE yourkey > something
  31714.                                                   AND yourkey <= somethingelse;
  31715.  
  31716. After all data has been inserted you can rename the tables.
  31717.  
  31718. During the conversion of big tables you should set the InnoDB buffer
  31719. pool size big to reduce disk i/o. Not bigger than 80 % of the physical
  31720. memory, though.  You should set InnoDB log files big, and also the log
  31721. buffer large.
  31722.  
  31723. Make sure you do not run out of tablespace: InnoDB tables take a lot
  31724. more space than MyISAM tables. If an `ALTER TABLE' runs out of space,
  31725. it will start a rollback, and that can take hours if it is disk-bound.
  31726. In inserts InnoDB uses the insert buffer to merge secondary index
  31727. records to indexes in batches. That saves a lot of disk i/o. In
  31728. rollback no such mechanism is used, and the rollback can take 30 times
  31729. longer than the insertion.
  31730.  
  31731. In the case of a runaway rollback, if you do not have valuable data in
  31732. your database, it is better that you kill the database process and
  31733. delete all InnoDB data and log files and all InnoDB table `.frm' files,
  31734. and start your job again, rather than wait for millions of disk i/os to
  31735. complete.
  31736.  
  31737. 
  31738. File: mysql.info,  Node: Adding and removing,  Next: Backing up,  Prev: Using InnoDB tables,  Up: InnoDB
  31739.  
  31740. Adding and removing InnoDB data and log files
  31741. ---------------------------------------------
  31742.  
  31743. You cannot increase the size of an InnoDB data file. To add more into
  31744. your tablespace you have to add a new data file. To do this you have to
  31745. shut down your MySQL database, edit the `my.cnf' file, adding a new
  31746. file to `innodb_data_file_path', and then start MySQL again.
  31747.  
  31748. Currently you cannot remove a data file from InnoDB. To decrease the
  31749. size of your database you have to use `mysqldump' to dump all your
  31750. tables, create a new database, and import your tables to the new
  31751. database.
  31752.  
  31753. If you want to change the number or the size of your InnoDB log files,
  31754. you have to shut down MySQL and make sure that it shuts down without
  31755. errors.  Then copy the old log files into a safe place just in case
  31756. something went wrong in the shutdown and you will need them to recover
  31757. the database. Delete then the old log files from the log file directory,
  31758. edit `my.cnf', and start MySQL again. InnoDB will tell you at the
  31759. startup that it is creating new log files.
  31760.  
  31761. 
  31762. File: mysql.info,  Node: Backing up,  Next: Moving,  Prev: Adding and removing,  Up: InnoDB
  31763.  
  31764. Backing up and recovering an InnoDB database
  31765. --------------------------------------------
  31766.  
  31767. The key to safe database management is taking regular backups.  To take
  31768. a 'binary' backup of your database you have to do the following:
  31769.  
  31770.    * Shut down your MySQL database and make sure it shuts down without
  31771.      errors.
  31772.  
  31773.    * Copy all your data files into a safe place.
  31774.  
  31775.    * Copy all your InnoDB log files to a safe place.
  31776.  
  31777.    * Copy your `my.cnf' configuration file(s) to a safe place.
  31778.  
  31779.    * Copy all the `.frm' files for your InnoDB tables into a safe place.
  31780.  
  31781. There is currently no on-line or incremental backup tool available for
  31782. InnoDB, though they are in the TODO list.
  31783.  
  31784. In addition to taking the binary backups described above, you should
  31785. also regularly take dumps of your tables with `mysqldump'. The reason
  31786. to this is that a binary file may be corrupted without you noticing it.
  31787. Dumped tables are stored into text files which are human-readable and
  31788. much simpler than database binary files. Seeing table corruption from
  31789. dumped files is easier, and since their format is simpler, the chance
  31790. for serious data corruption in them is smaller.
  31791.  
  31792. A good idea is to take the dumps at the same time you take a binary
  31793. backup of your database. You have to shut out all clients from your
  31794. database to get a consistent snapshot of all your tables into your
  31795. dumps. Then you can take the binary backup, and you will then have a
  31796. consistent snapshot of your database in two formats.
  31797.  
  31798. To be able to recover your InnoDB database to the present from the
  31799. binary backup described above, you have to run your MySQL database with
  31800. the general logging and log archiving of MySQL switched on. Here by the
  31801. general logging we mean the logging mechanism of the MySQL server which
  31802. is independent of InnoDB logs.
  31803.  
  31804. To recover from a crash of your MySQL server process, the only thing
  31805. you have to do is to restart it. InnoDB will automatically check the
  31806. logs and perform a roll-forward of the database to the present.  InnoDB
  31807. will automatically roll back uncommitted transactions which were
  31808. present at the time of the crash. During recovery, InnoDB will print
  31809. out something like the following:
  31810.  
  31811.      ~/mysqlm/sql > mysqld
  31812.      InnoDB: Database was not shut down normally.
  31813.      InnoDB: Starting recovery from log files...
  31814.      InnoDB: Starting log scan based on checkpoint at
  31815.      InnoDB: log sequence number 0 13674004
  31816.      InnoDB: Doing recovery: scanned up to log sequence number 0 13739520
  31817.      InnoDB: Doing recovery: scanned up to log sequence number 0 13805056
  31818.      InnoDB: Doing recovery: scanned up to log sequence number 0 13870592
  31819.      InnoDB: Doing recovery: scanned up to log sequence number 0 13936128
  31820.      ...
  31821.      InnoDB: Doing recovery: scanned up to log sequence number 0 20555264
  31822.      InnoDB: Doing recovery: scanned up to log sequence number 0 20620800
  31823.      InnoDB: Doing recovery: scanned up to log sequence number 0 20664692
  31824.      InnoDB: 1 uncommitted transaction(s) which must be rolled back
  31825.      InnoDB: Starting rollback of uncommitted transactions
  31826.      InnoDB: Rolling back trx no 16745
  31827.      InnoDB: Rolling back of trx no 16745 completed
  31828.      InnoDB: Rollback of uncommitted transactions completed
  31829.      InnoDB: Starting an apply batch of log records to the database...
  31830.      InnoDB: Apply batch completed
  31831.      InnoDB: Started
  31832.      mysqld: ready for connections
  31833.  
  31834. If your database gets corrupted or your disk fails, you have to do the
  31835. recovery from a backup. In the case of corruption, you should first
  31836. find a backup which is not corrupted. From a backup do the recovery
  31837. from the general log files of MySQL according to instructions in the
  31838. MySQL manual.
  31839.  
  31840. * Menu:
  31841.  
  31842. * InnoDB checkpoints::          Checkpoints
  31843.  
  31844. 
  31845. File: mysql.info,  Node: InnoDB checkpoints,  Prev: Backing up,  Up: Backing up
  31846.  
  31847. Checkpoints
  31848. ...........
  31849.  
  31850. InnoDB implements a checkpoint mechanism called a fuzzy checkpoint.
  31851. InnoDB will flush modified database pages from the buffer pool in small
  31852. batches, there is no need to flush the buffer pool in one single batch,
  31853. which would in practice stop processing of user SQL statements for a
  31854. while.
  31855.  
  31856. In crash recovery InnoDB looks for a checkpoint label written to the
  31857. log files. It knows that all modifications to the database before the
  31858. label are already present on the disk image of the database.  Then
  31859. InnoDB scans the log files forward from the place of the checkpoint
  31860. applying the logged modifications to the database.
  31861.  
  31862. InnoDB writes to the log files in a circular fashion.  All committed
  31863. modifications which make the database pages in the buffer pool
  31864. different from the images on disk must be available in the log files in
  31865. case InnoDB has to do a recovery. This means that when InnoDB starts to
  31866. reuse a log file in the circular fashion, it has to make sure that the
  31867. database page images on disk already contain the modifications logged
  31868. in the log file InnoDB is going to reuse. In other words, InnoDB has to
  31869. make a checkpoint and often this involves flushing of modified database
  31870. pages to disk.
  31871.  
  31872. The above explains why making your log files very big may save disk i/o
  31873. in checkpointing. It can make sense to set the total size of the log
  31874. files as big as the buffer pool or even bigger.  The drawback in big
  31875. log files is that crash recovery can last longer because there will be
  31876. more log to apply to the database.
  31877.  
  31878. 
  31879. File: mysql.info,  Node: Moving,  Next: InnoDB transaction model,  Prev: Backing up,  Up: InnoDB
  31880.  
  31881. Moving an InnoDB database to another machine
  31882. --------------------------------------------
  31883.  
  31884. InnoDB data and log files are binary-compatible on all platforms if the
  31885. floating point number format on the machines is the same.  You can move
  31886. an InnoDB database simply by copying all the relevant files, which we
  31887. already listed in the previous section on backing up a database. If the
  31888. floating point formats on the machines are different but you have not
  31889. used `FLOAT' or `DOUBLE' data types in your tables then the procedure
  31890. is the same: just copy the relevant files. If the formats are different
  31891. and your tables contain floating point data, you have to use `mysqldump'
  31892. and `mysqlimport' to move those tables.
  31893.  
  31894. A performance tip is to switch off the auto commit when you import data
  31895. into your database, assuming your tablespace has enough space for the
  31896. big rollback segment the big import transaction will generate.  Do the
  31897. commit only after importing a whole table or a segment of a table.
  31898.  
  31899. 
  31900. File: mysql.info,  Node: InnoDB transaction model,  Next: Implementation,  Prev: Moving,  Up: InnoDB
  31901.  
  31902. InnoDB transaction model
  31903. ------------------------
  31904.  
  31905. In the InnoDB transaction model the goal has been to combine the best
  31906. sides of a multiversioning database to traditional two-phase locking.
  31907. InnoDB does locking on row level and runs queries by default as
  31908. non-locking consistent reads, in the style of Oracle.  The lock table
  31909. in InnoDB is stored so space-efficiently that lock escalation is not
  31910. needed: typically several users are allowed to lock every row in the
  31911. database, or any random subset of the rows, without InnoDB running out
  31912. of memory.
  31913.  
  31914. In InnoDB all user activity happens inside transactions. If the auto
  31915. commit mode is used in MySQL, then each SQL statement will form a
  31916. single transaction. If the auto commit mode is switched off, then we
  31917. can think that a user always has a transaction open. If he issues the
  31918. SQL `COMMIT' or `ROLLBACK' statement, that ends the current
  31919. transaction, and a new starts. Both statements will release all InnoDB
  31920. locks that were set during the current transaction. A `COMMIT' means
  31921. that the changes made in the current transaction are made permanent and
  31922. become visible to other users. A `ROLLBACK' on the other hand cancels
  31923. all modifications made by the current transaction.
  31924.  
  31925. * Menu:
  31926.  
  31927. * InnoDB consistent read::      Consistent read
  31928. * InnoDB locking reads::        Locking reads
  31929. * InnoDB Next-key locking::     Next-key locking: avoiding the phantom problem
  31930. * InnoDB Locks set::            Locks set by different SQL statements in InnoDB
  31931. * InnoDB Deadlock detection::   Deadlock detection and rollback
  31932. * InnoDB Consistent read example::  An example of how the consistent read works in InnoDB
  31933.  
  31934. 
  31935. File: mysql.info,  Node: InnoDB consistent read,  Next: InnoDB locking reads,  Prev: InnoDB transaction model,  Up: InnoDB transaction model
  31936.  
  31937. Consistent read
  31938. ...............
  31939.  
  31940. A consistent read means that InnoDB uses its multiversioning to present
  31941. to a query a snapshot of the database at a point in time.  The query
  31942. will see the changes made by exactly those transactions that committed
  31943. before that point of time, and no changes made by later or uncommitted
  31944. transactions. The exception to this rule is that the query will see the
  31945. changes made by the transaction itself which issues the query.
  31946.  
  31947. When a transaction issues its first consistent read, InnoDB assigns the
  31948. snapshot, or the point of time, which all consistent reads in the same
  31949. transaction will use. In the snapshot are all transactions that
  31950. committed before assigning the snapshot. Thus the consistent reads
  31951. within the same transaction will also be consistent with respect to each
  31952. other. You can get a fresher snapshot for your queries by committing
  31953. the current transaction and after that issuing new queries.
  31954.  
  31955. Consistent read is the default mode in which InnoDB processes `SELECT'
  31956. statements. A consistent read does not set any locks on the tables it
  31957. accesses, and therefore other users are free to modify those tables at
  31958. the same time a consistent read is being performed on the table.
  31959.  
  31960. 
  31961. File: mysql.info,  Node: InnoDB locking reads,  Next: InnoDB Next-key locking,  Prev: InnoDB consistent read,  Up: InnoDB transaction model
  31962.  
  31963. Locking reads
  31964. .............
  31965.  
  31966. A consistent read is not convenient in some circumstances.  Suppose you
  31967. want to add a new row into your table `CHILD', and make sure that the
  31968. child already has a parent in table `PARENT'.
  31969.  
  31970. Suppose you use a consistent read to read the table `PARENT' and indeed
  31971. see the parent of the child in the table. Can you now safely add the
  31972. child row to table `CHILD'? No, because it may happen that meanwhile
  31973. some other user has deleted the parent row from the table `PARENT', and
  31974. you are not aware of that.
  31975.  
  31976. The solution is to perform the `SELECT' in a locking mode, `LOCK IN
  31977. SHARE MODE'.
  31978.  
  31979.      SELECT * FROM PARENT WHERE NAME = 'Jones' LOCK IN SHARE MODE;
  31980.  
  31981. Performing a read in share mode means that we read the latest available
  31982. data, and set a shared mode lock on the rows we read.  If the latest
  31983. data belongs to a yet uncommitted transaction of another user, we will
  31984. wait until that transaction commits.  A shared mode lock prevents
  31985. others from updating or deleting the row we have read. After we see
  31986. that the above query returns the parent `'Jones'', we can safely add
  31987. his child to table `CHILD', and commit our transaction.  This example
  31988. shows how to implement referential integrity in your application code.
  31989.  
  31990. Let us look at another example: we have an integer counter field in a
  31991. table `CHILD_CODES' which we use to assign a unique identifier to each
  31992. child we add to table `CHILD'.  Obviously, using a consistent read or a
  31993. shared mode read to read the present value of the counter is not a good
  31994. idea, since then two users of the database may see the same value for
  31995. the counter, and we will get a duplicate key error when we add the two
  31996. children with the same identifier to the table.
  31997.  
  31998. In this case there are two good ways to implement the reading and
  31999. incrementing of the counter: (1) update the counter first by
  32000. incrementing it by 1 and only after that read it, or (2) read the
  32001. counter first with a lock mode `FOR UPDATE', and increment after that:
  32002.  
  32003.      SELECT COUNTER_FIELD FROM CHILD_CODES FOR UPDATE;
  32004.      UPDATE CHILD_CODES SET COUNTER_FIELD = COUNTER_FIELD + 1;
  32005.  
  32006. A `SELECT ... FOR UPDATE' will read the latest available data setting
  32007. exclusive locks on each row it reads.  Thus it sets the same locks a
  32008. searched SQL `UPDATE' would set on the rows.
  32009.  
  32010. 
  32011. File: mysql.info,  Node: InnoDB Next-key locking,  Next: InnoDB Locks set,  Prev: InnoDB locking reads,  Up: InnoDB transaction model
  32012.  
  32013. Next-key locking: avoiding the phantom problem
  32014. ..............................................
  32015.  
  32016. In row level locking InnoDB uses an algorithm called next-key locking.
  32017. InnoDB does the row level locking so that when it searches or scans an
  32018. index of a table, it sets shared or exclusive locks on the index
  32019. records in encounters. Thus the row level locks are more precisely
  32020. called index record locks.
  32021.  
  32022. The locks InnoDB sets on index records also affect the 'gap' before
  32023. that index record. If a user has a shared or exclusive lock on record R
  32024. in an index, then another user cannot insert a new index record
  32025. immediately before R in the index order.  This locking of gaps is done
  32026. to prevent the so-called phantom problem. Suppose I want to read and
  32027. lock all children with identifier bigger than 100 from table `CHILD',
  32028. and update some field in the selected rows.
  32029.  
  32030.      SELECT * FROM CHILD WHERE ID > 100 FOR UPDATE;
  32031.  
  32032. Suppose there is an index on table `CHILD' on column `ID'. Our query
  32033. will scan that index starting from the first record where `ID' is
  32034. bigger than 100.  Now, if the locks set on the index records would not
  32035. lock out inserts made in the gaps, a new child might meanwhile be
  32036. inserted to the table. If now I in my transaction execute
  32037.  
  32038.      SELECT * FROM CHILD WHERE ID > 100 FOR UPDATE;
  32039.  
  32040. again, I will see a new child in the result set the query returns.
  32041. This is against the isolation principle of transactions: a transaction
  32042. should be able to run so that the data it has read does not change
  32043. during the transaction. If we regard a set of rows as a data item, then
  32044. the new 'phantom' child would break this isolation principle.
  32045.  
  32046. When InnoDB scans an index it can also lock the gap after the last
  32047. record in the index. Just that happens in the previous example: the
  32048. locks set by InnoDB will prevent any insert to the table where `ID'
  32049. would be bigger than 100.
  32050.  
  32051. You can use the next-key locking to implement a uniqueness check in
  32052. your application: if you read your data in share mode and do not see a
  32053. duplicate for a row you are going to insert, then you can safely insert
  32054. your row and know that the next-key lock set on the successor of your
  32055. row during the read will prevent anyone meanwhile inserting a duplicate
  32056. for your row. Thus the next-key locking allows you to 'lock' the
  32057. non-existence of something in your table.
  32058.  
  32059. 
  32060. File: mysql.info,  Node: InnoDB Locks set,  Next: InnoDB Deadlock detection,  Prev: InnoDB Next-key locking,  Up: InnoDB transaction model
  32061.  
  32062. Locks set by different SQL statements in InnoDB
  32063. ...............................................
  32064.  
  32065.    * `SELECT ... FROM ...' : this is a consistent read, reading a
  32066.      snapshot of the database and setting no locks.
  32067.  
  32068.    * `SELECT ... FROM ... LOCK IN SHARE MODE' : sets shared next-key
  32069.      locks on all index records the read encounters.
  32070.  
  32071.    * `SELECT ... FROM ... FOR UPDATE' : sets exclusive next-key locks
  32072.      on all index records the read encounters.
  32073.  
  32074.    * `INSERT INTO ... VALUES (...)' : sets an exclusive lock on the
  32075.      inserted row; note that this lock is not a next-key lock and does
  32076.      not prevent other users from inserting to the gap before the
  32077.      inserted row. If a duplicate key error occurs, sets a shared lock
  32078.      on the duplicate index record.
  32079.  
  32080.    * `INSERT INTO T SELECT ... FROM S WHERE ...' sets an exclusive
  32081.      (non-next-key) lock on each row inserted into `T'. Does the search
  32082.      on `S' as a consistent read, but sets shared next-key locks on `S'
  32083.      if the MySQL logging is on. InnoDB has to set locks in the latter
  32084.      case because in roll-forward recovery from a backup every SQL
  32085.      statement has to be executed in exactly the same way as it was
  32086.      done originally.
  32087.  
  32088.    * `CREATE TABLE ... SELECT ...' performs the `SELECT' as a
  32089.      consistent read or with shared locks, like in the previous item.
  32090.  
  32091.    * `REPLACE' is done like an insert if there is no collision on a
  32092.      unique key. Otherwise, an exclusive next-key lock is placed on the
  32093.      row which has to be updated.
  32094.  
  32095.    * `UPDATE ... SET ... WHERE ...' : sets an exclusive next-key lock
  32096.      on every record the search encounters.
  32097.  
  32098.    * `DELETE FROM ... WHERE ...' : sets an exclusive next-key lock on
  32099.      every record the search encounters.
  32100.  
  32101.    * `LOCK TABLES ... ' : sets table locks. In the implementation the
  32102.      MySQL layer of code sets these locks. The automatic deadlock
  32103.      detection of InnoDB cannot detect deadlocks where such table locks
  32104.      are involved: see the next section below. See also section 13
  32105.      'InnoDB restrictions' about the following: since MySQL does know
  32106.      about row level locks, it is possible that you get a table lock on
  32107.      a table where another user currently has row level locks. But that
  32108.      does not put transaction integerity into danger.
  32109.  
  32110. 
  32111. File: mysql.info,  Node: InnoDB Deadlock detection,  Next: InnoDB Consistent read example,  Prev: InnoDB Locks set,  Up: InnoDB transaction model
  32112.  
  32113. Deadlock detection and rollback
  32114. ...............................
  32115.  
  32116. InnoDB automatically detects a deadlock of transactions and rolls back
  32117. the transaction whose lock request was the last one to build a
  32118. deadlock, that is, a cycle in the waits-for graph of transactions.
  32119. InnoDB cannot detect deadlocks where a lock set by a MySQL `LOCK
  32120. TABLES' statement is involved, or if a lock set in another table
  32121. handler than InnoDB is involved. You have to resolve these situations
  32122. using `innodb_lock_wait_timeout' set in `my.cnf'.
  32123.  
  32124. When InnoDB performs a complete rollback of a transaction, all the
  32125. locks of the transaction are released. However, if just a single SQL
  32126. statement is rolled back as a result of an error, some of the locks set
  32127. by the SQL statement may be preserved. This is because InnoDB stores
  32128. row locks in a format where it cannot afterwards know which was set by
  32129. which SQL statement.
  32130.  
  32131. 
  32132. File: mysql.info,  Node: InnoDB Consistent read example,  Prev: InnoDB Deadlock detection,  Up: InnoDB transaction model
  32133.  
  32134. An example of how the consistent read works in InnoDB
  32135. .....................................................
  32136.  
  32137. When you issue a consistent read, that is, an ordinary `SELECT'
  32138. statement, InnoDB will give your transaction a timepoint according to
  32139. which your query sees the database. Thus, if transaction B deletes a
  32140. row and commits after your timepoint was assigned, then you will not
  32141. see the row deleted. Similarly with inserts and updates.
  32142.  
  32143. You can advance your timepoint by committing your transaction and then
  32144. doing another `SELECT'.
  32145.  
  32146. This is called multiversioned concurrency control.
  32147.  
  32148.                        User A                 User B
  32149.      
  32150.                    set autocommit=0;      set autocommit=0;
  32151.      time
  32152.      |             SELECT * FROM t;
  32153.      |             empty set
  32154.      |                                    INSERT INTO t VALUES (1, 2);
  32155.      |
  32156.      v             SELECT * FROM t;
  32157.                    empty set
  32158.                                           COMMIT;
  32159.      
  32160.                    SELECT * FROM t;
  32161.                    empty set;
  32162.      
  32163.                    COMMIT;
  32164.      
  32165.                    SELECT * FROM t;
  32166.                    ----------------------
  32167.                    |     1    |    2   |
  32168.                    ----------------------
  32169.  
  32170. Thus user A sees the row inserted by B only when B has committed the
  32171. insert, and A has committed his own transaction so that the timepoint
  32172. is advanced past the the commit of B.
  32173.  
  32174. If you want to see the 'freshest' state of the database, you should use
  32175. a locking read:
  32176.  
  32177.      SELECT * FROM t LOCK IN SHARE MODE;
  32178.  
  32179. Performance tuning tips
  32180. -----------------------
  32181.  
  32182. *1.* If the Unix `top' or the Windows `Task Manager' shows that the CPU
  32183. usage percentage with your workload is less than 70 %, your workload is
  32184. probably disk-bound. Maybe you are making too many transaction commits,
  32185. or the buffer pool is too small.  Making the buffer pool bigger can
  32186. help, but do not set it bigger than 80 % of physical memory.
  32187.  
  32188. *2.* Wrap several modifications into one transaction. InnoDB must flush
  32189. the log to disk at each transaction commit, if that transaction made
  32190. modifications to the database. Since the rotation speed of a disk is
  32191. typically at most 167 revolutions/second, that constrains the number of
  32192. commits to the same 167/second if the disk does not fool the operating
  32193. system.
  32194.  
  32195. *3.* If you can afford the loss of some latest committed transactions,
  32196. you can set the `my.cnf' parameter `innodb_flush_log_at_trx_commit' to
  32197. zero. InnoDB tries to flush the log anyway once in a second, though the
  32198. flush is not guaranteed.
  32199.  
  32200. *4.* Make your log files big, even as big as the buffer pool. When
  32201. InnoDB has written the log files full, it has to write the modified
  32202. contents of the buffer pool to disk in a checkpoint. Small log files
  32203. will cause many unnecessary disk writes. The drawback in big log files
  32204. is that recovery time will be longer.
  32205.  
  32206. *5.* Also the log buffer should be quite big, say 8 MB.
  32207.  
  32208. *6.* (Relevant from 3.23.39 up.)  In some versions of Linux and Unix,
  32209. flushing files to disk with the Unix `fdatasync' and other similar
  32210. methods is surprisingly slow.  The default method InnoDB uses is the
  32211. `fdatasync' function.  If you are not satisfied with the database write
  32212. performance, you may try setting `innodb_flush_method' in `my.cnf' to
  32213. `O_DSYNC', though O_DSYNC seems to be slower on most systems.
  32214.  
  32215. *7.* In importing data to InnoDB, make sure that MySQL does not have
  32216. `autocommit=1' on. Then every insert requires a log flush to disk.  Put
  32217. before your plain SQL import file line
  32218.  
  32219.      set autocommit=0;
  32220.  
  32221. and after it
  32222.  
  32223.      commit;
  32224.  
  32225. If you use the `mysqldump' option `--opt', you will get dump files
  32226. which are fast to import also to an InnoDB table, even without wrapping
  32227. them to the above `set autocommit=0; ... commit;' wrappers.
  32228.  
  32229. *8.* Beware of big rollbacks of mass inserts: InnoDB uses the insert
  32230. buffer to save disk i/o in inserts, but in a corresponding rollback no
  32231. such mechanism is used. A disk-bound rollback can take 30 times the time
  32232. of the corresponding insert. Killing the database process will not help
  32233. because the rollback will start again at the database startup. The only
  32234. way to get rid of a runaway rollback is to increase the buffer pool so
  32235. that the rollback becomes CPU-bound and runs fast, or delete the whole
  32236. InnoDB database.
  32237.  
  32238. *9.* Beware also of other big disk-bound operations.  Use `DROP TABLE'
  32239. or `TRUNCATE' (from MySQL-4.0 up) to empty a table, not `DELETE FROM
  32240. yourtable'.
  32241.  
  32242. *10.* Use the multi-line `INSERT' to reduce communication overhead
  32243. between the client and the server if you need to insert many rows:
  32244.  
  32245.      INSERT INTO yourtable VALUES (1, 2), (5, 5);
  32246.  
  32247. This tip is of course valid for inserts into any table type, not just
  32248. InnoDB.
  32249.  
  32250. The InnoDB Monitor
  32251. ..................
  32252.  
  32253. Starting from version 3.23.41 InnoDB includes the InnoDB Monitor which
  32254. prints information on the InnoDB internal state.  When swithed on,
  32255. InnoDB Monitor will make the MySQL server to print data to the standard
  32256. output about once every 10 seconds. This data is useful in performance
  32257. tuning.
  32258.  
  32259. The printed information includes data on:
  32260.    * table and record locks held by each active transaction,
  32261.  
  32262.    * lock waits of a transactions,
  32263.  
  32264.    * semaphore waits of threads,
  32265.  
  32266.    * pending file i/o requests,
  32267.  
  32268.    * buffer pool statistics, and
  32269.  
  32270.    * purge and insert buffer merge activity of the main thread of
  32271.      InnoDB.
  32272.  
  32273. You can start InnoDB Monitor through the following SQL command:
  32274.  
  32275.      CREATE TABLE innodb_monitor(a int) type = innodb;
  32276.  
  32277. and stop it by
  32278.  
  32279.      DROP TABLE innodb_monitor;
  32280.  
  32281. The `CREATE TABLE' syntax is just a way to pass a command to the InnoDB
  32282. engine through the MySQL SQL parser: the created table is not relevant
  32283. at all for InnoDB Monitor. If you shut down the database when the
  32284. monitor is running, and you want to start the monitor again, you have
  32285. to drop the table before you can issue a new `CREATE TABLE' to start
  32286. the monitor.  This syntax may change in a future release.
  32287.  
  32288. A sample output of the InnoDB Monitor:
  32289.  
  32290.      ================================
  32291.      010809 18:45:06 INNODB MONITOR OUTPUT
  32292.      ================================
  32293.      --------------------------
  32294.      LOCKS HELD BY TRANSACTIONS
  32295.      --------------------------
  32296.      LOCK INFO:
  32297.      Number of locks in the record hash table 1294
  32298.      LOCKS FOR TRANSACTION ID 0 579342744
  32299.      TABLE LOCK table test/mytable trx id 0 582333343 lock_mode IX
  32300.      
  32301.      RECORD LOCKS space id 0 page no 12758 n bits 104 table test/mytable index
  32302.      PRIMARY trx id 0 582333343 lock_mode X
  32303.      Record lock, heap no 2 PHYSICAL RECORD: n_fields 74; 1-byte offs FALSE;
  32304.      info bits 0
  32305.       0: len 4; hex 0001a801; asc ;; 1: len 6; hex 000022b5b39f; asc ";; 2: len 7;
  32306.      hex 000002001e03ec; asc ;; 3: len 4; hex 00000001;
  32307.      ...
  32308.      -----------------------------------------------
  32309.      CURRENT SEMAPHORES RESERVED AND SEMAPHORE WAITS
  32310.      -----------------------------------------------
  32311.      SYNC INFO:
  32312.      Sorry, cannot give mutex list info in non-debug version!
  32313.      Sorry, cannot give rw-lock list info in non-debug version!
  32314.      -----------------------------------------------------
  32315.      SYNC ARRAY INFO: reservation count 6041054, signal count 2913432
  32316.      4a239430 waited for by thread 49627477 op. S-LOCK file NOT KNOWN line 0
  32317.      Mut ex 0 sp 5530989 r 62038708 sys 2155035; rws 0 8257574 8025336; rwx 0 1121090 1848344
  32318.      -----------------------------------------------------
  32319.      CURRENT PENDING FILE I/O'S
  32320.      --------------------------
  32321.      Pending normal aio reads:
  32322.      Reserved slot, messages 40157658 4a4a40b8
  32323.      Reserved slot, messages 40157658 4a477e28
  32324.      ...
  32325.      Reserved slot, messages 40157658 4a4424a8
  32326.      Reserved slot, messages 40157658 4a39ea38
  32327.      Total of 36 reserved aio slots
  32328.      Pending aio writes:
  32329.      Total of 0 reserved aio slots
  32330.      Pending insert buffer aio reads:
  32331.      Total of 0 reserved aio slots
  32332.      Pending log writes or reads:
  32333.      Reserved slot, messages 40158c98 40157f98
  32334.      Total of 1 reserved aio slots
  32335.      Pending synchronous reads or writes:
  32336.      Total of 0 reserved aio slots
  32337.      -----------
  32338.      BUFFER POOL
  32339.      -----------
  32340.      LRU list length 8034
  32341.      Free list length 0
  32342.      Flush list length 999
  32343.      Buffer pool size in pages 8192
  32344.      Pending reads 39
  32345.      Pending writes: LRU 0, flush list 0, single page 0
  32346.      Pages read 31383918, created 51310, written 2985115
  32347.      ----------------------------
  32348.      END OF INNODB MONITOR OUTPUT
  32349.      ============================
  32350.      010809 18:45:22 InnoDB starts purge
  32351.      010809 18:45:22 InnoDB purged 0 pages
  32352.  
  32353. Some notes on the output:
  32354.  
  32355.    * If the section LOCKS HELD BY TRANSACTIONS reports lock waits, then
  32356.      your application may have lock contention. The output can also
  32357.      help to trace reasons for transaction deadlocks.
  32358.  
  32359.    * Section SYNC INFO will report reserved semaphores if you compile
  32360.      InnoDB with <code>UNIV_SYNC_DEBUG</code> defined in
  32361.      <tt>univ.i</tt>.
  32362.  
  32363.    * Section SYNC ARRAY INFO reports threads waiting for a semaphore
  32364.      and statistics on how many times threads have needed a spin or a
  32365.      wait on a mutex or a rw-lock semaphore. A big number of threads
  32366.      waiting for semaphores may be a result of disk i/o, or contention
  32367.      problems inside InnoDB. Contention can be due to heavy parallelism
  32368.      of queries, or problems in operating system thread scheduling.
  32369.  
  32370.    * Section CURRENT PENDING FILE I/O'S lists pending file i/o
  32371.      requests. A large number of these indicates that the workload is
  32372.      disk i/o -bound.
  32373.  
  32374.    * Section BUFFER POOL gives you statistics on pages read and
  32375.      written. You can calculate from these numbers how many data file
  32376.      i/o's your queries are currently doing.
  32377.  
  32378. 
  32379. File: mysql.info,  Node: Implementation,  Next: Table and index,  Prev: InnoDB transaction model,  Up: InnoDB
  32380.  
  32381. Implementation of multiversioning
  32382. ---------------------------------
  32383.  
  32384. Since InnoDB is a multiversioned database, it must keep information of
  32385. old versions of rows in the tablespace. This information is stored in a
  32386. data structure we call a rollback segment after an analogous data
  32387. structure in Oracle.
  32388.  
  32389. InnoDB internally adds two fields to each row stored in the database.
  32390. A 6-byte field tells the transaction identifier for the last
  32391. transaction which inserted or updated the row. Also a deletion is
  32392. internally treated as an update where a special bit in the row is set
  32393. to mark it as deleted. Each row also contains a 7-byte field called the
  32394. roll pointer. The roll pointer points to an undo log record written to
  32395. the rollback segment. If the row was updated, then the undo log record
  32396. contains the information necessary to rebuild the content of the row
  32397. before it was updated.
  32398.  
  32399. InnoDB uses the information in the rollback segment to perform the undo
  32400. operations needed in a transaction rollback. It also uses the
  32401. information to build earlier versions of a row for a consistent read.
  32402.  
  32403. Undo logs in the rollback segment are divided into insert and update
  32404. undo logs. Insert undo logs are only needed in transaction rollback and
  32405. can be discarded as soon as the transaction commits. Update undo logs
  32406. are used also in consistent reads, and they can be discarded only after
  32407. there is no transaction present for which InnoDB has assigned a
  32408. snapshot that in a consistent read could need the information in the
  32409. update undo log to build an earlier version of a database row.
  32410.  
  32411. You must remember to commit your transactions regularly. Otherwise
  32412. InnoDB cannot discard data from the update undo logs, and the rollback
  32413. segment may grow too big, filling up your tablespace.
  32414.  
  32415. The physical size of an undo log record in the rollback segment is
  32416. typically smaller than the corresponding inserted or updated row. You
  32417. can use this information to calculate the space need for your rollback
  32418. segment.
  32419.  
  32420. In our multiversioning scheme a row is not physically removed from the
  32421. database immediately when you delete it with an SQL statement.  Only
  32422. when InnoDB can discard the update undo log record written for the
  32423. deletion, it can also physically remove the corresponding row and its
  32424. index records from the database. This removal operation is called a
  32425. purge, and it is quite fast, usually taking the same order of time as
  32426. the SQL statement which did the deletion.
  32427.  
  32428. 
  32429. File: mysql.info,  Node: Table and index,  Next: File space management,  Prev: Implementation,  Up: InnoDB
  32430.  
  32431. Table and index structures
  32432. --------------------------
  32433.  
  32434. Every InnoDB table has a special index called the clustered index where
  32435. the data of the rows is stored. If you define a `PRIMARY KEY' on your
  32436. table, then the index of the primary key will be the clustered index.
  32437.  
  32438. If you do not define a primary key for your table, InnoDB will
  32439. internally generate a clustered index where the rows are ordered by the
  32440. row id InnoDB assigns to the rows in such a table. The row id is a
  32441. 6-byte field which monotonically increases as new rows are inserted.
  32442. Thus the rows ordered by the row id will be physically in the insertion
  32443. order.
  32444.  
  32445. Accessing a row through the clustered index is fast, because the row
  32446. data will be on the same page where the index search leads us. In many
  32447. databases the data is traditionally stored on a different page from the
  32448. index record. If a table is large, the clustered index architecture
  32449. often saves a disk i/o when compared to the traditional solution.
  32450.  
  32451. The records in non-clustered indexes (we also call them secondary
  32452. indexes), in InnoDB contain the primary key value for the row. InnoDB
  32453. uses this primary key value to search for the row from the clustered
  32454. index. Note that if the primary key is long, the secondary indexes will
  32455. use more space.
  32456.  
  32457. * Menu:
  32458.  
  32459. * InnoDB physical structure::   Physical structure of an index
  32460. * InnoDB Insert buffering::     Insert buffering
  32461. * InnoDB Adaptive hash::        Adaptive hash indexes
  32462. * InnoDB Physical record::      Physical record structure
  32463.  
  32464. 
  32465. File: mysql.info,  Node: InnoDB physical structure,  Next: InnoDB Insert buffering,  Prev: Table and index,  Up: Table and index
  32466.  
  32467. Physical structure of an index
  32468. ..............................
  32469.  
  32470. All indexes in InnoDB are B-trees where the index records are stored in
  32471. the leaf pages of the tree. The default size of an index page is 16 kB.
  32472. When new records are inserted, InnoDB tries to leave 1 / 16 of the page
  32473. free for future insertions and updates of the index records.
  32474.  
  32475. If index records are inserted in a sequential (ascending or descending)
  32476. order, the resulting index pages will be about 15/16 full.  If records
  32477. are inserted in a random order, then the pages will be 1/2 - 15/16
  32478. full. If the fillfactor of an index page drops below 1/2, InnoDB will
  32479. try to contract the index tree to free the page.
  32480.  
  32481. 
  32482. File: mysql.info,  Node: InnoDB Insert buffering,  Next: InnoDB Adaptive hash,  Prev: InnoDB physical structure,  Up: Table and index
  32483.  
  32484. Insert buffering
  32485. ................
  32486.  
  32487. It is a common situation in a database application that the primary key
  32488. is a unique identifier and new rows are inserted in the ascending order
  32489. of the primary key. Thus the insertions to the clustered index do not
  32490. require random reads from a disk.
  32491.  
  32492. On the other hand, secondary indexes are usually non-unique and
  32493. insertions happen in a relatively random order into secondary indexes.
  32494. This would cause a lot of random disk i/o's without a special mechanism
  32495. used in InnoDB.
  32496.  
  32497. If an index record should be inserted to a non-unique secondary index,
  32498. InnoDB checks if the secondary index page is already in the buffer
  32499. pool. If that is the case, InnoDB will do the insertion directly to the
  32500. index page. But, if the index page is not found from the buffer pool,
  32501. InnoDB inserts the record to a special insert buffer structure.  The
  32502. insert buffer is kept so small that it entirely fits in the buffer
  32503. pool, and insertions can be made to it very fast.
  32504.  
  32505. The insert buffer is periodically merged to the secondary index trees
  32506. in the database. Often we can merge several insertions on the same page
  32507. in of the index tree, and hence save disk i/o's.  It has been measured
  32508. that the insert buffer can speed up insertions to a table up to 15
  32509. times.
  32510.  
  32511. 
  32512. File: mysql.info,  Node: InnoDB Adaptive hash,  Next: InnoDB Physical record,  Prev: InnoDB Insert buffering,  Up: Table and index
  32513.  
  32514. Adaptive hash indexes
  32515. .....................
  32516.  
  32517. If a database fits almost entirely in main memory, then the fastest way
  32518. to perform queries on it is to use hash indexes. InnoDB has an
  32519. automatic mechanism which monitors index searches made to the indexes
  32520. defined for a table, and if InnoDB notices that queries could benefit
  32521. from building of a hash index, such an index is automatically built.
  32522.  
  32523. But note that the hash index is always built based on an existing
  32524. B-tree index on the table. InnoDB can build a hash index on a prefix of
  32525. any length of the key defined for the B-tree, depending on what search
  32526. pattern InnoDB observes on the B-tree index.  A hash index can be
  32527. partial: it is not required that the whole B-tree index is cached in
  32528. the buffer pool. InnoDB will build hash indexes on demand to those
  32529. pages of the index which are often accessed.
  32530.  
  32531. In a sense, through the adaptive hash index mechanism InnoDB adapts
  32532. itself to ample main memory, coming closer to the architecture of main
  32533. memory databases.
  32534.  
  32535. 
  32536. File: mysql.info,  Node: InnoDB Physical record,  Prev: InnoDB Adaptive hash,  Up: Table and index
  32537.  
  32538. Physical record structure
  32539. .........................
  32540.  
  32541.    * Each index record in InnoDB contains a header of 6 bytes. The
  32542.      header is used to link consecutive records together, and also in
  32543.      the row level locking.
  32544.  
  32545.    * Records in the clustered index contain fields for all user-defined
  32546.      columns. In addition, there is a 6-byte field for the transaction
  32547.      id and a 7-byte field for the roll pointer.
  32548.  
  32549.    * If the user has not defined a primary key for a table, then each
  32550.      clustered index record contains also a 6-byte row id field.
  32551.  
  32552.    * Each secondary index record contains also all the fields defined
  32553.      for the clustered index key.
  32554.  
  32555.    * A record contains also a pointer to each field of the record.  If
  32556.      the total length of the fields in a record is < 128 bytes, then
  32557.      the pointer is 1 byte, else 2 bytes.
  32558.  
  32559. How an auto-increment column works in InnoDB
  32560. ............................................
  32561.  
  32562. After a database startup, when a user first does an insert to a table
  32563. `T' where an auto-increment column has been defined, and the user does
  32564. not provide an explicit value for the column, then InnoDB executes
  32565. `SELECT MAX(auto-inc-column) FROM T', and assigns that value incremented
  32566. by one to the the column and the auto-increment counter of the table.
  32567. We say that the auto-increment counter for table `T' has been
  32568. initialized.
  32569.  
  32570. InnoDB follows the same procedure in initializing the auto-increment
  32571. counter for a freshly created table.
  32572.  
  32573. Note that if the user specifies in an insert the value 0 to the
  32574. auto-increment column, then InnoDB treats the row like the value would
  32575. not have been specified.
  32576.  
  32577. After the auto-increment counter has been initialized, if a user inserts
  32578. a row where he explicitly specifies the column value, and the value is
  32579. bigger than the current counter value, then the counter is set to the
  32580. specified column value. If the user does not explicitly specify a
  32581. value, then InnoDB increments the counter by one and assigns its new
  32582. value to the column.
  32583.  
  32584. The auto-increment mechanism, when assigning values from the counter,
  32585. bypasses locking and transaction handling. Therefore you may also get
  32586. gaps in the number sequence if you roll back transactions which have
  32587. got numbers from the counter.
  32588.  
  32589. The behavior of auto-increment is not defined if a user gives a negative
  32590. value to the column or if the value becomes bigger than the maximum
  32591. integer that can be stored in the specified integer type.
  32592.  
  32593. 
  32594. File: mysql.info,  Node: File space management,  Next: Error handling,  Prev: Table and index,  Up: InnoDB
  32595.  
  32596. File space management and disk i/o
  32597. ----------------------------------
  32598.  
  32599. * Menu:
  32600.  
  32601. * InnoDB Disk i/o::             Disk i/o
  32602. * InnoDB File space::           File space management
  32603. * InnoDB File Defragmenting::   Defragmenting a table
  32604.  
  32605. 
  32606. File: mysql.info,  Node: InnoDB Disk i/o,  Next: InnoDB File space,  Prev: File space management,  Up: File space management
  32607.  
  32608. Disk i/o
  32609. ........
  32610.  
  32611. In disk i/o InnoDB uses asynchronous i/o. On Windows NT it uses the
  32612. native asynchronous i/o provided by the operating system.  On Unix,
  32613. InnoDB uses simulated asynchronous i/o built into InnoDB: InnoDB
  32614. creates a number of i/o threads to take care of i/o operations, such as
  32615. read-ahead. In a future version we will add support for simulated aio
  32616. on Windows NT and native aio on those versions of Unix which have one.
  32617.  
  32618. On Windows NT InnoDB uses non-buffered i/o. That means that the disk
  32619. pages InnoDB reads or writes are not buffered in the operating system
  32620. file cache. This saves some memory bandwidth.
  32621.  
  32622. Starting from 3.23.41 InnoDB uses a novel file flush technique called
  32623. doublewrite.  It adds safety to crash recovery after an operating
  32624. system crash or a power outage, and improves performance on most Unix
  32625. flavors by reducing the need for fsync operations.
  32626.  
  32627. Doublewrite means that InnoDB before writing pages to a data file first
  32628. writes them to a contiguous tablespace area called the doublewrite
  32629. buffer. Only after the write and the flush to the doublewrite buffer
  32630. has completed, InnoDB writes the pages to their proper positions in the
  32631. data file. If the operating system crashes in the middle of a page
  32632. write, InnoDB will in recovery find a good copy of the page from the
  32633. doublewrite buffer.
  32634.  
  32635. Starting from 3.23.41 you can also use a raw disk partition as a data
  32636. file, though this has not been tested yet. When you create a new data
  32637. file you have to put the keyword `newraw' immediately after the data
  32638. file size in `innodb_data_file_path'. The partition must be >= than you
  32639. specify as the size. Note that 1M in InnoDB is 1024 x 1024 bytes, while
  32640. in disk specifications 1 MB usually means 1000 000 bytes.
  32641.  
  32642.      innodb_data_file_path=hdd1:3Gnewraw;hdd2:2Gnewraw
  32643.  
  32644. When you start the database again you MUST change the keyword to `raw'.
  32645. Otherwise InnoDB will write over your partition!
  32646.  
  32647.      innodb_data_file_path=hdd1:3Graw;hdd2:2Graw
  32648.  
  32649. Using a raw disk you can on some Unixes perform non-buffered i/o.
  32650.  
  32651. There are two read-ahead heuristics in InnoDB: sequential read-ahead
  32652. and random read-ahead. In sequential read-ahead InnoDB notices that the
  32653. access pattern to a segment in the tablespace is sequential.  Then
  32654. InnoDB will post in advance a batch of reads of database pages to the
  32655. i/o system. In random read-ahead InnoDB notices that some area in a
  32656. tablespace seems to be in the process of being fully read into the
  32657. buffer pool. Then InnoDB posts the remaining reads to the i/o system.
  32658.  
  32659. 
  32660. File: mysql.info,  Node: InnoDB File space,  Next: InnoDB File Defragmenting,  Prev: InnoDB Disk i/o,  Up: File space management
  32661.  
  32662. File space management
  32663. .....................
  32664.  
  32665. The data files you define in the configuration file form the tablespace
  32666. of InnoDB. The files are simply catenated to form the tablespace, there
  32667. is no striping in use.  Currently you cannot directly instruct where
  32668. the space is allocated for your tables, except by using the following
  32669. fact: from a newly created tablespace InnoDB will allocate space
  32670. starting from the low end.
  32671.  
  32672. The tablespace consists of database pages whose default size is 16 kB.
  32673. The pages are grouped into extents of 64 consecutive pages. The 'files'
  32674. inside a tablespace are called segments in InnoDB. The name of the
  32675. rollback segment is somewhat misleading because it actually contains
  32676. many segments in the tablespace.
  32677.  
  32678. For each index in InnoDB we allocate two segments: one is for non-leaf
  32679. nodes of the B-tree, the other is for the leaf nodes. The idea here is
  32680. to achieve better sequentiality for the leaf nodes, which contain the
  32681. data.
  32682.  
  32683. When a segment grows inside the tablespace, InnoDB allocates the first
  32684. 32 pages to it individually. After that InnoDB starts to allocate whole
  32685. extents to the segment.  InnoDB can add to a large segment up to 4
  32686. extents at a time to ensure good sequentiality of data.
  32687.  
  32688. Some pages in the tablespace contain bitmaps of other pages, and
  32689. therefore a few extents in an InnoDB tablespace cannot be allocated to
  32690. segments as a whole, but only as individual pages.
  32691.  
  32692. When you issue a query `SHOW TABLE STATUS FROM ... LIKE ...' to ask for
  32693. available free space in the tablespace, InnoDB will report you the
  32694. space which is certainly usable in totally free extents of the
  32695. tablespace. InnoDB always reserves some extents for clean-up and other
  32696. internal purposes; these reserved extents are not included in the free
  32697. space.
  32698.  
  32699. When you delete data from a table, InnoDB will contract the
  32700. corresponding B-tree indexes. It depends on the pattern of deletes if
  32701. that frees individual pages or extents to the tablespace, so that the
  32702. freed space is available for other users. Dropping a table or deleting
  32703. all rows from it is guaranteed to release the space to other users, but
  32704. remember that deleted rows can be physically removed only in a purge
  32705. operation after they are no longer needed in transaction rollback or
  32706. consistent read.
  32707.  
  32708. 
  32709. File: mysql.info,  Node: InnoDB File Defragmenting,  Prev: InnoDB File space,  Up: File space management
  32710.  
  32711. Defragmenting a table
  32712. .....................
  32713.  
  32714. If there are random insertions or deletions in the indexes of a table,
  32715. the indexes may become fragmented. By fragmentation we mean that the
  32716. physical ordering of the index pages on the disk is not close to the
  32717. alphabetical ordering of the records on the pages, or that there are
  32718. many unused pages in the 64-page blocks which were allocated to the
  32719. index.
  32720.  
  32721. It can speed up index scans if you periodically use `mysqldump' to dump
  32722. the table to a text file, drop the table, and reload it from the dump.
  32723. Another way to do the defragmenting is to `ALTER' the table type to
  32724. `MyISAM' and back to `InnoDB' again.  Note that a `MyISAM' table must
  32725. fit in a single file on your operating system.
  32726.  
  32727. If the insertions to and index are always ascending and records are
  32728. deleted only from the end, then the the file space management algorithm
  32729. of InnoDB guarantees that fragmentation in the index will not occur.
  32730.  
  32731. 
  32732. File: mysql.info,  Node: Error handling,  Next: InnoDB restrictions,  Prev: File space management,  Up: InnoDB
  32733.  
  32734. Error handling
  32735. --------------
  32736.  
  32737. The error handling in InnoDB is not always the same as specified in the
  32738. ANSI SQL standards. According to the ANSI standard, any error during an
  32739. SQL statement should cause the rollback of that statement. InnoDB
  32740. sometimes rolls back only part of the statement.  The following list
  32741. specifies the error handling of InnoDB.
  32742.  
  32743.    * If you run out of file space in the tablespace, you will get the
  32744.      MySQL `'Table is full'' error and InnoDB rolls back the SQL
  32745.      statement.
  32746.  
  32747.    * A transaction deadlock or a timeout in a lock wait will give
  32748.      `'Table handler error 1000000'' and InnoDB rolls back the SQL
  32749.      statement.
  32750.  
  32751.    * A duplicate key error only rolls back the insert of that
  32752.      particular row, even in a statement like `INSERT INTO ... SELECT
  32753.      ...'.  This will probably change so that the SQL statement will be
  32754.      rolled back if you have not specified the `IGNORE' option in your
  32755.      statement.
  32756.  
  32757.    * A 'row too long' error rolls back the SQL statement.
  32758.  
  32759.    * Other errors are mostly detected by the MySQL layer of code, and
  32760.      they roll back the corresponding SQL statement.
  32761.  
  32762. 
  32763. File: mysql.info,  Node: InnoDB restrictions,  Next: InnoDB contact information,  Prev: Error handling,  Up: InnoDB
  32764.  
  32765. Some restrictions on InnoDB tables
  32766. ----------------------------------
  32767.  
  32768.    * `SHOW TABLE STATUS' does not give accurate statistics on InnoDB
  32769.      tables, except for the physical size reserved by the table.  The
  32770.      row count is only a rough estimate used in SQL optimization.
  32771.  
  32772.    * If you try to create an unique index on a prefix of a column you
  32773.      will get an error:
  32774.  
  32775.           CREATE TABLE T (A CHAR(20), B INT, UNIQUE (A(5))) TYPE = InnoDB;
  32776.  
  32777.      If you create a non unique index on a prefix of a column, InnoDB
  32778.      will create an index over the whole column.
  32779.  
  32780.    * `INSERT DELAYED' is not supported for InnoDB tables.
  32781.  
  32782.    * The MySQL `LOCK TABLES' operation does not know of InnoDB row
  32783.      level locks set in already completed SQL statements: this means
  32784.      that you can get a table lock on a table even if there still exist
  32785.      transactions of other users which have row level locks on the same
  32786.      table. Thus your operations on the table may have to wait if they
  32787.      collide with these locks of other users. Also a deadlock is
  32788.      possible. However, this does not endanger transaction integrity,
  32789.      because the row level locks set by InnoDB will always take care of
  32790.      the integrity.  Also, a table lock prevents other transactions
  32791.      from acquiring more row level locks (in a conflicting lock mode)
  32792.      on the table.
  32793.  
  32794.    * You cannot have a key on a `BLOB' or `TEXT' column.
  32795.  
  32796.    * A table cannot contain more than 1000 columns.
  32797.  
  32798.    * `DELETE FROM TABLE' does not regenerate the table but instead
  32799.      deletes all rows, one by one, which is not that fast. In future
  32800.      versions of MySQL you can use `TRUNCATE' which is fast.
  32801.  
  32802.    * Before dropping a database with InnoDB tables one has to drop the
  32803.      individual InnoDB tables first.
  32804.  
  32805.    * The default database page size in InnoDB is 16 kB. By recompiling
  32806.      the code one can set it from 8 kB to 64 kB.  The maximun row
  32807.      length is slightly less than half of a database page in versions
  32808.      <= 3.23.40 of InnoDB. Starting from source release 3.23.41 BLOB and
  32809.      TEXT columns are allowed to be < 4 GB, the total row length must
  32810.      also be < 4 GB. InnoDB does not store fields whose size is <= 30
  32811.      bytes on separate pages. After InnoDB has modified the row by
  32812.      storing long fields on separate pages, the remaining length of the
  32813.      row must be slightly less than half a database page.
  32814.  
  32815.    * The maximum data or log file size is 2 GB or 4 GB depending on how
  32816.      large files your operating system supports. Support for > 4 GB
  32817.      files will be added to InnoDB in a future version.
  32818.  
  32819.    * The maximum tablespace size is 4 billion database pages. This is
  32820.      also the maximum size for a table. The minimum tablespace size is
  32821.      10 MB.
  32822.  
  32823. 
  32824. File: mysql.info,  Node: InnoDB contact information,  Prev: InnoDB restrictions,  Up: InnoDB
  32825.  
  32826. InnoDB contact information
  32827. --------------------------
  32828.  
  32829. Contact information of Innobase Oy, producer of the InnoDB engine.
  32830. Website: `http://www.innodb.com'. Email: <Heikki.Tuuri@innodb.com>
  32831.  
  32832.      phone: 358-9-6969 3250 (office) 358-40-5617367 (mobile)
  32833.      InnoDB Oy Inc.
  32834.      World Trade Center Helsinki
  32835.      Aleksanterinkatu 17
  32836.      P.O.Box 800
  32837.      00101 Helsinki
  32838.      Finland
  32839.  
  32840. 
  32841. File: mysql.info,  Node: Clients,  Next: Extending MySQL,  Prev: Table types,  Up: Top
  32842.  
  32843. MySQL APIs
  32844. **********
  32845.  
  32846. * Menu:
  32847.  
  32848. * PHP::                         MySQL PHP API
  32849. * Perl::                        MySQL Perl API
  32850. * ODBC::                        MySQL ODBC Support
  32851. * C::                           MySQL C API
  32852. * Cplusplus::                   MySQL C++ APIs
  32853. * Java::                        MySQL Java connectivity (JDBC)
  32854. * Python::                      MySQL Python APIs
  32855. * Tcl::                         MySQL Tcl APIs
  32856. * Eiffel::                      MySQL Eiffel wrapper
  32857.  
  32858. This chapter describes the APIs available for MySQL, where to get them,
  32859. and how to use them.  The C API is the most extensively covered, as it
  32860. was developed by the MySQL team, and is the basis for most of the other
  32861. APIs.
  32862.  
  32863. 
  32864. File: mysql.info,  Node: PHP,  Next: Perl,  Prev: Clients,  Up: Clients
  32865.  
  32866. MySQL PHP API
  32867. =============
  32868.  
  32869. PHP is a server-side, HTML-embedded scripting language that may be used
  32870. to create dynamic Web pages.  It contains support for accessing several
  32871. databases, including MySQL.  PHP may be run as a separate program or
  32872. compiled as a module for use with the Apache Web server.
  32873.  
  32874. The distribution and documentation are available at the PHP web site
  32875. (http://www.php.net/).
  32876.  
  32877. * Menu:
  32878.  
  32879. * PHP problems::                Common problems with MySQL and PHP
  32880.  
  32881. 
  32882. File: mysql.info,  Node: PHP problems,  Prev: PHP,  Up: PHP
  32883.  
  32884. Common Problems with MySQL and PHP
  32885. ----------------------------------
  32886.  
  32887.    * Error: "Maximum Execution Time Exceeded" This is a PHP limit;  Go
  32888.      into the `php3.ini' file and set the maximum execution time up
  32889.      from 30 seconds to something higher, as needed.  It is also not a
  32890.      bad idea to double the ram allowed per script to 16MB instead of 8
  32891.      MB.
  32892.  
  32893.    * Error: "Fatal error: Call to unsupported or undefined function
  32894.      mysql_connect() in .."  This means that your PHP version isn't
  32895.      compiled with MySQL support.  You can either compile a dynamic
  32896.      MySQL module and load it into PHP or recompile PHP with built-in
  32897.      MySQL support.  This is described in detail in the PHP manual.
  32898.  
  32899.    * Error: "undefined reference to `uncompress'" This means that the
  32900.      client library is compiled with support for a compressed
  32901.      client/server protocol. The fix is to add `-lz' last when linking
  32902.      with `-lmysqlclient'.
  32903.  
  32904. 
  32905. File: mysql.info,  Node: Perl,  Next: ODBC,  Prev: PHP,  Up: Clients
  32906.  
  32907. MySQL Perl API
  32908. ==============
  32909.  
  32910. This section documents the Perl `DBI' interface.  The former interface
  32911. was called `mysqlperl'.  `DBI'/`DBD' now is the recommended Perl
  32912. interface, so `mysqlperl' is obsolete and is not documented here.
  32913.  
  32914. * Menu:
  32915.  
  32916. * DBI with DBD::                `DBI' with `DBD::mysql'
  32917. * Perl DBI Class::              The `DBI' interface
  32918. * DBI-info::                    More `DBI'/`DBD' information
  32919.  
  32920. 
  32921. File: mysql.info,  Node: DBI with DBD,  Next: Perl DBI Class,  Prev: Perl,  Up: Perl
  32922.  
  32923. `DBI' with `DBD::mysql'
  32924. -----------------------
  32925.  
  32926. `DBI' is a generic interface for many databases. That means that you
  32927. can write a script that works with many different database engines
  32928. without change. You need a DataBase Driver (DBD) defined for each
  32929. database type. For MySQL, this driver is called `DBD::mysql'.
  32930.  
  32931. For more information on the Perl5 DBI, please visit the `DBI' Web page
  32932. and read the documentation:
  32933.      `http://www.symbolstone.org/technology/perl/DBI/index.html'
  32934. For more information on Object Oriented Programming (OOP) as defined in
  32935. Perl5, see the Perl OOP page:
  32936.      `http://language.perl.com/info/documentation.html'
  32937.  
  32938. Note that if you want to use transactions with Perl, you need to have
  32939. `Msql-Mysql-modules' version 1.2216 or newer.
  32940.  
  32941. Installation instructions for MySQL Perl support are given in *Note
  32942. Perl support::.
  32943.  
  32944. 
  32945. File: mysql.info,  Node: Perl DBI Class,  Next: DBI-info,  Prev: DBI with DBD,  Up: Perl
  32946.  
  32947. The `DBI' Interface
  32948. -------------------
  32949.  
  32950. *Portable DBI Methods*
  32951.  
  32952. `connect'              Establishes a connection to a database server.
  32953. `disconnect'           Disconnects from the database server.
  32954. `prepare'              Prepares a SQL statement for execution.
  32955. `execute'              Executes prepared statements.
  32956. `do'                   Prepares and executes a SQL statement.
  32957. `quote'                Quotes string or `BLOB' values to be inserted.
  32958. `fetchrow_array'       Fetches the next row as an array of fields.
  32959. `fetchrow_arrayref'    Fetches next row as a reference array of fields.
  32960. `fetchrow_hashref'     Fetches next row as a reference to a hashtable.
  32961. `fetchall_arrayref'    Fetches all data as an array of arrays.
  32962. `finish'               Finishes a statement and lets the system free
  32963.                        resources.
  32964. `rows'                 Returns the number of rows affected.
  32965. `data_sources'         Returns an array of databases available on
  32966.                        localhost.
  32967. `ChopBlanks'           Controls whether `fetchrow_*' methods trim spaces.
  32968. `NUM_OF_PARAMS'        The number of placeholders in the prepared
  32969.                        statement.
  32970. `NULLABLE'             Which columns can be `NULL'.
  32971. `trace'                Perform tracing for debugging.
  32972.  
  32973. *MySQL-specific Methods*
  32974.  
  32975. `insertid'             The latest `AUTO_INCREMENT' value.
  32976. `is_blob'              Which columns are `BLOB' values.
  32977. `is_key'               Which columns are keys.
  32978. `is_num'               Which columns are numeric.
  32979. `is_pri_key'           Which columns are primary keys.
  32980. `is_not_null'          Which columns CANNOT be `NULL'. See `NULLABLE'.
  32981. `length'               Maximum possible column sizes.
  32982. `max_length'           Maximum column sizes actually present in result.
  32983. `NAME'                 Column names.
  32984. `NUM_OF_FIELDS'        Number of fields returned.
  32985. `table'                Table names in returned set.
  32986. `type'                 All column types.
  32987.  
  32988. The Perl methods are described in more detail in the following sections.
  32989. Variables used for method return values have these meanings:
  32990.  
  32991. `$dbh'
  32992.      Database handle
  32993.  
  32994. `$sth'
  32995.      Statement handle
  32996.  
  32997. `$rc'
  32998.      Return code (often a status)
  32999.  
  33000. `$rv'
  33001.      Return value (often a row count)
  33002.  
  33003. *Portable DBI Methods*
  33004.  
  33005. `connect($data_source, $username, $password)'
  33006.      Use the `connect' method to make a database connection to the data
  33007.      source. The `$data_source' value should begin with
  33008.      `DBI:driver_name:'.  Example uses of `connect' with the
  33009.      `DBD::mysql' driver:
  33010.           $dbh = DBI->connect("DBI:mysql:$database", $user, $password);
  33011.           $dbh = DBI->connect("DBI:mysql:$database:$hostname",
  33012.                               $user, $password);
  33013.           $dbh = DBI->connect("DBI:mysql:$database:$hostname:$port",
  33014.                               $user, $password);
  33015.      If the user name and/or password are undefined, `DBI' uses the
  33016.      values of the `DBI_USER' and `DBI_PASS' environment variables,
  33017.      respectively. If you don't specify a hostname, it defaults to
  33018.      `'localhost''. If you don't specify a port number, it defaults to
  33019.      the default MySQL port (3306).
  33020.  
  33021.      As of `Msql-Mysql-modules' Version 1.2009, the `$data_source'
  33022.      value allows certain modifiers:
  33023.  
  33024.     `mysql_read_default_file=file_name'
  33025.           Read `filename' as an option file.  For information on option
  33026.           files, see *Note Option files::.
  33027.  
  33028.     `mysql_read_default_group=group_name'
  33029.           The default group when reading an option file is normally the
  33030.           `[client]' group.  By specifying the
  33031.           `mysql_read_default_group' option, the default group becomes
  33032.           the `[group_name]' group.
  33033.  
  33034.     `mysql_compression=1'
  33035.           Use compressed communication between the client and server
  33036.           (MySQL Version 3.22.3 or later).
  33037.  
  33038.     `mysql_socket=/path/to/socket'
  33039.           Specify the pathname of the Unix socket that is used to
  33040.           connect to the server (MySQL Version 3.21.15 or later).
  33041.  
  33042.      Multiple modifiers may be given; each must be preceded by a
  33043.      semicolon.
  33044.  
  33045.      For example, if you want to avoid hardcoding the user name and
  33046.      password into a `DBI' script, you can take them from the user's
  33047.      `~/.my.cnf' option file instead by writing your `connect' call
  33048.      like this:
  33049.  
  33050.           $dbh = DBI->connect("DBI:mysql:$database"
  33051.                           . ";mysql_read_default_file=$ENV{HOME}/.my.cnf",
  33052.                           $user, $password);
  33053.  
  33054.      This call will read options defined for the `[client]' group in the
  33055.      option file.  If you wanted to do the same thing but use options
  33056.      specified for the `[perl]' group as well, you could use this:
  33057.  
  33058.           $dbh = DBI->connect("DBI:mysql:$database"
  33059.                           . ";mysql_read_default_file=$ENV{HOME}/.my.cnf"
  33060.                           . ";mysql_read_default_group=perl",
  33061.                           $user, $password);
  33062.  
  33063. `disconnect'
  33064.      The `disconnect' method disconnects the database handle from the
  33065.      database.  This is typically called right before you exit from the
  33066.      program.  Example:
  33067.           $rc = $dbh->disconnect;
  33068.  
  33069. `prepare($statement)'
  33070.      Prepares a SQL statement for execution by the database engine and
  33071.      returns a statement handle `($sth)', which you can use to invoke
  33072.      the `execute' method.  Typically you handle `SELECT' statements
  33073.      (and `SELECT'-like statements such as `SHOW', `DESCRIBE', and
  33074.      `EXPLAIN') by means of `prepare' and `execute'.  Example:
  33075.           $sth = $dbh->prepare($statement)
  33076.               or die "Can't prepare $statement: $dbh->errstr\n";
  33077.  
  33078. `execute'
  33079.      The `execute' method executes a prepared statement. For
  33080.      non-`SELECT' statements, `execute' returns the number of rows
  33081.      affected.  If no rows are affected, `execute' returns `"0E0"',
  33082.      which Perl treats as zero but regards as true. If an error occurs,
  33083.      `execute' returns `undef'. For `SELECT' statements, `execute' only
  33084.      starts the SQL query in the database; you need to use one of the
  33085.      `fetch_*' methods described below to retrieve the data.  Example:
  33086.           $rv = $sth->execute
  33087.                     or die "can't execute the query: $sth->errstr;
  33088.  
  33089. `do($statement)'
  33090.      The `do' method prepares and executes a SQL statement and returns
  33091.      the number of rows affected.  If no rows are affected, `do' returns
  33092.      `"0E0"', which Perl treats as zero but regards as true.  This
  33093.      method is generally used for non-`SELECT' statements that cannot
  33094.      be prepared in advance (due to driver limitations) or that do not
  33095.      need to be executed more than once (inserts, deletes, etc.).
  33096.      Example:
  33097.           $rv = $dbh->do($statement)
  33098.                   or die "Can't execute $statement: $dbh- >errstr\n";
  33099.  
  33100.      Generally the 'do' statement is MUCH faster (and is preferable)
  33101.      than prepare/execute for statements that don't contain parameters.
  33102.  
  33103. `quote($string)'
  33104.      The `quote' method is used to "escape" any special characters
  33105.      contained in the string and to add the required outer quotation
  33106.      marks.  Example:
  33107.           $sql = $dbh->quote($string)
  33108.  
  33109. `fetchrow_array'
  33110.      This method fetches the next row of data and returns it as an
  33111.      array of field values.  Example:
  33112.           while(@row = $sth->fetchrow_array) {
  33113.                   print qw($row[0]\t$row[1]\t$row[2]\n);
  33114.           }
  33115.  
  33116. `fetchrow_arrayref'
  33117.      This method fetches the next row of data and returns it as a
  33118.      reference to an array of field values. Example:
  33119.           while($row_ref = $sth->fetchrow_arrayref) {
  33120.                   print qw($row_ref->[0]\t$row_ref->[1]\t$row_ref->[2]\n);
  33121.           }
  33122.  
  33123. `fetchrow_hashref'
  33124.      This method fetches a row of data and returns a reference to a hash
  33125.      table containing field name/value pairs. This method is not nearly
  33126.      as efficient as using array references as demonstrated above.
  33127.      Example:
  33128.           while($hash_ref = $sth->fetchrow_hashref) {
  33129.                   print qw($hash_ref->{firstname}\t$hash_ref->{lastname}\t\
  33130.                           $hash_ref- > title}\n);
  33131.           }
  33132.  
  33133. `fetchall_arrayref'
  33134.      This method is used to get all the data (rows) to be returned from
  33135.      the SQL statement. It returns a reference to an array of
  33136.      references to arrays for each row. You access or print the data by
  33137.      using a nested loop. Example:
  33138.           my $table = $sth->fetchall_arrayref
  33139.                           or die "$sth->errstr\n";
  33140.           my($i, $j);
  33141.           for $i ( 0 .. $#{$table} ) {
  33142.                   for $j ( 0 .. $#{$table->[$i]} ) {
  33143.                           print "$table->[$i][$j]\t";
  33144.                   }
  33145.                   print "\n";
  33146.           }
  33147.  
  33148. `finish'
  33149.      Indicates that no more data will be fetched from this statement
  33150.      handle. You call this method to free up the statement handle and
  33151.      any system resources associated with it.  Example:
  33152.           $rc = $sth->finish;
  33153.  
  33154. `rows'
  33155.      Returns the number of rows changed (updated, deleted, etc.) by the
  33156.      last command.  This is usually used after a non-`SELECT' `execute'
  33157.      statement.  Example:
  33158.           $rv = $sth->rows;
  33159.  
  33160. `NULLABLE'
  33161.      Returns a reference to an array of boolean values; for each
  33162.      element of the array, a value of TRUE indicates that this column
  33163.      may contain `NULL' values.  Example:
  33164.           $null_possible = $sth->{NULLABLE};
  33165.  
  33166. `NUM_OF_FIELDS'
  33167.      This attribute indicates the number of fields returned by a
  33168.      `SELECT' or `SHOW FIELDS' statement.  You may use this for
  33169.      checking whether a statement returned a result: A zero value
  33170.      indicates a non-`SELECT' statement like `INSERT', `DELETE', or
  33171.      `UPDATE'.  Example:
  33172.           $nr_of_fields = $sth->{NUM_OF_FIELDS};
  33173.  
  33174. `data_sources($driver_name)'
  33175.      This method returns an array containing names of databases
  33176.      available to the MySQL server on the host `'localhost''.  Example:
  33177.           @dbs = DBI->data_sources("mysql");
  33178.  
  33179. `ChopBlanks'
  33180.      This attribute determines whether the `fetchrow_*' methods will
  33181.      chop leading and trailing blanks from the returned values.
  33182.      Example:
  33183.           $sth->{'ChopBlanks'} =1;
  33184.  
  33185. `trace($trace_level)'
  33186. `trace($trace_level, $trace_filename)'
  33187.      The `trace' method enables or disables tracing.  When invoked as a
  33188.      `DBI' class method, it affects tracing for all handles.  When
  33189.      invoked as a database or statement handle method, it affects
  33190.      tracing for the given handle (and any future children of the
  33191.      handle).  Setting `$trace_level' to 2 provides detailed trace
  33192.      information.  Setting `$trace_level' to 0 disables tracing.  Trace
  33193.      output goes to the standard error output by default.  If
  33194.      `$trace_filename' is specified, the file is opened in append mode
  33195.      and output for _all_ traced handles is written to that file.
  33196.      Example:
  33197.           DBI->trace(2);                # trace everything
  33198.           DBI->trace(2,"/tmp/dbi.out"); # trace everything to
  33199.                                         # /tmp/dbi.out
  33200.           $dth->trace(2);               # trace this database handle
  33201.           $sth->trace(2);               # trace this statement handle
  33202.  
  33203.      You can also enable `DBI' tracing by setting the `DBI_TRACE'
  33204.      environment variable.  Setting it to a numeric value is equivalent
  33205.      to calling `DBI->(value)'.  Setting it to a pathname is equivalent
  33206.      to calling `DBI->(2,value)'.
  33207.  
  33208. *MySQL-specific Methods*
  33209.  
  33210. The methods shown below are MySQL-specific and not part of the `DBI'
  33211. standard.  Several of them are now deprecated: `is_blob', `is_key',
  33212. `is_num', `is_pri_key', `is_not_null', `length', `max_length', and
  33213. `table'.  Where `DBI'-standard alternatives exist, they are noted below:
  33214.  
  33215. `insertid'
  33216.      If you use the `AUTO_INCREMENT' feature of MySQL, the new
  33217.      auto-incremented values will be stored here.  Example:
  33218.           $new_id = $sth->{insertid};
  33219.  
  33220.      As an alternative, you can use `$dbh->{'mysql_insertid'}'.
  33221.  
  33222. `is_blob'
  33223.      Returns a reference to an array of boolean values; for each
  33224.      element of the array, a value of TRUE indicates that the
  33225.      respective column is a `BLOB'.  Example:
  33226.           $keys = $sth->{is_blob};
  33227.  
  33228. `is_key'
  33229.      Returns a reference to an array of boolean values; for each
  33230.      element of the array, a value of TRUE indicates that the
  33231.      respective column is a key.  Example:
  33232.           $keys = $sth->{is_key};
  33233.  
  33234. `is_num'
  33235.      Returns a reference to an array of boolean values; for each
  33236.      element of the array, a value of TRUE indicates that the
  33237.      respective column contains numeric values.  Example:
  33238.           $nums = $sth->{is_num};
  33239.  
  33240. `is_pri_key'
  33241.      Returns a reference to an array of boolean values; for each
  33242.      element of the array, a value of TRUE indicates that the
  33243.      respective column is a primary key.  Example:
  33244.           $pri_keys = $sth->{is_pri_key};
  33245.  
  33246. `is_not_null'
  33247.      Returns a reference to an array of boolean values; for each
  33248.      element of the array, a value of FALSE indicates that this column
  33249.      may contain `NULL' values.  Example:
  33250.           $not_nulls = $sth->{is_not_null};
  33251.  
  33252.      `is_not_null' is deprecated; it is preferable to use the
  33253.      `NULLABLE' attribute (described above), because that is a DBI
  33254.      standard.
  33255.  
  33256. `length'
  33257. `max_length'
  33258.      Each of these methods returns a reference to an array of column
  33259.      sizes.  The `length' array indicates the maximum possible sizes
  33260.      that each column may be (as declared in the table description).
  33261.      The `max_length' array indicates the maximum sizes actually
  33262.      present in the result table.  Example:
  33263.  
  33264.           $lengths = $sth->{length};
  33265.           $max_lengths = $sth->{max_length};
  33266.  
  33267. `NAME'
  33268.      Returns a reference to an array of column names.  Example:
  33269.           $names = $sth->{NAME};
  33270.  
  33271. `table'
  33272.      Returns a reference to an array of table names.  Example:
  33273.           $tables = $sth->{table};
  33274.  
  33275. `type'
  33276.      Returns a reference to an array of column types.  Example:
  33277.           $types = $sth->{type};
  33278.  
  33279. 
  33280. File: mysql.info,  Node: DBI-info,  Prev: Perl DBI Class,  Up: Perl
  33281.  
  33282. More `DBI'/`DBD' Information
  33283. ----------------------------
  33284.  
  33285. You can use the `perldoc' command to get more information about `DBI'.
  33286.  
  33287.      perldoc DBI
  33288.      perldoc DBI::FAQ
  33289.      perldoc DBD::mysql
  33290.  
  33291. You can also use the `pod2man', `pod2html', etc., tools to translate to
  33292. other formats.
  33293.  
  33294. You can find the latest `DBI' information at the `DBI' Web page:
  33295.      `http://www.symbolstone.org/technology/perl/DBI/index.html'
  33296.  
  33297. 
  33298. File: mysql.info,  Node: ODBC,  Next: C,  Prev: Perl,  Up: Clients
  33299.  
  33300. MySQL ODBC Support
  33301. ==================
  33302.  
  33303. * Menu:
  33304.  
  33305. * Installing MyODBC::           How to install MyODBC
  33306. * ODBC administrator::          How to fill in the various fields in the ODBC administrator program
  33307. * MyODBC connect parameters::   Connect parameters for MyODBC
  33308. * ODBC Problems::               How to report problems with MySQL ODBC
  33309. * MyODBC clients::              Programs known to work with *MyODBC*
  33310. * ODBC and last_insert_id::     How to get the value of an `AUTO_INCREMENT' column in ODBC
  33311. * MyODBC bug report::           Reporting problems with MyODBC
  33312.  
  33313. MySQL provides support for ODBC by means of the *MyODBC* program.  This
  33314. chapter will teach you how to install *MyODBC*, and how to use it.
  33315. Here, you will also find a list of common programs that are known to
  33316. work with *MyODBC*.
  33317.  
  33318. 
  33319. File: mysql.info,  Node: Installing MyODBC,  Next: ODBC administrator,  Prev: ODBC,  Up: ODBC
  33320.  
  33321. How To Install MyODBC
  33322. ---------------------
  33323.  
  33324. *MyODBC* is a 32-bit ODBC (2.50) level 0 (with level 1 and level 2
  33325. features) driver for connecting an ODBC-aware application to MySQL.
  33326. *MyODBC* works on Windows95, Windows98, NT, and on most Unix platforms.
  33327.  
  33328. *MyODBC* is in public domain, and you can find the newest version at
  33329. `http://www.mysql.com/downloads/api-myodbc.html'.
  33330.  
  33331. If you have problem with *MyODBC* and your program also works with
  33332. OLEDB, you should try the OLEDB driver that you can find in the Contrib
  33333. section.  *Note Contrib::.
  33334.  
  33335. Normally you only need to install *MyODBC* on Windows machines.  You
  33336. only need *MyODBC* for Unix if you have a program like ColdFusion that
  33337. is running on the Unix machine and uses ODBC to connect to the
  33338. databases.
  33339.  
  33340. If you want to install *MyODBC* on a Unix box, you will also need an
  33341. *ODBC* manager.  *MyODBC* is known to work with most of the Unix ODBC
  33342. managers.  You can find a list at these in the *ODBC*-related links
  33343. section on the MySQL useful links page.  *Note Useful Links::.
  33344.  
  33345. To install *MyODBC* on Windows, you should download the appropriate
  33346. *MyODBC* .zip file (for Windows or NT/Win2000), unpack it with
  33347. `WINZIP', or some similar program, and execute the `SETUP.EXE' file.
  33348.  
  33349. On Windows/NT you may get the following error when trying to install
  33350. *MyODBC*:
  33351.  
  33352.      An error occurred while copying C:\WINDOWS\SYSTEM\MFC30.DLL. Restart
  33353.      Windows and try installing again (before running any applications which
  33354.      use ODBC)
  33355.  
  33356. The problem in this case is that some other program is using ODBC and
  33357. because of how Windows is designed, you may not in this case be able to
  33358. install a new ODBC drivers with Microsoft's ODBC setup program. In most
  33359. cases you can continue by just pressing `Ignore' to copy the rest of
  33360. the MyODBC files and the final installation should still work.  If this
  33361. doesn't work, the solution is to reboot your computer in "safe mode"
  33362. (Choose this by pressing F8 just before your machine starts Windows
  33363. during rebooting), install *MyODBC*, and reboot to normal mode.
  33364.  
  33365.    * To make a connection to a Unix box from a Windows box, with an ODBC
  33366.      application (one that doesn't support MySQL natively), you must
  33367.      first install *MyODBC* on the Windows machine.
  33368.  
  33369.    * The user and Windows machine must have the access privileges to the
  33370.      MySQL server on the Unix machine.  This is set up with the `GRANT'
  33371.      command. *Note `GRANT': GRANT.
  33372.  
  33373.    * You must create an ODBC DSN entry as follows:
  33374.  
  33375.         - Open the Control Panel on the Windows machine.
  33376.  
  33377.         - Double-click the ODBC Data Sources 32 bits icon.
  33378.  
  33379.         - Click the tab User DSN.
  33380.  
  33381.         - Click the button Add.
  33382.  
  33383.         - Select MySQL in the screen Create New Data Source and click
  33384.           the Finish button.
  33385.  
  33386.         - The MySQL Driver default configuration screen is shown.
  33387.           *Note ODBC administrator::.
  33388.  
  33389.    * Now start your application and select the ODBC driver with the DSN
  33390.      you specified in the ODBC administrator.
  33391.  
  33392. Notice that there are other configuration options on the screen of
  33393. MySQL (trace, don't prompt on connect, etc) that you can try if you run
  33394. into problems.
  33395.  
  33396. 
  33397. File: mysql.info,  Node: ODBC administrator,  Next: MyODBC connect parameters,  Prev: Installing MyODBC,  Up: ODBC
  33398.  
  33399. How to Fill in the Various Fields in the ODBC Administrator Program
  33400. -------------------------------------------------------------------
  33401.  
  33402. There are three possibilities for specifying the server name on
  33403. Windows95:
  33404.  
  33405.    * Use the IP address of the server.
  33406.  
  33407.    * Add a file `\windows\lmhosts' with the following information:
  33408.  
  33409.           ip hostname
  33410.  
  33411.      For example:
  33412.  
  33413.           194.216.84.21 my_hostname
  33414.  
  33415.    * Configure the PC to use DNS.
  33416.  
  33417. Example of how to fill in the `ODBC setup':
  33418.      Windows DSN name:   test
  33419.      Description:        This is my test database
  33420.      MySql Database:     test
  33421.      Server:             194.216.84.21
  33422.      User:               monty
  33423.      Password:           my_password
  33424.      Port:
  33425.  
  33426. The value for the `Windows DSN name' field is any name that is unique
  33427. in your Windows ODBC setup.
  33428.  
  33429. You don't have to specify values for the `Server', `User', `Password',
  33430. or `Port' fields in the ODBC setup screen.  However, if you do, the
  33431. values will be used as the defaults later when you attempt to make a
  33432. connection.  You have the option of changing the values at that time.
  33433.  
  33434. If the port number is not given, the default port (3306) is used.
  33435.  
  33436. If you specify the option `Read options from C:\my.cnf', the groups
  33437. `client' and `odbc' will be read from the `C:\my.cnf' file.  You can
  33438. use all options that are usable by `mysql_options()'.  *Note
  33439. `mysql_options': mysql_options.
  33440.  
  33441. 
  33442. File: mysql.info,  Node: MyODBC connect parameters,  Next: ODBC Problems,  Prev: ODBC administrator,  Up: ODBC
  33443.  
  33444. Connect parameters for MyODBC
  33445. -----------------------------
  33446.  
  33447. One can specify the following parameters for *MyODBC* on the
  33448. `[Servername]' section of an `ODBC.INI' file or through  the
  33449. `InConnectionString' argument in the `SQLDriverConnect()' call.
  33450.  
  33451. *Parameter*    *Default       *Comment*
  33452.                value*         
  33453. user           ODBC (on       The username used to connect to MySQL.
  33454.                Windows)       
  33455. server         localhost      The hostname of the MySQL server.
  33456. database                      The default database
  33457. option         0              A integer by which you can specify how
  33458.                               *MyODBC* should work. See below.
  33459. port           3306           The TCP/IP port to use if `server' is not
  33460.                               `localhost'.
  33461. stmt                          A statement that will be executed when
  33462.                               connection to `MySQL'.
  33463. password                      The password for the `server' `user'
  33464.                               combination.
  33465. socket                        The socket or Windows pipe to connect to.
  33466.  
  33467. The option argument is used to tell *MyODBC* that the client isn't 100%
  33468. ODBC compliant. On Windows, one normally sets the option flag by
  33469. toggling the different options on the connection screen but one can also
  33470. set this in the opton argument. The following options are listed in the
  33471. same order as they appear in the *MyODBC* connect screen:
  33472.  
  33473. *Bit*   *Meaning*
  33474. 1       The client can't handle that *MyODBC* returns the real width of
  33475.         a column.
  33476. 2       The client can't handle that MySQL returns the true value of
  33477.         affected rows.  If this flag is set then MySQL returns 'found
  33478.         rows' instead.  One must have MySQL 3.21.14 or newer to get this
  33479.         to work.
  33480. 4       Make a debug log in c:\myodbc.log.  This is the same as putting
  33481.         `MYSQL_DEBUG=d:t:O,c::\myodbc.log' in `AUTOEXEC.BAT'
  33482. 8       Don't set any packet limit for results and parameters.
  33483. 16      Don't prompt for questions even if driver would like to prompt
  33484. 32      Simulate a ODBC 1.0 driver in some context.
  33485. 64      Ignore use of database name in 'database.table.column'.
  33486. 128     Force use of ODBC manager cursors (experimental).
  33487. 256     Disable the use of extended fetch (experimental)
  33488. 512     Pad CHAR fields to full column length.
  33489. 1024    SQLDescribeCol() will return fully qualifed column names
  33490. 2048    Use the compressed server/client protocol
  33491. 4096    Tell server to ignore space after function name and before `'(''
  33492.         (needed by PowerBuilder).  This will make all function names
  33493.         keywords!
  33494. 8192    Connect with named pipes to a `mysqld' server running on NT.
  33495. 16384   Change LONGLONG columns to INT columns (Some applications can't
  33496.         handle LONGLONG).
  33497. 32768   Return 'user' as Table_qualifier and Table_owner from SQLTables
  33498.         (experimental)
  33499. 65536   Read parameters from the `client' and `odbc' groups from `my.cnf'
  33500. 131072  Add some extra safety checks (should not bee needed but...)
  33501.  
  33502. If you want to have many options, you should add the above flags!  For
  33503. example setting option to 12 (4+8) gives you debugging without package
  33504. limits!
  33505.  
  33506. The default `MYODBC.DLL' is compiled for optimal performance.  If you
  33507. want to to debug *MyODBC* (for example to enable tracing), you should
  33508. instead use `MYODBCD.DLL'.  To install this file, copy `MYODBCD.DLL'
  33509. over the installed `MYODBC.DLL' file.
  33510.  
  33511. 
  33512. File: mysql.info,  Node: ODBC Problems,  Next: MyODBC clients,  Prev: MyODBC connect parameters,  Up: ODBC
  33513.  
  33514. How to Report Problems with MyODBC
  33515. ----------------------------------
  33516.  
  33517. *MyODBC* has been tested with Access, Admndemo.exe, C++-Builder,
  33518. Borland Builder 4, Centura Team Developer (formerly Gupta SQL/Windows),
  33519. ColdFusion (on Solaris and NT with svc pack 5), Crystal Reports,
  33520. DataJunction, Delphi, ERwin, Excel, iHTML, FileMaker Pro, FoxPro, Notes
  33521. 4.5/4.6, SBSS, Perl DBD-ODBC, Paradox, Powerbuilder, Powerdesigner 32
  33522. bit, VC++, and Visual Basic.
  33523.  
  33524. If you know of any other applications that work with *MyODBC*, please
  33525. send mail to <myodbc@lists.mysql.com> about this!
  33526.  
  33527. With some programs you may get an error like: `Another user has
  33528. modifies the record that you have modified'. In most cases this can be
  33529. solved by doing one of the following things:
  33530.  
  33531.    * Add a primary key for the table if there isn't one already.
  33532.  
  33533.    * Add a timestamp column if there isn't one already.
  33534.  
  33535.    * Only use double float fields. Some programs may fail when they
  33536.      compare single floats.
  33537.  
  33538. If the above doesn't help, you should do a `MyODBC' trace file and try
  33539. to figure out why things go wrong.
  33540.  
  33541. 
  33542. File: mysql.info,  Node: MyODBC clients,  Next: ODBC and last_insert_id,  Prev: ODBC Problems,  Up: ODBC
  33543.  
  33544. Programs Known to Work with MyODBC
  33545. ----------------------------------
  33546.  
  33547. Most programs should work with *MyODBC*, but for each of those listed
  33548. below, we have tested it ourselves or received confirmation from some
  33549. user that it works:
  33550.  
  33551. *Program*
  33552.      *Comment*
  33553.  
  33554. Access
  33555.      To make Access work:
  33556.         * If you are using Access 2000, you should get and install the
  33557.           newest (version 2.6 or above) Microsoft MDAC (`Microsoft Data
  33558.           Access Components') from `http://www.microsoft.com/data'.
  33559.           This will fix the following bug in Access: when you export
  33560.           data to MySQL, the table and column names aren't specified.
  33561.           Another way to around this bug is to upgrade to MyODBC
  33562.           Version 2.50.33 and MySQL Version 3.23.x, which together
  33563.           provide a workaround for this bug!
  33564.  
  33565.           You should also get and apply the Microsoft Jet 4.0 Service
  33566.           Pack 5 (SP5) which can be found here
  33567.           `http://support.microsoft.com/support/kb/articles/Q
  33568.           239/1/14.ASP'.  This will fix some cases where columns are
  33569.           marked as `#deleted#' in Access.
  33570.  
  33571.           Note that if you are using MySQL Version 3.22, you must to
  33572.           apply the MDAC patch and use MyODBC 2.50.32 or 2.50.34 and
  33573.           above to go around this problem.
  33574.  
  33575.         * Set the "Return matching rows" MyODBC option field when
  33576.           connecting to MySQL.
  33577.  
  33578.         * You should have a primary key in the table. If not, new or
  33579.           updated rows may show up as `#Deleted#'.
  33580.  
  33581.         * You should have a timestamp in all tables you want to be able
  33582.           to update.  For maximum portability `TIMESTAMP(14)' or simple
  33583.           `TIMESTAMP' is recommended instead of other `TIMESTAMP(X)'
  33584.           variations.
  33585.  
  33586.         * Only use double float fields. Access fails when comparing
  33587.           with single floats.  The symptom usually is that new or
  33588.           updated rows may show up as `#Deleted#' or that you can't
  33589.           find or update rows.
  33590.  
  33591.         * If you still get the error `Another user has changed your
  33592.           data' after adding a `TIMESTAMP' column, the following trick
  33593.           may help you:
  33594.  
  33595.           Don't use `table' data sheet view. Create instead a form with
  33596.           the fields you want, and use that `form' data sheet view.
  33597.           You should set the `DefaultValue' property for the
  33598.           `TIMESTAMP' column to `NOW()'.  It may be a good idea to hide
  33599.           the `TIMESTAMP' column from view so your users are not
  33600.           confused.
  33601.  
  33602.         * Access on NT will report `BLOB' columns as `OLE OBJECTS'. If
  33603.           you want to have `MEMO' columns instead, you should change the
  33604.           column to `TEXT' with `ALTER TABLE'.
  33605.  
  33606.         * Access can't always handle `DATE' columns properly. If you
  33607.           have a problem with these, change the columns to `DATETIME'.
  33608.  
  33609.         * In some cases, Access may generate illegal SQL queries that
  33610.           MySQL can't understand. You can fix this by selecting
  33611.           `"Query|SQLSpecific|Pass-Through"' from the Access menu.
  33612.  
  33613.         * If you have in Access a column defined as BYTE, Access will
  33614.           try to export this as `TINYINT' instead of `TINYINT
  33615.           UNSIGNED'.  This will give you problems if you have values >
  33616.           127 in the column!
  33617.  
  33618.         * If you are using Access 7.0, You should use the option flag
  33619.           `Return matching rows'.
  33620.  
  33621.         * If you are using Access 2.0, You should use the option flags
  33622.           `Return matching rows' and `Simulate ODBC 1.0'.
  33623.  
  33624. ADO
  33625.      When you are coding with the ADO API and *MyODBC* you need to put
  33626.      attention in some default properties that aren't supported by the
  33627.      MySQL server.  For example, using the `CursorLocation Property' as
  33628.      `adUseServer' will return for the `RecordCount Property' a result
  33629.      of -1. To have the right value, you need to set this property to
  33630.      `adUseClient', like is showing in the VB code below:
  33631.  
  33632.           Dim myconn As New ADODB.Connection
  33633.           Dim myrs As New Recordset
  33634.           Dim mySQL As String
  33635.           Dim myrows As Long
  33636.           
  33637.           myconn.Open "DSN=MyODBCsample"
  33638.           mySQL = "SELECT * from user"
  33639.           myrs.Source = mySQL
  33640.           Set myrs.ActiveConnection = myconn
  33641.           myrs.CursorLocation = adUseClient
  33642.           myrs.Open
  33643.           myrows = myrs.RecordCount
  33644.           
  33645.           myrs.Close
  33646.           myconn.Close
  33647.  
  33648.      Another workaround is to use a `SELECT COUNT(*)' statement for a
  33649.      similar query to get the correct row count.
  33650.  
  33651. Active server pages (ASP)
  33652.      You should use the option flag `Return matching rows'.
  33653.  
  33654. BDE applications
  33655.      To get these to work, you should set the option flags `Don't
  33656.      optimize column widths' and `Return matching rows'.
  33657.  
  33658. Borland Builder 4
  33659.      When you start a query you can use the property `Active' or use the
  33660.      method `Open'.  Note that `Active' will start by automatically
  33661.      issuing a `SELECT * FROM ...' query that may not be a good thing if
  33662.      your tables are big!
  33663.  
  33664. ColdFusion (On Unix)
  33665.      The following information is taken from the ColdFusion
  33666.      documentation:
  33667.  
  33668.      Use the following information to configure ColdFusion Server for
  33669.      Linux to use the unixODBC driver with *MyODBC* for MySQL data
  33670.      sources.  Allaire has verified that *MyODBC* Version 2.50.26 works
  33671.      with MySQL Version 3.22.27 and ColdFusion for Linux. (Any newer
  33672.      version should also work.) You can download *MyODBC* at
  33673.      `http://www.mysql.com/downloads/api-myodbc.html'
  33674.  
  33675.      ColdFusion Version 4.5.1 allows you to us the ColdFusion
  33676.      Administrator to add the MySQL data source. However, the driver is
  33677.      not included with ColdFusion Version 4.5.1. Before the MySQL driver
  33678.      will appear in the ODBC datasources drop-down list, you must build
  33679.      and copy the *MyODBC* driver to `/opt/coldfusion/lib/libmyodbc.so'.
  33680.  
  33681.      The Contrib directory contains the program mydsn-xxx.zip which
  33682.      allows you to build and remove the DSN registry file for the
  33683.      MyODBC driver on Coldfusion applications.
  33684.  
  33685. DataJunction
  33686.      You have to change it to output `VARCHAR' rather than `ENUM', as
  33687.      it exports the latter in a manner that causes MySQL grief.
  33688.  
  33689. Excel
  33690.      Works. Some tips:
  33691.         * If you have problems with dates, try to select them as
  33692.           strings using the `CONCAT()' function. For example:
  33693.                select CONCAT(rise_time), CONCAT(set_time)
  33694.                    from sunrise_sunset;
  33695.           Values retrieved as strings this way should be correctly
  33696.           recognized as time values by Excel97.
  33697.  
  33698.           The purpose of `CONCAT()' in this example is to fool ODBC
  33699.           into thinking the column is of "string type". Without the
  33700.           `CONCAT()', ODBC knows the column is of time type, and Excel
  33701.           does not understand that.
  33702.  
  33703.           Note that this is a bug in Excel, because it automatically
  33704.           converts a string to a time. This would be great if the
  33705.           source was a text file, but is plain stupid when the source
  33706.           is an ODBC connection that reports exact types for each
  33707.           column.
  33708.  
  33709. Word
  33710.      To retrieve data from MySQL to Word/Excel documents, you need to
  33711.      use the `MyODBC' driver and the Add-in Microsoft Query help.
  33712.  
  33713.      For example, create a db with a table containing 2 columns of text:
  33714.  
  33715.         * Insert rows using the `mysql' client command-line tool.
  33716.  
  33717.         * Create a DSN file using the MyODBC driver, for example, my
  33718.           for the db above.
  33719.  
  33720.         * Open the Word application.
  33721.  
  33722.         * Create a blank new documentation.
  33723.  
  33724.         * Using the tool bar called Database, press the button insert
  33725.           database.
  33726.  
  33727.         * Press the button Get Data.
  33728.  
  33729.         * At the right hand of the screen Get Data, press the button Ms
  33730.           Query.
  33731.  
  33732.         * In the Ms Query create a New Data Source using the DSN file
  33733.           my.
  33734.  
  33735.         * Select the new query.
  33736.  
  33737.         * Select the columns that you want.
  33738.  
  33739.         * Make a filter if you want.
  33740.  
  33741.         * Make a Sort if you want.
  33742.  
  33743.         * Select Return Data to Microsoft Word.
  33744.  
  33745.         * Click Finish.
  33746.  
  33747.         * Click Insert data and select the records.
  33748.  
  33749.         * Click OK and you see the rows in your Word document.
  33750.  
  33751. odbcadmin
  33752.      Test program for ODBC.
  33753.  
  33754. Delphi
  33755.      You must use BDE Version 3.2 or newer.  Set the `Don't optimize
  33756.      column width' option field when connecting to MySQL.
  33757.  
  33758.      Also, here is some potentially useful Delphi code that sets up
  33759.      both an ODBC entry and a BDE entry for *MyODBC* (the BDE entry
  33760.      requires a BDE Alias Editor that is free at a Delphi Super Page
  33761.      near you. (Thanks to Bryan Brunton <bryan@flesherfab.com> for
  33762.      this):
  33763.  
  33764.           fReg:= TRegistry.Create;
  33765.             fReg.OpenKey('\Software\ODBC\ODBC.INI\DocumentsFab', True);
  33766.             fReg.WriteString('Database', 'Documents');
  33767.             fReg.WriteString('Description', ' ');
  33768.             fReg.WriteString('Driver', 'C:\WINNT\System32\myodbc.dll');
  33769.             fReg.WriteString('Flag', '1');
  33770.             fReg.WriteString('Password', '');
  33771.             fReg.WriteString('Port', ' ');
  33772.             fReg.WriteString('Server', 'xmark');
  33773.             fReg.WriteString('User', 'winuser');
  33774.             fReg.OpenKey('\Software\ODBC\ODBC.INI\ODBC Data Sources', True);
  33775.             fReg.WriteString('DocumentsFab', 'MySQL');
  33776.             fReg.CloseKey;
  33777.             fReg.Free;
  33778.           
  33779.             Memo1.Lines.Add('DATABASE NAME=');
  33780.             Memo1.Lines.Add('USER NAME=');
  33781.             Memo1.Lines.Add('ODBC DSN=DocumentsFab');
  33782.             Memo1.Lines.Add('OPEN MODE=READ/WRITE');
  33783.             Memo1.Lines.Add('BATCH COUNT=200');
  33784.             Memo1.Lines.Add('LANGDRIVER=');
  33785.             Memo1.Lines.Add('MAX ROWS=-1');
  33786.             Memo1.Lines.Add('SCHEMA CACHE DIR=');
  33787.             Memo1.Lines.Add('SCHEMA CACHE SIZE=8');
  33788.             Memo1.Lines.Add('SCHEMA CACHE TIME=-1');
  33789.             Memo1.Lines.Add('SQLPASSTHRU MODE=SHARED AUTOCOMMIT');
  33790.             Memo1.Lines.Add('SQLQRYMODE=');
  33791.             Memo1.Lines.Add('ENABLE SCHEMA CACHE=FALSE');
  33792.             Memo1.Lines.Add('ENABLE BCD=FALSE');
  33793.             Memo1.Lines.Add('ROWSET SIZE=20');
  33794.             Memo1.Lines.Add('BLOBS TO CACHE=64');
  33795.             Memo1.Lines.Add('BLOB SIZE=32');
  33796.           
  33797.             AliasEditor.Add('DocumentsFab','MySQL',Memo1.Lines);
  33798.  
  33799. C++ Builder
  33800.      Tested with BDE Version 3.0. The only known problem is that when
  33801.      the table schema changes, query fields are not updated. BDE,
  33802.      however, does not seem to recognize primary keys, only the index
  33803.      PRIMARY, though this has not been a problem.
  33804.  
  33805. Vision
  33806.      You should use the option flag `Return matching rows'.
  33807.  
  33808. Visual Basic
  33809.      To be able to update a table, you must define a primary key for
  33810.      the table.
  33811.  
  33812.      Visual Basic with ADO can't handle big integers. This means that
  33813.      some queries like `SHOW PROCESSLIST' will not work properly.  The
  33814.      fix is to set add the option `OPTION=16834' in the ODBC connect
  33815.      string or set the `Change BIGINT columns to INT' option in the
  33816.      MyODBC connect screen.  You may also want to set the `Return
  33817.      matching rows' option.
  33818.  
  33819. VisualInterDev
  33820.      If you get the error `[Microsoft][ODBC Driver Manager] Driver does
  33821.      not support this parameter' the reason may be that you have a
  33822.      `BIGINT' in your result.  Try setting the `Change BIGINT columns
  33823.      to INT' option in the MyODBC connect screen.
  33824.  
  33825. Visual Objects
  33826.      You should use the option flag `Don't optimize column widths'.
  33827.  
  33828. 
  33829. File: mysql.info,  Node: ODBC and last_insert_id,  Next: MyODBC bug report,  Prev: MyODBC clients,  Up: ODBC
  33830.  
  33831. How to Get the Value of an `AUTO_INCREMENT' Column in ODBC
  33832. ----------------------------------------------------------
  33833.  
  33834. A common problem is how to get the value of an automatically generated
  33835. ID from an `INSERT'. With ODBC, you can do something like this (assuming
  33836. that `auto' is an `AUTO_INCREMENT' field):
  33837.  
  33838.      INSERT INTO foo (auto,text) VALUES(NULL,'text');
  33839.      SELECT LAST_INSERT_ID();
  33840.  
  33841. Or, if you are just going to insert the ID into another table, you can
  33842. do this:
  33843.  
  33844.      INSERT INTO foo (auto,text) VALUES(NULL,'text');
  33845.      INSERT INTO foo2 (id,text) VALUES(LAST_INSERT_ID(),'text');
  33846.  
  33847. *Note Getting unique ID::.
  33848.  
  33849. For the benefit of some ODBC applications (at least Delphi and Access),
  33850. the following query can be used to find a newly inserted row:
  33851.      SELECT * FROM tbl_name WHERE auto IS NULL;
  33852.  
  33853. 
  33854. File: mysql.info,  Node: MyODBC bug report,  Prev: ODBC and last_insert_id,  Up: ODBC
  33855.  
  33856. Reporting Problems with MyODBC
  33857. ------------------------------
  33858.  
  33859. If you encounter difficulties with *MyODBC*, you should start by making
  33860. a log file from the ODBC manager (the log you get when requesting logs
  33861. from ODBCADMIN) and a *MyODBC* log.
  33862.  
  33863. To get a *MyODBC* log, you need to do the following:
  33864.  
  33865.   1. Ensure that you are using `myodbcd.dll' and not `myodbc.dll'.  The
  33866.      easiest way to do this is to get `myodbcd.dll' from the MyODBC
  33867.      distribution and copy it over the `myodbc.dll', which is probably
  33868.      in your `C:\windows\system32' or `C:\winnt\system32' directory.
  33869.  
  33870.      Note that you probably want to restore the old myodbc.dll file
  33871.      when you have finished testing, as this is a lot faster than
  33872.      `myodbcd.dll'.
  33873.  
  33874.   2. Tag the `Trace MyODBC' option flag in the *MyODBC*
  33875.      connect/configure screen.  The log will be written to file
  33876.      `C:\myodbc.log'.
  33877.  
  33878.      If the trace option is not remembered when you are going back to
  33879.      the above screen, it means that you are not using the `myodbcd.dll'
  33880.      driver (see above).
  33881.  
  33882.   3. Start your application and try to get it to fail.
  33883.  
  33884. Check the `MyODBC trace file', to find out what could be wrong.  You
  33885. should be able to find out the issued queries by searching after the
  33886. string `>mysql_real_query' in the `myodbc.log' file.
  33887.  
  33888. You should also try duplicating the queries in the `mysql' monitor or
  33889. `admndemo' to find out if the error is MyODBC or MySQL.
  33890.  
  33891. If you find out something is wrong, please only send the relevant rows
  33892. (max 40 rows) to <myodbc@lists.mysql.com>.  Please never send the whole
  33893. MyODBC or ODBC log file!
  33894.  
  33895. If you are unable to find out what's wrong, the last option is to make
  33896. an archive (tar or zip) that contains a MyODBC trace file, the ODBC log
  33897. file, and a README file that explains the problem.  You can send this
  33898. to `ftp://support.mysql.com/pub/mysql/secret'.  Only we at MySQL AB
  33899. will have access to the files you upload, and we will be very discrete
  33900. with the data!
  33901.  
  33902. If you can create a program that also shows this problem, please upload
  33903. this too!
  33904.  
  33905. If the program works with some other SQL server, you should make an
  33906. ODBC log file where you do exactly the same thing in the other SQL
  33907. server.
  33908.  
  33909. Remember that the more information you can supply to us, the more
  33910. likely it is that we can fix the problem!
  33911.  
  33912. 
  33913. File: mysql.info,  Node: C,  Next: Cplusplus,  Prev: ODBC,  Up: Clients
  33914.  
  33915. MySQL C API
  33916. ===========
  33917.  
  33918. * Menu:
  33919.  
  33920. * C API datatypes::             C API Datatypes
  33921. * C API function overview::     C API Function Overview
  33922. * C API functions::             C API Function Descriptions
  33923. * C Thread functions::
  33924. * C API problems::              Common questions and problems when using the C API
  33925. * Building clients::            Building Client Programs
  33926. * Threaded clients::            How to Make a Threaded Client
  33927.  
  33928. The C API code is distributed with MySQL. It is included in the
  33929. `mysqlclient' library and allows C programs to access a database.
  33930.  
  33931. Many of the clients in the MySQL source distribution are written in C.
  33932. If you are looking for examples that demonstrate how to use the C API,
  33933. take a look at these clients. You can find these in the `clients'
  33934. directory in the MySQL source distribution.
  33935.  
  33936. Most of the other client APIs (all except Java) use the `mysqlclient'
  33937. library to communicate with the MySQL server. This means that, for
  33938. example, you can take advantage of many of the same environment
  33939. variables that are used by other client programs, because they are
  33940. referenced from the library.  See *Note Client-Side Scripts::, for a
  33941. list of these variables.
  33942.  
  33943. The client has a maximum communication buffer size. The size of the
  33944. buffer that is allocated initially (16K bytes) is automatically
  33945. increased up to the maximum size (the maximum is 16M). Because buffer
  33946. sizes are increased only as demand warrants, simply increasing the
  33947. default maximum limit does not in itself cause more resources to be
  33948. used. This size check is mostly a check for erroneous queries and
  33949. communication packets.
  33950.  
  33951. The communication buffer must be large enough to contain a single SQL
  33952. statement (for client-to-server traffic) and one row of returned data
  33953. (for server-to-client traffic).  Each thread's communication buffer is
  33954. dynamically enlarged to handle any query or row up to the maximum
  33955. limit.  For example, if you have `BLOB' values that contain up to 16M
  33956. of data, you must have a communication buffer limit of at least 16M (in
  33957. both server and client).  The client's default maximum is 16M, but the
  33958. default maximum in the server is 1M.  You can increase this by changing
  33959. the value of the `max_allowed_packet' parameter when the server is
  33960. started.  *Note Server parameters::.
  33961.  
  33962. The MySQL server shrinks each communication buffer to
  33963. `net_buffer_length' bytes after each query.  For clients, the size of
  33964. the buffer associated with a connection is not decreased until the
  33965. connection is closed, at which time client memory is reclaimed.
  33966.  
  33967. For programming with threads, consult the 'how to make a thread-safe
  33968. client' chapter. *Note Threaded clients::.
  33969.  
  33970. 
  33971. File: mysql.info,  Node: C API datatypes,  Next: C API function overview,  Prev: C,  Up: C
  33972.  
  33973. C API Datatypes
  33974. ---------------
  33975.  
  33976. `MYSQL'
  33977.      This structure represents a handle to one database connection. It
  33978.      is used for almost all MySQL functions.
  33979.  
  33980. `MYSQL_RES'
  33981.      This structure represents the result of a query that returns rows
  33982.      (`SELECT', `SHOW', `DESCRIBE', `EXPLAIN').  The information
  33983.      returned from a query is called the _result set_ in the remainder
  33984.      of this section.
  33985.  
  33986. `MYSQL_ROW'
  33987.      This is a type-safe representation of one row of data. It is
  33988.      currently implemented as an array of counted byte strings.  (You
  33989.      cannot treat these as null-terminated strings if field values may
  33990.      contain binary data, because such values may contain null bytes
  33991.      internally.)  Rows are obtained by calling `mysql_fetch_row()'.
  33992.  
  33993. `MYSQL_FIELD'
  33994.      This structure contains information about a field, such as the
  33995.      field's name, type, and size. Its members are described in more
  33996.      detail below.  You may obtain the `MYSQL_FIELD' structures for
  33997.      each field by calling `mysql_fetch_field()' repeatedly.  Field
  33998.      values are not part of this structure; they are contained in a
  33999.      `MYSQL_ROW' structure.
  34000.  
  34001. `MYSQL_FIELD_OFFSET'
  34002.      This is a type-safe representation of an offset into a MySQL field
  34003.      list.  (Used by `mysql_field_seek()'.)  Offsets are field numbers
  34004.      within a row, beginning at zero.
  34005.  
  34006. `my_ulonglong'
  34007.      The type used for the number of rows and for
  34008.      `mysql_affected_rows()', `mysql_num_rows()', and
  34009.      `mysql_insert_id()'. This type provides a range of `0' to
  34010.      `1.84e19'.
  34011.  
  34012.      On some systems, attempting to print a value of type `my_ulonglong'
  34013.      will not work.  To print such a value, convert it to `unsigned
  34014.      long' and use a `%lu' print format.  Example:
  34015.           printf (Number of rows: %lu\n", (unsigned long) mysql_num_rows(result));
  34016.  
  34017. The `MYSQL_FIELD' structure contains the members listed below:
  34018.  
  34019. `char * name'
  34020.      The name of the field, as a null-terminated string.
  34021.  
  34022. `char * table'
  34023.      The name of the table containing this field, if it isn't a
  34024.      calculated field.  For calculated fields, the `table' value is an
  34025.      empty string.
  34026.  
  34027. `char * def'
  34028.      The default value of this field, as a null-terminated string.
  34029.      This is set only if you use `mysql_list_fields()'.
  34030.  
  34031. `enum enum_field_types type'
  34032.      The type of the field.  The `type' value may be one of the
  34033.      following:
  34034.  
  34035.      *Type value*         *Type meaning*
  34036.      `FIELD_TYPE_TINY'    `TINYINT' field
  34037.      `FIELD_TYPE_SHORT'   `SMALLINT' field
  34038.      `FIELD_TYPE_LONG'    `INTEGER' field
  34039.      `FIELD_TYPE_INT24'   `MEDIUMINT' field
  34040.      `FIELD_TYPE_LONGLONG'`BIGINT' field
  34041.      `FIELD_TYPE_DECIMAL' `DECIMAL' or `NUMERIC' field
  34042.      `FIELD_TYPE_FLOAT'   `FLOAT' field
  34043.      `FIELD_TYPE_DOUBLE'  `DOUBLE' or `REAL' field
  34044.      `FIELD_TYPE_TIMESTAMP'`TIMESTAMP' field
  34045.      `FIELD_TYPE_DATE'    `DATE' field
  34046.      `FIELD_TYPE_TIME'    `TIME' field
  34047.      `FIELD_TYPE_DATETIME'`DATETIME' field
  34048.      `FIELD_TYPE_YEAR'    `YEAR' field
  34049.      `FIELD_TYPE_STRING'  String (`CHAR' or `VARCHAR') field
  34050.      `FIELD_TYPE_BLOB'    `BLOB' or `TEXT' field (use
  34051.                           `max_length' to determine the
  34052.                           maximum length)
  34053.      `FIELD_TYPE_SET'     `SET' field
  34054.      `FIELD_TYPE_ENUM'    `ENUM' field
  34055.      `FIELD_TYPE_NULL'    `NULL'-type field
  34056.      `FIELD_TYPE_CHAR'    Deprecated; use `FIELD_TYPE_TINY'
  34057.                           instead
  34058.  
  34059.      You can use the `IS_NUM()' macro to test whether or not a field
  34060.      has a numeric type.  Pass the `type' value to `IS_NUM()' and it
  34061.      will evaluate to TRUE if the field is numeric:
  34062.  
  34063.           if (IS_NUM(field->type))
  34064.               printf("Field is numeric\n");
  34065.  
  34066. `unsigned int length'
  34067.      The width of the field, as specified in the table definition.
  34068.  
  34069. `unsigned int max_length'
  34070.      The maximum width of the field for the result set (the length of
  34071.      the longest field value for the rows actually in the result set).
  34072.      If you use `mysql_store_result()' or `mysql_list_fields()', this
  34073.      contains the maximum length for the field.  If you use
  34074.      `mysql_use_result()', the value of this variable is zero.
  34075.  
  34076. `unsigned int flags'
  34077.      Different bit-flags for the field.  The `flags' value may have zero
  34078.      or more of the following bits set:
  34079.  
  34080.      *Flag value*         *Flag meaning*
  34081.      `NOT_NULL_FLAG'      Field can't be `NULL'
  34082.      `PRI_KEY_FLAG'       Field is part of a primary key
  34083.      `UNIQUE_KEY_FLAG'    Field is part of a unique key
  34084.      `MULTIPLE_KEY_FLAG'  Field is part of a non-unique key
  34085.      `UNSIGNED_FLAG'      Field has the `UNSIGNED' attribute
  34086.      `ZEROFILL_FLAG'      Field has the `ZEROFILL' attribute
  34087.      `BINARY_FLAG'        Field has the `BINARY' attribute
  34088.      `AUTO_INCREMENT_FLAG'Field has the `AUTO_INCREMENT'
  34089.                           attribute
  34090.      `ENUM_FLAG'          Field is an `ENUM' (deprecated)
  34091.      `BLOB_FLAG'          Field is a `BLOB' or `TEXT'
  34092.                           (deprecated)
  34093.      `TIMESTAMP_FLAG'     Field is a `TIMESTAMP' (deprecated)
  34094.  
  34095.      Use of the `BLOB_FLAG', `ENUM_FLAG', and `TIMESTAMP_FLAG' flags is
  34096.      deprecated because they indicate the type of a field rather than
  34097.      an attribute of its type.  It is preferable to test `field->type'
  34098.      against `FIELD_TYPE_BLOB', `FIELD_TYPE_ENUM', or
  34099.      `FIELD_TYPE_TIMESTAMP' instead.
  34100.  
  34101.      The example below illustrates a typical use of the `flags' value:
  34102.  
  34103.           if (field->flags & NOT_NULL_FLAG)
  34104.               printf("Field can't be null\n");
  34105.  
  34106.      You may use the following convenience macros to determine the
  34107.      boolean status of the `flags' value:
  34108.  
  34109.      `IS_NOT_NULL(flags)' True if this field is defined as
  34110.                           `NOT NULL'
  34111.      `IS_PRI_KEY(flags)'  True if this field is a primary
  34112.                           key
  34113.      `IS_BLOB(flags)'     True if this field is a `BLOB' or
  34114.                           `TEXT' (deprecated; test
  34115.                           `field->type' instead)
  34116.  
  34117. `unsigned int decimals'
  34118.      The number of decimals for numeric fields.
  34119.  
  34120. 
  34121. File: mysql.info,  Node: C API function overview,  Next: C API functions,  Prev: C API datatypes,  Up: C
  34122.  
  34123. C API Function Overview
  34124. -----------------------
  34125.  
  34126. The functions available in the C API are listed below and are described
  34127. in greater detail in the next section.  *Note C API functions::.
  34128.  
  34129. *mysql_affected_rows()* Returns the number of rows
  34130.                        changed/deleted/inserted by the last `UPDATE',
  34131.                        `DELETE', or `INSERT' query.
  34132. *mysql_close()*         Closes a server connection.
  34133. *mysql_connect()*       Connects to a MySQL server. This function is
  34134.                        deprecated; use `mysql_real_connect()' instead.
  34135. *mysql_change_user()*   Changes user and database on an open connection.
  34136. *mysql_character_set_name()* Returns the name of the default character set
  34137.                        for the connection.
  34138. *mysql_create_db()*     Creates a database. This function is deprecated;
  34139.                        use the SQL command `CREATE DATABASE' instead.
  34140. *mysql_data_seek()*     Seeks to an arbitrary row in a query result set.
  34141. *mysql_debug()*         Does a `DBUG_PUSH' with the given string.
  34142. *mysql_drop_db()*       Drops a database. This function is deprecated;
  34143.                        use the SQL command `DROP DATABASE' instead.
  34144. *mysql_dump_debug_info()* Makes the server write debug information to the
  34145.                        log.
  34146. *mysql_eof()*           Determines whether or not the last row of a
  34147.                        result set has been read.  This function is
  34148.                        deprecated; `mysql_errno()' or `mysql_error()'
  34149.                        may be used instead.
  34150. *mysql_errno()*         Returns the error number for the most recently
  34151.                        invoked MySQL function.
  34152. *mysql_error()*         Returns the error message for the most recently
  34153.                        invoked MySQL function.
  34154. *mysql_real_escape_string()* Escapes special characters in a string for use
  34155.                        in a SQL statement taking into account the
  34156.                        current charset of the connection.
  34157. *mysql_escape_string()* Escapes special characters in a string for use
  34158.                        in a SQL statement.
  34159. *mysql_fetch_field()*   Returns the type of the next table field.
  34160. *mysql_fetch_field_direct()* Returns the type of a table field, given a field
  34161.                        number.
  34162. *mysql_fetch_fields()*  Returns an array of all field structures.
  34163. *mysql_fetch_lengths()* Returns the lengths of all columns in the
  34164.                        current row.
  34165. *mysql_fetch_row()*     Fetches the next row from the result set.
  34166. *mysql_field_seek()*    Puts the column cursor on a specified column.
  34167. *mysql_field_count()*   Returns the number of result columns for the
  34168.                        most recent query.
  34169. *mysql_field_tell()*    Returns the position of the field cursor used
  34170.                        for the last `mysql_fetch_field()'.
  34171. *mysql_free_result()*   Frees memory used by a result set.
  34172. *mysql_get_client_info()* Returns client version information.
  34173. *mysql_get_host_info()* Returns a string describing the connection.
  34174. *mysql_get_proto_info()* Returns the protocol version used by the
  34175.                        connection.
  34176. *mysql_get_server_info()* Returns the server version number.
  34177. *mysql_info()*          Returns information about the most recently
  34178.                        executed query.
  34179. *mysql_init()*          Gets or initializes a `MYSQL' structure.
  34180. *mysql_insert_id()*     Returns the ID generated for an `AUTO_INCREMENT'
  34181.                        column by the previous query.
  34182. *mysql_kill()*          Kills a given thread.
  34183. *mysql_list_dbs()*      Returns database names matching a simple regular
  34184.                        expression.
  34185. *mysql_list_fields()*   Returns field names matching a simple regular
  34186.                        expression.
  34187. *mysql_list_processes()* Returns a list of the current server threads.
  34188. *mysql_list_tables()*   Returns table names matching a simple regular
  34189.                        expression.
  34190. *mysql_num_fields()*    Returns the number of columns in a result set.
  34191. *mysql_num_rows()*      Returns the number of rows in a result set.
  34192. *mysql_options()*       Sets connect options for `mysql_connect()'.
  34193. *mysql_ping()*          Checks whether or not the connection to the
  34194.                        server is working, reconnecting as necessary.
  34195. *mysql_query()*         Executes a SQL query specified as a
  34196.                        null-terminated string.
  34197. *mysql_real_connect()*  Connects to a MySQL server.
  34198. *mysql_real_query()*    Executes a SQL query specified as a counted
  34199.                        string.
  34200. *mysql_reload()*        Tells the server to reload the grant tables.
  34201. *mysql_row_seek()*      Seeks to a row in a result set, using value
  34202.                        returned from `mysql_row_tell()'.
  34203. *mysql_row_tell()*      Returns the row cursor position.
  34204. *mysql_select_db()*     Selects a database.
  34205. *mysql_shutdown()*      Shuts down the database server.
  34206. *mysql_stat()*          Returns the server status as a string.
  34207. *mysql_store_result()*  Retrieves a complete result set to the client.
  34208. *mysql_thread_id()*     Returns the current thread ID.
  34209. *mysql_thread_save()*   Returns 1 if the clients are compiled as
  34210.                        thread-safe.
  34211. *mysql_use_result()*    Initiates a row-by-row result set retrieval.
  34212.  
  34213. To connect to the server, call `mysql_init()' to initialize a
  34214. connection handler, then call `mysql_real_connect()' with that handler
  34215. (along with other information such as the hostname, user name, and
  34216. password).  Upon connection, `mysql_real_connect()' sets the
  34217. `reconnect' flag (part of the MYSQL structure) to a value of `1'. This
  34218. flag indicates, in the event that a query cannot be performed because
  34219. of a lost connection, to try reconnecting to the server before giving
  34220. up.  When you are done with the connection, call `mysql_close()' to
  34221. terminate it.
  34222.  
  34223. While a connection is active, the client may send SQL queries to the
  34224. server using `mysql_query()' or `mysql_real_query()'.  The difference
  34225. between the two is that `mysql_query()' expects the query to be
  34226. specified as a null-terminated string whereas `mysql_real_query()'
  34227. expects a counted string.  If the string contains binary data (which may
  34228. include null bytes), you must use `mysql_real_query()'.
  34229.  
  34230. For each non-`SELECT' query (for example, `INSERT', `UPDATE',
  34231. `DELETE'), you can find out how many rows were changed (affected) by
  34232. calling `mysql_affected_rows()'.
  34233.  
  34234. For `SELECT' queries, you retrieve the selected rows as a result set.
  34235. (Note that some statements are `SELECT'-like in that they return rows.
  34236. These include `SHOW', `DESCRIBE', and `EXPLAIN'.  They should be
  34237. treated the same way as `SELECT' statements.)
  34238.  
  34239. There are two ways for a client to process result sets.  One way is to
  34240. retrieve the entire result set all at once by calling
  34241. `mysql_store_result()'.  This function acquires from the server all the
  34242. rows returned by the query and stores them in the client.  The second
  34243. way is for the client to initiate a row-by-row result set retrieval by
  34244. calling `mysql_use_result()'.  This function initializes the retrieval,
  34245. but does not actually get any rows from the server.
  34246.  
  34247. In both cases, you access rows by calling `mysql_fetch_row()'.  With
  34248. `mysql_store_result()', `mysql_fetch_row()' accesses rows that have
  34249. already been fetched from the server.  With `mysql_use_result()',
  34250. `mysql_fetch_row()' actually retrieves the row from the server.
  34251. Information about the size of the data in each row is available by
  34252. calling `mysql_fetch_lengths()'.
  34253.  
  34254. After you are done with a result set, call `mysql_free_result()' to
  34255. free the memory used for it.
  34256.  
  34257. The two retrieval mechanisms are complementary.  Client programs should
  34258. choose the approach that is most appropriate for their requirements.
  34259. In practice, clients tend to use `mysql_store_result()' more commonly.
  34260.  
  34261. An advantage of `mysql_store_result()' is that because the rows have all
  34262. been fetched to the client, you not only can access rows sequentially,
  34263. you can move back and forth in the result set using `mysql_data_seek()'
  34264. or `mysql_row_seek()' to change the current row position within the
  34265. result set.  You can also find out how many rows there are by calling
  34266. `mysql_num_rows()'.  On the other hand, the memory requirements for
  34267. `mysql_store_result()' may be very high for large result sets and you
  34268. are more likely to encounter out-of-memory conditions.
  34269.  
  34270. An advantage of `mysql_use_result()' is that the client requires less
  34271. memory for the result set because it maintains only one row at a time
  34272. (and because there is less allocation overhead, `mysql_use_result()'
  34273. can be faster).  Disadvantages are that you must process each row
  34274. quickly to avoid tying up the server, you don't have random access to
  34275. rows within the result set (you can only access rows sequentially), and
  34276. you don't know how many rows are in the result set until you have
  34277. retrieved them all.  Furthermore, you _must_ retrieve all the rows even
  34278. if you determine in mid-retrieval that you've found the information you
  34279. were looking for.
  34280.  
  34281. The API makes it possible for clients to respond appropriately to
  34282. queries (retrieving rows only as necessary) without knowing whether or
  34283. not the query is a `SELECT'.  You can do this by calling
  34284. `mysql_store_result()' after each `mysql_query()' (or
  34285. `mysql_real_query()').  If the result set call succeeds, the query was
  34286. a `SELECT' and you can read the rows.  If the result set call fails,
  34287. call `mysql_field_count()' to determine whether or not a result was
  34288. actually to be expected.  If `mysql_field_count()' returns zero, the
  34289. query returned no data (indicating that it was an `INSERT', `UPDATE',
  34290. `DELETE', etc.), and was not expected to return rows.  If
  34291. `mysql_field_count()' is non-zero, the query should have returned rows,
  34292. but didn't.  This indicates that the query was a `SELECT' that failed.
  34293. See the description for `mysql_field_count()' for an example of how
  34294. this can be done.
  34295.  
  34296. Both `mysql_store_result()' and `mysql_use_result()' allow you to
  34297. obtain information about the fields that make up the result set (the
  34298. number of fields, their names and types, etc.).  You can access field
  34299. information sequentially within the row by calling
  34300. `mysql_fetch_field()' repeatedly, or by field number within the row by
  34301. calling `mysql_fetch_field_direct()'.  The current field cursor
  34302. position may be changed by calling `mysql_field_seek()'.  Setting the
  34303. field cursor affects subsequent calls to `mysql_fetch_field()'.  You
  34304. can also get information for fields all at once by calling
  34305. `mysql_fetch_fields()'.
  34306.  
  34307. For detecting and reporting errors, MySQL provides access to error
  34308. information by means of the `mysql_errno()' and `mysql_error()'
  34309. functions.  These return the error code or error message for the most
  34310. recently invoked function that can succeed or fail, allowing you to
  34311. determine when an error occurred and what it was.
  34312.  
  34313. 
  34314. File: mysql.info,  Node: C API functions,  Next: C Thread functions,  Prev: C API function overview,  Up: C
  34315.  
  34316. C API Function Descriptions
  34317. ---------------------------
  34318.  
  34319. * Menu:
  34320.  
  34321. * mysql_affected_rows::         `mysql_affected_rows()'
  34322. * mysql_close::                 `mysql_close()'
  34323. * mysql_connect::               `mysql_connect()'
  34324. * mysql_change_user::           `mysql_change_user()'
  34325. * mysql_character_set_name::    `mysql_character_set_name()'
  34326. * mysql_create_db::             `mysql_create_db()'
  34327. * mysql_data_seek::             `mysql_data_seek()'
  34328. * mysql_debug::                 `mysql_debug()'
  34329. * mysql_drop_db::               `mysql_drop_db()'
  34330. * mysql_dump_debug_info::       `mysql_dump_debug_info()'
  34331. * mysql_eof::                   `mysql_eof()'
  34332. * mysql_errno::                 `mysql_errno()'
  34333. * mysql_error::                 `mysql_error()'
  34334. * mysql_escape_string::         `mysql_escape_string()'
  34335. * mysql_fetch_field::           `mysql_fetch_field()'
  34336. * mysql_fetch_fields::          `mysql_fetch_fields()'
  34337. * mysql_fetch_field_direct::    `mysql_fetch_field_direct()'
  34338. * mysql_fetch_lengths::         `mysql_fetch_lengths()'
  34339. * mysql_fetch_row::             `mysql_fetch_row()'
  34340. * mysql_field_count::           `mysql_field_count()'
  34341. * mysql_field_seek::            `mysql_field_seek()'
  34342. * mysql_field_tell::            `mysql_field_tell()'
  34343. * mysql_free_result::           `mysql_free_result()'
  34344. * mysql_get_client_info::       `mysql_get_client_info()'
  34345. * mysql_get_host_info::         `mysql_get_host_info()'
  34346. * mysql_get_proto_info::        `mysql_get_proto_info()'
  34347. * mysql_get_server_info::       `mysql_get_server_info()'
  34348. * mysql_info::                  `mysql_info()'
  34349. * mysql_init::                  `mysql_init()'
  34350. * mysql_insert_id::             `mysql_insert_id()'
  34351. * mysql_kill::                  `mysql_kill()'
  34352. * mysql_list_dbs::              `mysql_list_dbs()'
  34353. * mysql_list_fields::           `mysql_list_fields()'
  34354. * mysql_list_processes::        `mysql_list_processes()'
  34355. * mysql_list_tables::           `mysql_list_tables()'
  34356. * mysql_num_fields::            `mysql_num_fields()'
  34357. * mysql_num_rows::              `mysql_num_rows()'
  34358. * mysql_options::               `mysql_options()'
  34359. * mysql_ping::                  `mysql_ping()'
  34360. * mysql_query::                 `mysql_query()'
  34361. * mysql_real_connect::          `mysql_real_connect()'
  34362. * mysql_real_escape_string::    `mysql_real_escape_string()'
  34363. * mysql_real_query::            `mysql_real_query()'
  34364. * mysql_reload::                `mysql_reload()'
  34365. * mysql_row_seek::              `mysql_row_seek()'
  34366. * mysql_row_tell::              `mysql_row_tell()'
  34367. * mysql_select_db::             `mysql_select_db()'
  34368. * mysql_shutdown::              `mysql_shutdown()'
  34369. * mysql_stat::                  `mysql_stat()'
  34370. * mysql_store_result::          `mysql_store_result()'
  34371. * mysql_thread_id::             `mysql_thread_id()'
  34372. * mysql_use_result::            `mysql_use_result()'
  34373.  
  34374. In the descriptions below, a parameter or return value of `NULL' means
  34375. `NULL' in the sense of the C programming language, not a MySQL `NULL'
  34376. value.
  34377.  
  34378. Functions that return a value generally return a pointer or an integer.
  34379. Unless specified otherwise, functions returning a pointer return a
  34380. non-`NULL' value to indicate success or a `NULL' value to indicate an
  34381. error, and functions returning an integer return zero to indicate
  34382. success or non-zero to indicate an error.  Note that "non-zero" means
  34383. just that.  Unless the function description says otherwise, do not test
  34384. against a value other than zero:
  34385.  
  34386.      if (result)                   /* correct */
  34387.          ... error ...
  34388.      
  34389.      if (result < 0)               /* incorrect */
  34390.          ... error ...
  34391.      
  34392.      if (result == -1)             /* incorrect */
  34393.          ... error ...
  34394.  
  34395. When a function returns an error, the *Errors* subsection of the
  34396. function description lists the possible types of errors.  You can find
  34397. out which of these occurred by calling `mysql_errno()'.  A string
  34398. representation of the error may be obtained by calling `mysql_error()'.
  34399.  
  34400. 
  34401. File: mysql.info,  Node: mysql_affected_rows,  Next: mysql_close,  Prev: C API functions,  Up: C API functions
  34402.  
  34403. `mysql_affected_rows()'
  34404. .......................
  34405.  
  34406. `my_ulonglong mysql_affected_rows(MYSQL *mysql)'
  34407.  
  34408. Description
  34409. ...........
  34410.  
  34411. Returns the number of rows changed by the last `UPDATE', deleted by the
  34412. last `DELETE' or inserted by the last `INSERT' statement. May be called
  34413. immediately after `mysql_query()' for `UPDATE', `DELETE', or `INSERT'
  34414. statements.  For `SELECT' statements, `mysql_affected_rows()' works like
  34415. `mysql_num_rows()'.
  34416.  
  34417. Return Values
  34418. .............
  34419.  
  34420. An integer greater than zero indicates the number of rows affected or
  34421. retrieved.  Zero indicates that no records where updated for an
  34422. `UPDATE' statement, no rows matched the `WHERE' clause in the query or
  34423. that no query has yet been executed.  -1 indicates that the query
  34424. returned an error or that, for a `SELECT' query,
  34425. `mysql_affected_rows()' was called prior to calling
  34426. `mysql_store_result()'.
  34427.  
  34428. Errors
  34429. ......
  34430.  
  34431. None.
  34432.  
  34433. Example
  34434. .......
  34435.  
  34436.      mysql_query(&mysql,"UPDATE products SET cost=cost*1.25 WHERE group=10");
  34437.      printf("%ld products updated",(long) mysql_affected_rows(&mysql));
  34438.  
  34439. If one specifies the flag `CLIENT_FOUND_ROWS' when connecting to
  34440. `mysqld', `mysql_affected_rows()' will return the number of rows
  34441. matched by the `WHERE' statement for `UPDATE' statements.
  34442.  
  34443. Note that when one uses a `REPLACE' command, `mysql_affected_rows()'
  34444. will return 2 if the new row replaced and old row.  This is because in
  34445. this case one row was inserted and then the duplicate was deleted.
  34446.  
  34447. 
  34448. File: mysql.info,  Node: mysql_close,  Next: mysql_connect,  Prev: mysql_affected_rows,  Up: C API functions
  34449.  
  34450. `mysql_close()'
  34451. ...............
  34452.  
  34453. `void mysql_close(MYSQL *mysql)'
  34454.  
  34455. Description
  34456. ...........
  34457.  
  34458. Closes a previously opened connection.  `mysql_close()' also deallocates
  34459. the connection handle pointed to by `mysql' if the handle was allocated
  34460. automatically by `mysql_init()' or `mysql_connect()'.
  34461.  
  34462. Return Values
  34463. .............
  34464.  
  34465. None.
  34466.  
  34467. Errors
  34468. ......
  34469.  
  34470. None.
  34471.  
  34472. 
  34473. File: mysql.info,  Node: mysql_connect,  Next: mysql_change_user,  Prev: mysql_close,  Up: C API functions
  34474.  
  34475. `mysql_connect()'
  34476. .................
  34477.  
  34478. `MYSQL *mysql_connect(MYSQL *mysql, const char *host, const char *user,
  34479. const char *passwd)'
  34480.  
  34481. Description
  34482. ...........
  34483.  
  34484. This function is deprecated.  It is preferable to use
  34485. `mysql_real_connect()' instead.
  34486.  
  34487. `mysql_connect()' attempts to establish a connection to a MySQL
  34488. database engine running on `host'.  `mysql_connect()' must complete
  34489. successfully before you can execute any of the other API functions,
  34490. with the exception of `mysql_get_client_info()'.
  34491.  
  34492. The meanings of the parameters are the same as for the corresponding
  34493. parameters for `mysql_real_connect()' with the difference that the
  34494. connection parameter may be `NULL'. In this case the C API allocates
  34495. memory for the connection structure automatically and frees it when you
  34496. call `mysql_close()'. The disadvantage of this approach is that you
  34497. can't retrieve an error message if the connection fails.  (To get error
  34498. information from `mysql_errno()' or `mysql_error()', you must provide a
  34499. valid `MYSQL' pointer.)
  34500.  
  34501. Return Values
  34502. .............
  34503.  
  34504. Same as for `mysql_real_connect()'.
  34505.  
  34506. Errors
  34507. ......
  34508.  
  34509. Same as for `mysql_real_connect()'.
  34510.  
  34511. 
  34512. File: mysql.info,  Node: mysql_change_user,  Next: mysql_character_set_name,  Prev: mysql_connect,  Up: C API functions
  34513.  
  34514. `mysql_change_user()'
  34515. .....................
  34516.  
  34517. `my_bool mysql_change_user(MYSQL *mysql, const char *user, const char
  34518. *password, const char *db)'
  34519.  
  34520. Description
  34521. ...........
  34522.  
  34523. Changes the user and causes the database specified by `db' to become
  34524. the default (current) database on the connection specified by `mysql'.
  34525. In subsequent queries, this database is the default for table
  34526. references that do not include an explicit database specifier.
  34527.  
  34528. This function was introduced in MySQL Version 3.23.3.
  34529.  
  34530. `mysql_change_user()' fails unless the connected user can be
  34531. authenticated or if he doesn't have permission to use the database.  In
  34532. this case the user and database are not changed
  34533.  
  34534. The `db' parameter may be set to `NULL' if you don't want to have a
  34535. default database.
  34536.  
  34537. Return values
  34538. .............
  34539.  
  34540. Zero for success.  Non-zero if an error occurred.
  34541.  
  34542. Errors
  34543. ......
  34544.  
  34545. The same that you can get from `mysql_real_connect()'.
  34546.  
  34547. `CR_COMMANDS_OUT_OF_SYNC'
  34548.      Commands were executed in an improper order.
  34549.  
  34550. `CR_SERVER_GONE_ERROR'
  34551.      The MySQL server has gone away.
  34552.  
  34553. `CR_SERVER_LOST'
  34554.      The connection to the server was lost during the query.
  34555.  
  34556. `CR_UNKNOWN_ERROR'
  34557.      An unknown error occurred.
  34558.  
  34559. `ER_UNKNOWN_COM_ERROR'
  34560.      The MySQL server doesn't implement this command (probably an old
  34561.      server)
  34562.  
  34563. `ER_ACCESS_DENIED_ERROR'
  34564.      The user or password was wrong.
  34565.  
  34566. `ER_BAD_DB_ERROR'
  34567.      The database didn't exist.
  34568.  
  34569. `ER_DBACCESS_DENIED_ERROR'
  34570.      The user did not have access rights to the database.
  34571.  
  34572. `ER_WRONG_DB_NAME'
  34573.      The database name was too long.
  34574.  
  34575. Example
  34576. .......
  34577.  
  34578.      if (mysql_change_user(&mysql, "user", "password", "new_database"))
  34579.      {
  34580.         fprintf(stderr, "Failed to change user.  Error: %s\n",
  34581.                 mysql_error(&mysql));
  34582.      }
  34583.  
  34584. 
  34585. File: mysql.info,  Node: mysql_character_set_name,  Next: mysql_create_db,  Prev: mysql_change_user,  Up: C API functions
  34586.  
  34587. `mysql_character_set_name()'
  34588. ............................
  34589.  
  34590. `const char *mysql_character_set_name(MYSQL *mysql)'
  34591.  
  34592. Description
  34593. ...........
  34594.  
  34595. Returns the default character set for the current connection.
  34596.  
  34597. Return Values
  34598. .............
  34599.  
  34600. The default character set
  34601.  
  34602. Errors
  34603. ......
  34604.  
  34605. None.
  34606.  
  34607. 
  34608. File: mysql.info,  Node: mysql_create_db,  Next: mysql_data_seek,  Prev: mysql_character_set_name,  Up: C API functions
  34609.  
  34610. `mysql_create_db()'
  34611. ...................
  34612.  
  34613. `int mysql_create_db(MYSQL *mysql, const char *db)'
  34614.  
  34615. Description
  34616. ...........
  34617.  
  34618. Creates the database named by the `db' parameter.
  34619.  
  34620. This function is deprecated.  It is preferable to use `mysql_query()'
  34621. to issue a SQL `CREATE DATABASE' statement instead.
  34622.  
  34623. Return Values
  34624. .............
  34625.  
  34626. Zero if the database was created successfully. Non-zero if an error
  34627. occurred.
  34628.  
  34629. Errors
  34630. ......
  34631.  
  34632. `CR_COMMANDS_OUT_OF_SYNC'
  34633.      Commands were executed in an improper order.
  34634.  
  34635. `CR_SERVER_GONE_ERROR'
  34636.      The MySQL server has gone away.
  34637.  
  34638. `CR_SERVER_LOST'
  34639.      The connection to the server was lost during the query.
  34640.  
  34641. `CR_UNKNOWN_ERROR'
  34642.      An unknown error occurred.
  34643.  
  34644. Example
  34645. .......
  34646.  
  34647.      if(mysql_create_db(&mysql, "my_database"))
  34648.      {
  34649.         fprintf(stderr, "Failed to create new database.  Error: %s\n",
  34650.                 mysql_error(&mysql));
  34651.      }
  34652.  
  34653. 
  34654. File: mysql.info,  Node: mysql_data_seek,  Next: mysql_debug,  Prev: mysql_create_db,  Up: C API functions
  34655.  
  34656. `mysql_data_seek()'
  34657. ...................
  34658.  
  34659. `void mysql_data_seek(MYSQL_RES *result, unsigned long long offset)'
  34660.  
  34661. Description
  34662. ...........
  34663.  
  34664. Seeks to an arbitrary row in a query result set.  This requires that the
  34665. result set structure contains the entire result of the query, so
  34666. `mysql_data_seek()' may be used in conjunction only with
  34667. `mysql_store_result()', not with `mysql_use_result()'.
  34668.  
  34669. The offset should be a value in the range from 0 to
  34670. `mysql_num_rows(result)-1'.
  34671.  
  34672. Return Values
  34673. .............
  34674.  
  34675. None.
  34676.  
  34677. Errors
  34678. ......
  34679.  
  34680. None.
  34681.  
  34682. 
  34683. File: mysql.info,  Node: mysql_debug,  Next: mysql_drop_db,  Prev: mysql_data_seek,  Up: C API functions
  34684.  
  34685. `mysql_debug()'
  34686. ...............
  34687.  
  34688. `void mysql_debug(char *debug)'
  34689.  
  34690. Description
  34691. ...........
  34692.  
  34693. Does a `DBUG_PUSH' with the given string. `mysql_debug()' uses the Fred
  34694. Fish debug library. To use this function, you must compile the client
  34695. library to support debugging.  *Note Debugging server::. *Note
  34696. Debugging client::.
  34697.  
  34698. Return Values
  34699. .............
  34700.  
  34701. None.
  34702.  
  34703. Errors
  34704. ......
  34705.  
  34706. None.
  34707.  
  34708. Example
  34709. .......
  34710.  
  34711. The call shown below causes the client library to generate a trace file
  34712. in `/tmp/client.trace' on the client machine:
  34713.  
  34714.      mysql_debug("d:t:O,/tmp/client.trace");
  34715.  
  34716. 
  34717. File: mysql.info,  Node: mysql_drop_db,  Next: mysql_dump_debug_info,  Prev: mysql_debug,  Up: C API functions
  34718.  
  34719. `mysql_drop_db()'
  34720. .................
  34721.  
  34722. `int mysql_drop_db(MYSQL *mysql, const char *db)'
  34723.  
  34724. Description
  34725. ...........
  34726.  
  34727. Drops the database named by the `db' parameter.
  34728.  
  34729. This function is deprecated.  It is preferable to use `mysql_query()'
  34730. to issue a SQL `DROP DATABASE' statement instead.
  34731.  
  34732. Return Values
  34733. .............
  34734.  
  34735. Zero if the database was dropped successfully. Non-zero if an error
  34736. occurred.
  34737.  
  34738. Errors
  34739. ......
  34740.  
  34741. `CR_COMMANDS_OUT_OF_SYNC'
  34742.      Commands were executed in an improper order.
  34743.  
  34744. `CR_SERVER_GONE_ERROR'
  34745.      The MySQL server has gone away.
  34746.  
  34747. `CR_SERVER_LOST'
  34748.      The connection to the server was lost during the query.
  34749.  
  34750. `CR_UNKNOWN_ERROR'
  34751.      An unknown error occurred.
  34752.  
  34753. Example
  34754. .......
  34755.  
  34756.      if(mysql_drop_db(&mysql, "my_database"))
  34757.        fprintf(stderr, "Failed to drop the database: Error: %s\n",
  34758.                mysql_error(&mysql));
  34759.  
  34760. 
  34761. File: mysql.info,  Node: mysql_dump_debug_info,  Next: mysql_eof,  Prev: mysql_drop_db,  Up: C API functions
  34762.  
  34763. `mysql_dump_debug_info()'
  34764. .........................
  34765.  
  34766. `int mysql_dump_debug_info(MYSQL *mysql)'
  34767.  
  34768. Description
  34769. ...........
  34770.  
  34771. Instructs the server to write some debug information to the log.  The
  34772. connected user must have the *process* privilege for this to work.
  34773.  
  34774. Return values
  34775. .............
  34776.  
  34777. Zero if the command was successful. Non-zero if an error occurred.
  34778.  
  34779. Errors
  34780. ......
  34781.  
  34782. `CR_COMMANDS_OUT_OF_SYNC'
  34783.      Commands were executed in an improper order.
  34784.  
  34785. `CR_SERVER_GONE_ERROR'
  34786.      The MySQL server has gone away.
  34787.  
  34788. `CR_SERVER_LOST'
  34789.      The connection to the server was lost during the query.
  34790.  
  34791. `CR_UNKNOWN_ERROR'
  34792.      An unknown error occurred.
  34793.  
  34794. 
  34795. File: mysql.info,  Node: mysql_eof,  Next: mysql_errno,  Prev: mysql_dump_debug_info,  Up: C API functions
  34796.  
  34797. `mysql_eof()'
  34798. .............
  34799.  
  34800. `my_bool mysql_eof(MYSQL_RES *result)'
  34801.  
  34802. Description
  34803. ...........
  34804.  
  34805. This function is deprecated.  `mysql_errno()' or `mysql_error()' may be
  34806. used instead.
  34807.  
  34808. `mysql_eof()' determines whether or not the last row of a result set
  34809. has been read.
  34810.  
  34811. If you acquire a result set from a successful call to
  34812. `mysql_store_result()', the client receives the entire set in one
  34813. operation.  In this case, a `NULL' return from `mysql_fetch_row()'
  34814. always means the end of the result set has been reached and it is
  34815. unnecessary to call `mysql_eof()'.
  34816.  
  34817. On the other hand, if you use `mysql_use_result()' to initiate a result
  34818. set retrieval, the rows of the set are obtained from the server one by
  34819. one as you call `mysql_fetch_row()' repeatedly.  Because an error may
  34820. occur on the connection during this process, a `NULL' return value from
  34821. `mysql_fetch_row()' does not necessarily mean the end of the result set
  34822. was reached normally.  In this case, you can use `mysql_eof()' to
  34823. determine what happened.  `mysql_eof()' returns a non-zero value if the
  34824. end of the result set was reached and zero if an error occurred.
  34825.  
  34826. Historically, `mysql_eof()' predates the standard MySQL error functions
  34827. `mysql_errno()' and `mysql_error()'.  Because those error functions
  34828. provide the same information, their use is preferred over
  34829. `mysql_eof()', which is now deprecated.  (In fact, they provide more
  34830. information, because `mysql_eof()' returns only a boolean value whereas
  34831. the error functions indicate a reason for the error when one occurs.)
  34832.  
  34833. Return Values
  34834. .............
  34835.  
  34836. Zero if no error occurred. Non-zero if the end of the result set has
  34837. been reached.
  34838.  
  34839. Errors
  34840. ......
  34841.  
  34842. None.
  34843.  
  34844. Example
  34845. .......
  34846.  
  34847. The following example shows how you might use `mysql_eof()':
  34848.  
  34849.      mysql_query(&mysql,"SELECT * FROM some_table");
  34850.      result = mysql_use_result(&mysql);
  34851.      while((row = mysql_fetch_row(result)))
  34852.      {
  34853.          // do something with data
  34854.      }
  34855.      if(!mysql_eof(result))  // mysql_fetch_row() failed due to an error
  34856.      {
  34857.          fprintf(stderr, "Error: %s\n", mysql_error(&mysql));
  34858.      }
  34859.  
  34860. However, you can achieve the same effect with the standard MySQL error
  34861. functions:
  34862.  
  34863.      mysql_query(&mysql,"SELECT * FROM some_table");
  34864.      result = mysql_use_result(&mysql);
  34865.      while((row = mysql_fetch_row(result)))
  34866.      {
  34867.          // do something with data
  34868.      }
  34869.      if(mysql_errno(&mysql))  // mysql_fetch_row() failed due to an error
  34870.      {
  34871.          fprintf(stderr, "Error: %s\n", mysql_error(&mysql));
  34872.      }
  34873.  
  34874. 
  34875. File: mysql.info,  Node: mysql_errno,  Next: mysql_error,  Prev: mysql_eof,  Up: C API functions
  34876.  
  34877. `mysql_errno()'
  34878. ...............
  34879.  
  34880. `unsigned int mysql_errno(MYSQL *mysql)'
  34881.  
  34882. Description
  34883. ...........
  34884.  
  34885. For the connection specified by `mysql', `mysql_errno()' returns the
  34886. error code for the most recently invoked API function that can succeed
  34887. or fail.  A return value of zero means that no error occurred. Client
  34888. error message numbers are listed in the MySQL `errmsg.h' header file.
  34889. Server error message numbers are listed in `mysqld_error.h'. In the
  34890. MySQL source distribution you can find a complete list of error
  34891. messages and error numbers in the file `Docs/mysqld_error.txt'.
  34892.  
  34893. Return Values
  34894. .............
  34895.  
  34896. An error code value. Zero if no error occurred.
  34897.  
  34898. Errors
  34899. ......
  34900.  
  34901. None.
  34902.  
  34903. 
  34904. File: mysql.info,  Node: mysql_error,  Next: mysql_escape_string,  Prev: mysql_errno,  Up: C API functions
  34905.  
  34906. `mysql_error()'
  34907. ...............
  34908.  
  34909. `char *mysql_error(MYSQL *mysql)'
  34910.  
  34911. Description
  34912. ...........
  34913.  
  34914. For the connection specified by `mysql', `mysql_error()' returns the
  34915. error message for the most recently invoked API function that can
  34916. succeed or fail.  An empty string (`""') is returned if no error
  34917. occurred.  This means the following two tests are equivalent:
  34918.  
  34919.      if(mysql_errno(&mysql))
  34920.      {
  34921.          // an error occurred
  34922.      }
  34923.      
  34924.      if(mysql_error(&mysql)[0] != '\0')
  34925.      {
  34926.          // an error occurred
  34927.      }
  34928.  
  34929. The language of the client error messages may be changed by recompiling
  34930. the MySQL client library. Currently you can choose error messages in
  34931. several different languages.  *Note Languages::.
  34932.  
  34933. Return Values
  34934. .............
  34935.  
  34936. A character string that describes the error.  An empty string if no
  34937. error occurred.
  34938.  
  34939. Errors
  34940. ......
  34941.  
  34942. None.
  34943.  
  34944. 
  34945. File: mysql.info,  Node: mysql_escape_string,  Next: mysql_fetch_field,  Prev: mysql_error,  Up: C API functions
  34946.  
  34947. `mysql_escape_string()'
  34948. .......................
  34949.  
  34950. You should use `mysql_real_escape_string()' instead!
  34951.  
  34952. This is identical to `mysql_real_escape_string()' except that it takes
  34953. the connection as the first argument. `mysql_real_escape_string()' will
  34954. escape the string according to the current character set while
  34955. `mysql_escape_string()' does not respect the current charset setting.
  34956.  
  34957. 
  34958. File: mysql.info,  Node: mysql_fetch_field,  Next: mysql_fetch_fields,  Prev: mysql_escape_string,  Up: C API functions
  34959.  
  34960. `mysql_fetch_field()'
  34961. .....................
  34962.  
  34963. `MYSQL_FIELD *mysql_fetch_field(MYSQL_RES *result)'
  34964.  
  34965. Description
  34966. ...........
  34967.  
  34968. Returns the definition of one column of a result set as a `MYSQL_FIELD'
  34969. structure. Call this function repeatedly to retrieve information about
  34970. all columns in the result set.  `mysql_fetch_field()' returns `NULL'
  34971. when no more fields are left.
  34972.  
  34973. `mysql_fetch_field()' is reset to return information about the first
  34974. field each time you execute a new `SELECT' query.  The field returned by
  34975. `mysql_fetch_field()' is also affected by calls to `mysql_field_seek()'.
  34976.  
  34977. If you've called `mysql_query()' to perform a `SELECT' on a table but
  34978. have not called `mysql_store_result()', MySQL returns the default blob
  34979. length (8K bytes) if you call `mysql_fetch_field()' to ask for the
  34980. length of a `BLOB' field.  (The 8K size is chosen because MySQL doesn't
  34981. know the maximum length for the `BLOB'. This should be made
  34982. configurable sometime.) Once you've retrieved the result set,
  34983. `field->max_length' contains the length of the largest value for this
  34984. column in the specific query.
  34985.  
  34986. Return Values
  34987. .............
  34988.  
  34989. The `MYSQL_FIELD' structure for the current column. `NULL' if no
  34990. columns are left.
  34991.  
  34992. Errors
  34993. ......
  34994.  
  34995. None.
  34996.  
  34997. Example
  34998. .......
  34999.  
  35000.      MYSQL_FIELD *field;
  35001.      
  35002.      while((field = mysql_fetch_field(result)))
  35003.      {
  35004.          printf("field name %s\n", field->name);
  35005.      }
  35006.  
  35007. 
  35008. File: mysql.info,  Node: mysql_fetch_fields,  Next: mysql_fetch_field_direct,  Prev: mysql_fetch_field,  Up: C API functions
  35009.  
  35010. `mysql_fetch_fields()'
  35011. ......................
  35012.  
  35013. `MYSQL_FIELD *mysql_fetch_fields(MYSQL_RES *result)'
  35014.  
  35015. Description
  35016. ...........
  35017.  
  35018. Returns an array of all `MYSQL_FIELD' structures for a result set.
  35019. Each structure provides the field definition for one column of the
  35020. result set.
  35021.  
  35022. Return Values
  35023. .............
  35024.  
  35025. An array of `MYSQL_FIELD' structures for all columns of a result set.
  35026.  
  35027. Errors
  35028. ......
  35029.  
  35030. None.
  35031.  
  35032. Example
  35033. .......
  35034.  
  35035.      unsigned int num_fields;
  35036.      unsigned int i;
  35037.      MYSQL_FIELD *fields;
  35038.      
  35039.      num_fields = mysql_num_fields(result);
  35040.      fields = mysql_fetch_fields(result);
  35041.      for(i = 0; i < num_fields; i++)
  35042.      {
  35043.         printf("Field %u is %s\n", i, fields[i].name);
  35044.      }
  35045.  
  35046. 
  35047. File: mysql.info,  Node: mysql_fetch_field_direct,  Next: mysql_fetch_lengths,  Prev: mysql_fetch_fields,  Up: C API functions
  35048.  
  35049. `mysql_fetch_field_direct()'
  35050. ............................
  35051.  
  35052. `MYSQL_FIELD *mysql_fetch_field_direct(MYSQL_RES *result, unsigned int
  35053. fieldnr)'
  35054.  
  35055. Description
  35056. ...........
  35057.  
  35058. Given a field number `fieldnr' for a column within a result set, returns
  35059. that column's field definition as a `MYSQL_FIELD' structure. You may use
  35060. this function to retrieve the definition for an arbitrary column.  The
  35061. value of `fieldnr' should be in the range from 0 to
  35062. `mysql_num_fields(result)-1'.
  35063.  
  35064. Return Values
  35065. .............
  35066.  
  35067. The `MYSQL_FIELD' structure for the specified column.
  35068.  
  35069. Errors
  35070. ......
  35071.  
  35072. None.
  35073.  
  35074. Example
  35075. .......
  35076.  
  35077.      unsigned int num_fields;
  35078.      unsigned int i;
  35079.      MYSQL_FIELD *field;
  35080.      
  35081.      num_fields = mysql_num_fields(result);
  35082.      for(i = 0; i < num_fields; i++)
  35083.      {
  35084.          field = mysql_fetch_field_direct(result, i);
  35085.          printf("Field %u is %s\n", i, field->name);
  35086.      }
  35087.  
  35088. 
  35089. File: mysql.info,  Node: mysql_fetch_lengths,  Next: mysql_fetch_row,  Prev: mysql_fetch_field_direct,  Up: C API functions
  35090.  
  35091. `mysql_fetch_lengths()'
  35092. .......................
  35093.  
  35094. `unsigned long *mysql_fetch_lengths(MYSQL_RES *result)'
  35095.  
  35096. Description
  35097. ...........
  35098.  
  35099. Returns the lengths of the columns of the current row within a result
  35100. set.  If you plan to copy field values, this length information is also
  35101. useful for optimization, because you can avoid calling `strlen()'.  In
  35102. addition, if the result set contains binary data, you _must_ use this
  35103. function to determine the size of the data, because `strlen()' returns
  35104. incorrect results for any field containing null characters.
  35105.  
  35106. The length for empty columns and for columns containing `NULL' values is
  35107. zero.  To see how to distinguish these two cases, see the description
  35108. for `mysql_fetch_row()'.
  35109.  
  35110. Return Values
  35111. .............
  35112.  
  35113. An array of unsigned long integers representing the size of each column
  35114. (not including any terminating null characters).  `NULL' if an error
  35115. occurred.
  35116.  
  35117. Errors
  35118. ......
  35119.  
  35120. `mysql_fetch_lengths()' is valid only for the current row of the result
  35121. set.  It returns `NULL' if you call it before calling
  35122. `mysql_fetch_row()' or after retrieving all rows in the result.
  35123.  
  35124. Example
  35125. .......
  35126.  
  35127.      MYSQL_ROW row;
  35128.      unsigned long *lengths;
  35129.      unsigned int num_fields;
  35130.      unsigned int i;
  35131.      
  35132.      row = mysql_fetch_row(result);
  35133.      if (row)
  35134.      {
  35135.          num_fields = mysql_num_fields(result);
  35136.          lengths = mysql_fetch_lengths(result);
  35137.          for(i = 0; i < num_fields; i++)
  35138.          {
  35139.               printf("Column %u is %lu bytes in length.\n", i, lengths[i]);
  35140.          }
  35141.      }
  35142.  
  35143. 
  35144. File: mysql.info,  Node: mysql_fetch_row,  Next: mysql_field_count,  Prev: mysql_fetch_lengths,  Up: C API functions
  35145.  
  35146. `mysql_fetch_row()'
  35147. ...................
  35148.  
  35149. `MYSQL_ROW mysql_fetch_row(MYSQL_RES *result)'
  35150.  
  35151. Description
  35152. ...........
  35153.  
  35154. Retrieves the next row of a result set. When used after
  35155. `mysql_store_result()', `mysql_fetch_row()' returns `NULL' when there
  35156. are no more rows to retrieve.  When used after `mysql_use_result()',
  35157. `mysql_fetch_row()' returns `NULL' when there are no more rows to
  35158. retrieve or if an error occurred.
  35159.  
  35160. The number of values in the row is given by `mysql_num_fields(result)'.
  35161. If `row' holds the return value from a call to `mysql_fetch_row()',
  35162. pointers to the values are accessed as `row[0]' to
  35163. `row[mysql_num_fields(result)-1]'.  `NULL' values in the row are
  35164. indicated by `NULL' pointers.
  35165.  
  35166. The lengths of the field values in the row may be obtained by calling
  35167. `mysql_fetch_lengths()'.  Empty fields and fields containing `NULL'
  35168. both have length 0; you can distinguish these by checking the pointer
  35169. for the field value.  If the pointer is `NULL', the field is `NULL';
  35170. otherwise the field is empty.
  35171.  
  35172. Return Values
  35173. .............
  35174.  
  35175. A `MYSQL_ROW' structure for the next row.  `NULL' if there are no more
  35176. rows to retrieve or if an error occurred.
  35177.  
  35178. Errors
  35179. ......
  35180.  
  35181. `CR_SERVER_LOST'
  35182.      The connection to the server was lost during the query.
  35183.  
  35184. `CR_UNKNOWN_ERROR'
  35185.      An unknown error occurred.
  35186.  
  35187. Example
  35188. .......
  35189.  
  35190.      MYSQL_ROW row;
  35191.      unsigned int num_fields;
  35192.      unsigned int i;
  35193.      
  35194.      num_fields = mysql_num_fields(result);
  35195.      while ((row = mysql_fetch_row(result)))
  35196.      {
  35197.         unsigned long *lengths;
  35198.         lengths = mysql_fetch_lengths(result);
  35199.         for(i = 0; i < num_fields; i++)
  35200.         {
  35201.             printf("[%.*s] ", (int) lengths[i], row[i] ? row[i] : "NULL");
  35202.         }
  35203.         printf("\n");
  35204.      }
  35205.  
  35206. 
  35207. File: mysql.info,  Node: mysql_field_count,  Next: mysql_field_seek,  Prev: mysql_fetch_row,  Up: C API functions
  35208.  
  35209. `mysql_field_count()'
  35210. .....................
  35211.  
  35212. `unsigned int mysql_field_count(MYSQL *mysql)'
  35213.  
  35214. If you are using a version of MySQL earlier than Version 3.22.24, you
  35215. should use `unsigned int mysql_num_fields(MYSQL *mysql)' instead.
  35216.  
  35217. Description
  35218. ...........
  35219.  
  35220. Returns the number of columns for the most recent query on the
  35221. connection.
  35222.  
  35223. The normal use of this function is when `mysql_store_result()' returned
  35224. `NULL' (and thus you have no result set pointer).  In this case, you
  35225. can call `mysql_field_count()' to determine whether or not
  35226. `mysql_store_result()' should have produced a non-empty result.  This
  35227. allows the client program to take proper action without knowing whether
  35228. or not the query was a `SELECT' (or `SELECT'-like) statement.  The
  35229. example shown below illustrates how this may be done.
  35230.  
  35231. *Note `NULL mysql_store_result()': NULL mysql_store_result.
  35232.  
  35233. Return Values
  35234. .............
  35235.  
  35236. An unsigned integer representing the number of fields in a result set.
  35237.  
  35238. Errors
  35239. ......
  35240.  
  35241. None.
  35242.  
  35243. Example
  35244. .......
  35245.  
  35246.      MYSQL_RES *result;
  35247.      unsigned int num_fields;
  35248.      unsigned int num_rows;
  35249.      
  35250.      if (mysql_query(&mysql,query_string))
  35251.      {
  35252.          // error
  35253.      }
  35254.      else // query succeeded, process any data returned by it
  35255.      {
  35256.          result = mysql_store_result(&mysql);
  35257.          if (result)  // there are rows
  35258.          {
  35259.              num_fields = mysql_num_fields(result);
  35260.              // retrieve rows, then call mysql_free_result(result)
  35261.          }
  35262.          else  // mysql_store_result() returned nothing; should it have?
  35263.          {
  35264.              if(mysql_field_count(&mysql) == 0)
  35265.              {
  35266.                  // query does not return data
  35267.                  // (it was not a SELECT)
  35268.                  num_rows = mysql_affected_rows(&mysql);
  35269.              }
  35270.              else // mysql_store_result() should have returned data
  35271.              {
  35272.                  fprintf(stderr, "Error: %s\n", mysql_error(&mysql));
  35273.              }
  35274.          }
  35275.      }
  35276.  
  35277. An alternative is to replace the `mysql_field_count(&mysql)' call with
  35278. `mysql_errno(&mysql)'.  In this case, you are checking directly for an
  35279. error from `mysql_store_result()' rather than inferring from the value
  35280. of `mysql_field_count()' whether or not the statement was a `SELECT'.
  35281.  
  35282. 
  35283. File: mysql.info,  Node: mysql_field_seek,  Next: mysql_field_tell,  Prev: mysql_field_count,  Up: C API functions
  35284.  
  35285. `mysql_field_seek()'
  35286. ....................
  35287.  
  35288. `MYSQL_FIELD_OFFSET mysql_field_seek(MYSQL_RES *result,
  35289. MYSQL_FIELD_OFFSET offset)'
  35290.  
  35291. * Threaded clients::         How to Make a Threaded Client
  35292.  
  35293. Description
  35294. ...........
  35295.  
  35296. Sets the field cursor to the given offset.   The next call to
  35297. `mysql_fetch_field()' will retrieve the field definition of the column
  35298. associated with that offset.
  35299.  
  35300. To seek to the beginning of a row, pass an `offset' value of zero.
  35301.  
  35302. Return Values
  35303. .............
  35304.  
  35305. The previous value of the field cursor.
  35306.  
  35307. Errors
  35308. ......
  35309.  
  35310. None.
  35311.  
  35312. 
  35313. File: mysql.info,  Node: mysql_field_tell,  Next: mysql_free_result,  Prev: mysql_field_seek,  Up: C API functions
  35314.  
  35315. `mysql_field_tell()'
  35316. ....................
  35317.  
  35318. `MYSQL_FIELD_OFFSET mysql_field_tell(MYSQL_RES *result)'
  35319.  
  35320. Description
  35321. ...........
  35322.  
  35323. Returns the position of the field cursor used for the last
  35324. `mysql_fetch_field()'. This value can be used as an argument to
  35325. `mysql_field_seek()'.
  35326.  
  35327. Return Values
  35328. .............
  35329.  
  35330. The current offset of the field cursor.
  35331.  
  35332. Errors
  35333. ......
  35334.  
  35335. None.
  35336.  
  35337. 
  35338. File: mysql.info,  Node: mysql_free_result,  Next: mysql_get_client_info,  Prev: mysql_field_tell,  Up: C API functions
  35339.  
  35340. `mysql_free_result()'
  35341. .....................
  35342.  
  35343. `void mysql_free_result(MYSQL_RES *result)'
  35344.  
  35345. Description
  35346. ...........
  35347.  
  35348. Frees the memory allocated for a result set by `mysql_store_result()',
  35349. `mysql_use_result()', `mysql_list_dbs()', etc.  When you are done with
  35350. a result set, you must free the memory it uses by calling
  35351. `mysql_free_result()'.
  35352.  
  35353. Return Values
  35354. .............
  35355.  
  35356. None.
  35357.  
  35358. Errors
  35359. ......
  35360.  
  35361. None.
  35362.  
  35363. 
  35364. File: mysql.info,  Node: mysql_get_client_info,  Next: mysql_get_host_info,  Prev: mysql_free_result,  Up: C API functions
  35365.  
  35366. `mysql_get_client_info()'
  35367. .........................
  35368.  
  35369. `char *mysql_get_client_info(void)'
  35370.  
  35371. Description
  35372. ...........
  35373.  
  35374. Returns a string that represents the client library version.
  35375.  
  35376. Return Values
  35377. .............
  35378.  
  35379. A character string that represents the MySQL client library version.
  35380.  
  35381. Errors
  35382. ......
  35383.  
  35384. None.
  35385.  
  35386. 
  35387. File: mysql.info,  Node: mysql_get_host_info,  Next: mysql_get_proto_info,  Prev: mysql_get_client_info,  Up: C API functions
  35388.  
  35389. `mysql_get_host_info()'
  35390. .......................
  35391.  
  35392. `char *mysql_get_host_info(MYSQL *mysql)'
  35393.  
  35394. Description
  35395. ...........
  35396.  
  35397. Returns a string describing the type of connection in use, including the
  35398. server host name.
  35399.  
  35400. Return Values
  35401. .............
  35402.  
  35403. A character string representing the server host name and the connection
  35404. type.
  35405.  
  35406. Errors
  35407. ......
  35408.  
  35409. None.
  35410.  
  35411. 
  35412. File: mysql.info,  Node: mysql_get_proto_info,  Next: mysql_get_server_info,  Prev: mysql_get_host_info,  Up: C API functions
  35413.  
  35414. `mysql_get_proto_info()'
  35415. ........................
  35416.  
  35417. `unsigned int mysql_get_proto_info(MYSQL *mysql)'
  35418.  
  35419. Description
  35420. ...........
  35421.  
  35422. Returns the protocol version used by current connection.
  35423.  
  35424. Return Values
  35425. .............
  35426.  
  35427. An unsigned integer representing the protocol version used by the
  35428. current connection.
  35429.  
  35430. Errors
  35431. ......
  35432.  
  35433. None.
  35434.  
  35435. 
  35436. File: mysql.info,  Node: mysql_get_server_info,  Next: mysql_info,  Prev: mysql_get_proto_info,  Up: C API functions
  35437.  
  35438. `mysql_get_server_info()'
  35439. .........................
  35440.  
  35441. `char *mysql_get_server_info(MYSQL *mysql)'
  35442.  
  35443. Description
  35444. ...........
  35445.  
  35446. Returns a string that represents the server version number.
  35447.  
  35448. Return Values
  35449. .............
  35450.  
  35451. A character string that represents the server version number.
  35452.  
  35453. Errors
  35454. ......
  35455.  
  35456. None.
  35457.  
  35458. 
  35459. File: mysql.info,  Node: mysql_info,  Next: mysql_init,  Prev: mysql_get_server_info,  Up: C API functions
  35460.  
  35461. `mysql_info()'
  35462. ..............
  35463.  
  35464. `char *mysql_info(MYSQL *mysql)'
  35465.  
  35466. Description
  35467. ...........
  35468.  
  35469. Retrieves a string providing information about the most recently
  35470. executed query, but only for the statements listed below.  For other
  35471. statements, `mysql_info()' returns `NULL'.  The format of the string
  35472. varies depending on the type of query, as described below.  The numbers
  35473. are illustrative only; the string will contain values appropriate for
  35474. the query.
  35475.  
  35476. `INSERT INTO ... SELECT ...'
  35477.      String format: `Records: 100 Duplicates: 0 Warnings: 0'
  35478.  
  35479. `INSERT INTO ... VALUES (...),(...),(...)...'
  35480.      String format: `Records: 3  Duplicates: 0  Warnings: 0'
  35481.  
  35482. `LOAD DATA INFILE ...'
  35483.      String format: `Records: 1 Deleted: 0 Skipped: 0 Warnings: 0'
  35484.  
  35485. `ALTER TABLE'
  35486.      String format: `Records: 3 Duplicates: 0 Warnings: 0'
  35487.  
  35488. `UPDATE'
  35489.      String format: `Rows matched: 40 Changed: 40 Warnings: 0'
  35490.  
  35491. Note that `mysql_info()' returns a non-`NULL' value for the `INSERT ...
  35492. VALUES' statement only if multiple value lists are specified in the
  35493. statement.
  35494.  
  35495. Return Values
  35496. .............
  35497.  
  35498. A character string representing additional information about the most
  35499. recently executed query.  `NULL' if no information is available for the
  35500. query.
  35501.  
  35502. Errors
  35503. ......
  35504.  
  35505. None.
  35506.  
  35507. 
  35508. File: mysql.info,  Node: mysql_init,  Next: mysql_insert_id,  Prev: mysql_info,  Up: C API functions
  35509.  
  35510. `mysql_init()'
  35511. ..............
  35512.  
  35513. `MYSQL *mysql_init(MYSQL *mysql)'
  35514.  
  35515. Description
  35516. ...........
  35517.  
  35518. Allocates or initializes a `MYSQL' object suitable for
  35519. `mysql_real_connect()'.  If `mysql' is a `NULL' pointer, the function
  35520. allocates, initializes, and returns a new object.  Otherwise the object
  35521. is initialized and the address of the object is returned.  If
  35522. `mysql_init()' allocates a new object, it will be freed when
  35523. `mysql_close()' is called to close the connection.
  35524.  
  35525. Return Values
  35526. .............
  35527.  
  35528. An initialized `MYSQL*' handle.  `NULL' if there was insufficient
  35529. memory to allocate a new object.
  35530.  
  35531. Errors
  35532. ......
  35533.  
  35534. In case of insufficient memory, `NULL' is returned.
  35535.  
  35536. 
  35537. File: mysql.info,  Node: mysql_insert_id,  Next: mysql_kill,  Prev: mysql_init,  Up: C API functions
  35538.  
  35539. `mysql_insert_id()'
  35540. ...................
  35541.  
  35542. `my_ulonglong mysql_insert_id(MYSQL *mysql)'
  35543.  
  35544. Description
  35545. ...........
  35546.  
  35547. Returns the ID generated for an `AUTO_INCREMENT' column by the previous
  35548. query.  Use this function after you have performed an `INSERT' query
  35549. into a table that contains an `AUTO_INCREMENT' field.
  35550.  
  35551. Note that `mysql_insert_id()' returns `0' if the previous query does
  35552. not generate an `AUTO_INCREMENT' value.  If you need to save the value
  35553. for later, be sure to call `mysql_insert_id()' immediately after the
  35554. query that generates the value.
  35555.  
  35556. `mysql_insert_id()' is updated after `INSERT' and `UPDATE' statements
  35557. that generate an `AUTO_INCREMENT' value or that set a column value to
  35558. `LAST_INSERT_ID(expr)'.  *Note Miscellaneous functions::.
  35559.  
  35560. Also note that the value of the SQL `LAST_INSERT_ID()' function always
  35561. contains the most recently generated `AUTO_INCREMENT' value, and is not
  35562. reset between queries because the value of that function is maintained
  35563. in the server.
  35564.  
  35565. Return Values
  35566. .............
  35567.  
  35568. The value of the `AUTO_INCREMENT' field that was updated by the previous
  35569. query.  Returns zero if there was no previous query on the connection
  35570. or if the query did not update an `AUTO_INCREMENT' value.
  35571.  
  35572. Errors
  35573. ......
  35574.  
  35575. None.
  35576.  
  35577. 
  35578. File: mysql.info,  Node: mysql_kill,  Next: mysql_list_dbs,  Prev: mysql_insert_id,  Up: C API functions
  35579.  
  35580. `mysql_kill()'
  35581. ..............
  35582.  
  35583. `int mysql_kill(MYSQL *mysql, unsigned long pid)'
  35584.  
  35585. Description
  35586. ...........
  35587.  
  35588. Asks the server to kill the thread specified by `pid'.
  35589.  
  35590. Return Values
  35591. .............
  35592.  
  35593. Zero for success.  Non-zero if an error occurred.
  35594.  
  35595. Errors
  35596. ......
  35597.  
  35598. `CR_COMMANDS_OUT_OF_SYNC'
  35599.      Commands were executed in an improper order.
  35600.  
  35601. `CR_SERVER_GONE_ERROR'
  35602.      The MySQL server has gone away.
  35603.  
  35604. `CR_SERVER_LOST'
  35605.      The connection to the server was lost during the query.
  35606.  
  35607. `CR_UNKNOWN_ERROR'
  35608.      An unknown error occurred.
  35609.  
  35610. 
  35611. File: mysql.info,  Node: mysql_list_dbs,  Next: mysql_list_fields,  Prev: mysql_kill,  Up: C API functions
  35612.  
  35613. `mysql_list_dbs()'
  35614. ..................
  35615.  
  35616. `MYSQL_RES *mysql_list_dbs(MYSQL *mysql, const char *wild)'
  35617.  
  35618. Description
  35619. ...........
  35620.  
  35621. Returns a result set consisting of database names on the server that
  35622. match the simple regular expression specified by the `wild' parameter.
  35623. `wild' may contain the wild-card characters `%' or `_', or may be a
  35624. `NULL' pointer to match all databases.  Calling `mysql_list_dbs()' is
  35625. similar to executing the query `SHOW databases [LIKE wild]'.
  35626.  
  35627. You must free the result set with `mysql_free_result()'.
  35628.  
  35629. Return Values
  35630. .............
  35631.  
  35632. A `MYSQL_RES' result set for success.  `NULL' if an error occurred.
  35633.  
  35634. Errors
  35635. ......
  35636.  
  35637. `CR_COMMANDS_OUT_OF_SYNC'
  35638.      Commands were executed in an improper order.
  35639.  
  35640. `CR_OUT_OF_MEMORY'
  35641.      Out of memory.
  35642.  
  35643. `CR_SERVER_GONE_ERROR'
  35644.      The MySQL server has gone away.
  35645.  
  35646. `CR_SERVER_LOST'
  35647.      The connection to the server was lost during the query.
  35648.  
  35649. `CR_UNKNOWN_ERROR'
  35650.      An unknown error occurred.
  35651.  
  35652. 
  35653. File: mysql.info,  Node: mysql_list_fields,  Next: mysql_list_processes,  Prev: mysql_list_dbs,  Up: C API functions
  35654.  
  35655. `mysql_list_fields()'
  35656. .....................
  35657.  
  35658. `MYSQL_RES *mysql_list_fields(MYSQL *mysql, const char *table, const
  35659. char *wild)'
  35660.  
  35661. Description
  35662. ...........
  35663.  
  35664. Returns a result set consisting of field names in the given table that
  35665. match the simple regular expression specified by the `wild' parameter.
  35666. `wild' may contain the wild-card characters `%' or `_', or may be a
  35667. `NULL' pointer to match all fields.  Calling `mysql_list_fields()' is
  35668. similar to executing the query `SHOW COLUMNS FROM tbl_name [LIKE wild]'.
  35669.  
  35670. Note that it's recommended that you use `SHOW COLUMNS FROM tbl_name'
  35671. instead of `mysql_list_fields()'.
  35672.  
  35673. You must free the result set with `mysql_free_result()'.
  35674.  
  35675. Return Values
  35676. .............
  35677.  
  35678. A `MYSQL_RES' result set for success.  `NULL' if an error occurred.
  35679.  
  35680. Errors
  35681. ......
  35682.  
  35683. `CR_COMMANDS_OUT_OF_SYNC'
  35684.      Commands were executed in an improper order.
  35685.  
  35686. `CR_SERVER_GONE_ERROR'
  35687.      The MySQL server has gone away.
  35688.  
  35689. `CR_SERVER_LOST'
  35690.      The connection to the server was lost during the query.
  35691.  
  35692. `CR_UNKNOWN_ERROR'
  35693.      An unknown error occurred.
  35694.  
  35695. 
  35696. File: mysql.info,  Node: mysql_list_processes,  Next: mysql_list_tables,  Prev: mysql_list_fields,  Up: C API functions
  35697.  
  35698. `mysql_list_processes()'
  35699. ........................
  35700.  
  35701. `MYSQL_RES *mysql_list_processes(MYSQL *mysql)'
  35702.  
  35703. Description
  35704. ...........
  35705.  
  35706. Returns a result set describing the current server threads.  This is
  35707. the same kind of information as that reported by `mysqladmin
  35708. processlist' or a `SHOW PROCESSLIST' query.
  35709.  
  35710. You must free the result set with `mysql_free_result()'.
  35711.  
  35712. Return Values
  35713. .............
  35714.  
  35715. A `MYSQL_RES' result set for success.  `NULL' if an error occurred.
  35716.  
  35717. Errors
  35718. ......
  35719.  
  35720. `CR_COMMANDS_OUT_OF_SYNC'
  35721.      Commands were executed in an improper order.
  35722.  
  35723. `CR_SERVER_GONE_ERROR'
  35724.      The MySQL server has gone away.
  35725.  
  35726. `CR_SERVER_LOST'
  35727.      The connection to the server was lost during the query.
  35728.  
  35729. `CR_UNKNOWN_ERROR'
  35730.      An unknown error occurred.
  35731.  
  35732. 
  35733. File: mysql.info,  Node: mysql_list_tables,  Next: mysql_num_fields,  Prev: mysql_list_processes,  Up: C API functions
  35734.  
  35735. `mysql_list_tables()'
  35736. .....................
  35737.  
  35738. `MYSQL_RES *mysql_list_tables(MYSQL *mysql, const char *wild)'
  35739.  
  35740. Description
  35741. ...........
  35742.  
  35743. Returns a result set consisting of table names in the current database
  35744. that match the simple regular expression specified by the `wild'
  35745. parameter.  `wild' may contain the wild-card characters `%' or `_', or
  35746. may be a `NULL' pointer to match all tables.  Calling
  35747. `mysql_list_tables()' is similar to executing the query `SHOW tables
  35748. [LIKE wild]'.
  35749.  
  35750. You must free the result set with `mysql_free_result()'.
  35751.  
  35752. Return Values
  35753. .............
  35754.  
  35755. A `MYSQL_RES' result set for success.  `NULL' if an error occurred.
  35756.  
  35757. Errors
  35758. ......
  35759.  
  35760. `CR_COMMANDS_OUT_OF_SYNC'
  35761.      Commands were executed in an improper order.
  35762.  
  35763. `CR_SERVER_GONE_ERROR'
  35764.      The MySQL server has gone away.
  35765.  
  35766. `CR_SERVER_LOST'
  35767.      The connection to the server was lost during the query.
  35768.  
  35769. `CR_UNKNOWN_ERROR'
  35770.      An unknown error occurred.
  35771.  
  35772. 
  35773. File: mysql.info,  Node: mysql_num_fields,  Next: mysql_num_rows,  Prev: mysql_list_tables,  Up: C API functions
  35774.  
  35775. `mysql_num_fields()'
  35776. ....................
  35777.  
  35778. `unsigned int mysql_num_fields(MYSQL_RES *result)'
  35779.  
  35780. or
  35781.  
  35782. `unsigned int mysql_num_fields(MYSQL *mysql)'
  35783.  
  35784. The second form doesn't work on MySQL Version 3.22.24 or newer.  To
  35785. pass a `MYSQL*' argument, you must use `unsigned int
  35786. mysql_field_count(MYSQL *mysql)' instead.
  35787.  
  35788. Description
  35789. ...........
  35790.  
  35791. Returns the number of columns in a result set.
  35792.  
  35793. Note that you can get the number of columns either from a pointer to a
  35794. result set or to a connection handle.  You would use the connection
  35795. handle if `mysql_store_result()' or `mysql_use_result()' returned
  35796. `NULL' (and thus you have no result set pointer).  In this case, you can
  35797. call `mysql_field_count()' to determine whether or not
  35798. `mysql_store_result()' should have produced a non-empty result.  This
  35799. allows the client program to take proper action without knowing whether
  35800. or not the query was a `SELECT' (or `SELECT'-like) statement.  The
  35801. example shown below illustrates how this may be done.
  35802.  
  35803. *Note `NULL mysql_store_result()': NULL mysql_store_result.
  35804.  
  35805. Return Values
  35806. .............
  35807.  
  35808. An unsigned integer representing the number of fields in a result set.
  35809.  
  35810. Errors
  35811. ......
  35812.  
  35813. None.
  35814.  
  35815. Example
  35816. .......
  35817.  
  35818.      MYSQL_RES *result;
  35819.      unsigned int num_fields;
  35820.      unsigned int num_rows;
  35821.      
  35822.      if (mysql_query(&mysql,query_string))
  35823.      {
  35824.          // error
  35825.      }
  35826.      else // query succeeded, process any data returned by it
  35827.      {
  35828.          result = mysql_store_result(&mysql);
  35829.          if (result)  // there are rows
  35830.          {
  35831.              num_fields = mysql_num_fields(result);
  35832.              // retrieve rows, then call mysql_free_result(result)
  35833.          }
  35834.          else  // mysql_store_result() returned nothing; should it have?
  35835.          {
  35836.              if (mysql_errno(&mysql))
  35837.          {
  35838.                 fprintf(stderr, "Error: %s\n", mysql_error(&mysql));
  35839.          }
  35840.              else if (mysql_field_count(&mysql) == 0)
  35841.              {
  35842.                  // query does not return data
  35843.                  // (it was not a SELECT)
  35844.                  num_rows = mysql_affected_rows(&mysql);
  35845.              }
  35846.          }
  35847.      }
  35848.  
  35849. An alternative (if you KNOW that your query should have returned a
  35850. result set) is to replace the `mysql_errno(&mysql)' call with a check if
  35851. `mysql_field_count(&mysql)' is = 0.  This will only happen if something
  35852. went wrong.
  35853.  
  35854. 
  35855. File: mysql.info,  Node: mysql_num_rows,  Next: mysql_options,  Prev: mysql_num_fields,  Up: C API functions
  35856.  
  35857. `mysql_num_rows()'
  35858. ..................
  35859.  
  35860. `my_ulonglong mysql_num_rows(MYSQL_RES *result)'
  35861.  
  35862. Description
  35863. ...........
  35864.  
  35865. Returns the number of rows in the result set.
  35866.  
  35867. The use of `mysql_num_rows()' depends on whether you use
  35868. `mysql_store_result()' or `mysql_use_result()' to return the result
  35869. set.  If you use `mysql_store_result()', `mysql_num_rows()' may be
  35870. called immediately.  If you use `mysql_use_result()',
  35871. `mysql_num_rows()' will not return the correct value until all the rows
  35872. in the result set have been retrieved.
  35873.  
  35874. Return Values
  35875. .............
  35876.  
  35877. The number of rows in the result set.
  35878.  
  35879. Errors
  35880. ......
  35881.  
  35882. None.
  35883.  
  35884. 
  35885. File: mysql.info,  Node: mysql_options,  Next: mysql_ping,  Prev: mysql_num_rows,  Up: C API functions
  35886.  
  35887. `mysql_options()'
  35888. .................
  35889.  
  35890. `int mysql_options(MYSQL *mysql, enum mysql_option option, const char
  35891. *arg)'
  35892.  
  35893. Description
  35894. ...........
  35895.  
  35896. Can be used to set extra connect options and affect behavior for a
  35897. connection.  This function may be called multiple times to set several
  35898. options.
  35899.  
  35900. `mysql_options()' should be called after `mysql_init()' and before
  35901. `mysql_connect()' or `mysql_real_connect()'.
  35902.  
  35903. The `option' argument is the option that you want to set; the `arg'
  35904. argument is the value for the option. If the option is an integer, then
  35905. `arg' should point to the value of the integer.
  35906.  
  35907. Possible options values:
  35908.  
  35909. *Option*           *Argument type*    *Function*
  35910. `MYSQL_OPT_CONNECT_TIMEOUT'`unsigned int *'   Connect timeout in seconds.
  35911. `MYSQL_OPT_COMPRESS'Not used           Use the compressed client/server
  35912.                                       protocol.
  35913. `MYSQL_OPT_NAMED_PIPE'Not used           Use named pipes to connect to a
  35914.                                       MySQL server on NT.
  35915. `MYSQL_INIT_COMMAND'`char *'           Command to execute when connecting
  35916.                                       to the MySQL server. Will
  35917.                                       automatically be re-executed when
  35918.                                       reconnecting.
  35919. `MYSQL_READ_DEFAULT_FILE'`char *'           Read options from the named option
  35920.                                       file instead of from `my.cnf'.
  35921. `MYSQL_READ_DEFAULT_GROUP'`char *'           Read options from the named group
  35922.                                       from `my.cnf' or the file specified
  35923.                                       with `MYSQL_READ_DEFAULT_FILE'.
  35924.  
  35925. Note that the group `client' is always read if you use
  35926. `MYSQL_READ_DEFAULT_FILE' or `MYSQL_READ_DEFAULT_GROUP'.
  35927.  
  35928. The specified group in the option file may contain the following
  35929. options:
  35930.  
  35931. `connect_timeout'      Connect timeout in seconds. On Linux this timeout
  35932.                        is also used for waiting for the first answer
  35933.                        from the server.
  35934. `compress'             Use the compressed client/server protocol.
  35935. `database'             Connect to this database if no database was
  35936.                        specified in the connect command.
  35937. `debug'                Debug options.
  35938. `host'                 Default host name.
  35939. `init-command'         Command to execute when connecting to MySQL
  35940.                        server. Will automatically be re-executed when
  35941.                        reconnecting.
  35942. `interactive-timeout'  Same as specifying `CLIENT_INTERACTIVE' to
  35943.                        `mysql_real_connect()'. *Note
  35944.                        mysql_real_connect::.
  35945. `password'             Default password.
  35946. `pipe'                 Use named pipes to connect to a MySQL server on
  35947.                        NT.
  35948. `port'                 Default port number.
  35949. `return-found-rows'    Tell `mysql_info()' to return found rows instead
  35950.                        of updated rows when using `UPDATE'.
  35951. `socket'               Default socket number.
  35952.  
  35953. `user'                 Default user.
  35954.  
  35955. Note that `timeout' has been replaced by `connect_timeout', but
  35956. `timeout' will still work for a while.
  35957.  
  35958. For more information about option files, see *Note Option files::.
  35959.  
  35960. Return Values
  35961. .............
  35962.  
  35963. Zero for success.  Non-zero if you used an unknown option.
  35964.  
  35965. Example
  35966. .......
  35967.  
  35968.      MYSQL mysql;
  35969.      
  35970.      mysql_init(&mysql);
  35971.      mysql_options(&mysql,MYSQL_OPT_COMPRESS,0);
  35972.      mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"odbc");
  35973.      if (!mysql_real_connect(&mysql,"host","user","passwd","database",0,NULL,0))
  35974.      {
  35975.          fprintf(stderr, "Failed to connect to database: Error: %s\n",
  35976.                mysql_error(&mysql));
  35977.      }
  35978.  
  35979. The above requests the client to use the compressed client/server
  35980. protocol and read the additional options from the `odbc' section in the
  35981. `my.cnf' file.
  35982.  
  35983. 
  35984. File: mysql.info,  Node: mysql_ping,  Next: mysql_query,  Prev: mysql_options,  Up: C API functions
  35985.  
  35986. `mysql_ping()'
  35987. ..............
  35988.  
  35989. `int mysql_ping(MYSQL *mysql)'
  35990.  
  35991. Description
  35992. ...........
  35993.  
  35994. Checks whether or not the connection to the server is working. If it
  35995. has gone down, an automatic reconnection is attempted.
  35996.  
  35997. This function can be used by clients that remain idle for a long while,
  35998. to check whether or not the server has closed the connection and
  35999. reconnect if necessary.
  36000.  
  36001. Return Values
  36002. .............
  36003.  
  36004. Zero if the server is alive. Non-zero if an error occurred.
  36005.  
  36006. Errors
  36007. ......
  36008.  
  36009. `CR_COMMANDS_OUT_OF_SYNC'
  36010.      Commands were executed in an improper order.
  36011.  
  36012. `CR_SERVER_GONE_ERROR'
  36013.      The MySQL server has gone away.
  36014.  
  36015. `CR_UNKNOWN_ERROR'
  36016.      An unknown error occurred.
  36017.  
  36018. 
  36019. File: mysql.info,  Node: mysql_query,  Next: mysql_real_connect,  Prev: mysql_ping,  Up: C API functions
  36020.  
  36021. `mysql_query()'
  36022. ...............
  36023.  
  36024. `int mysql_query(MYSQL *mysql, const char *query)'
  36025.  
  36026. Description
  36027. ...........
  36028.  
  36029. Executes the SQL query pointed to by the null-terminated string `query'.
  36030. The query must consist of a single SQL statement.  You should not add a
  36031. terminating semicolon (`;') or `\g' to the statement.
  36032.  
  36033. `mysql_query()' cannot be used for queries that contain binary data; you
  36034. should use `mysql_real_query()' instead.  (Binary data may contain the
  36035. `\0' character, which `mysql_query()' interprets as the end of the
  36036. query string.)
  36037.  
  36038. If you want to know if the query should return a result set or not, you
  36039. can use `mysql_field_count()' to check for this.  *Note
  36040. `mysql_field_count': mysql_field_count.
  36041.  
  36042. Return Values
  36043. .............
  36044.  
  36045. Zero if the query was successful. Non-zero if an error occurred.
  36046.  
  36047. Errors
  36048. ......
  36049.  
  36050. `CR_COMMANDS_OUT_OF_SYNC'
  36051.      Commands were executed in an improper order.
  36052.  
  36053. `CR_SERVER_GONE_ERROR'
  36054.      The MySQL server has gone away.
  36055.  
  36056. `CR_SERVER_LOST'
  36057.      The connection to the server was lost during the query.
  36058.  
  36059. `CR_UNKNOWN_ERROR'
  36060.      An unknown error occurred.
  36061.  
  36062. 
  36063. File: mysql.info,  Node: mysql_real_connect,  Next: mysql_real_escape_string,  Prev: mysql_query,  Up: C API functions
  36064.  
  36065. `mysql_real_connect()'
  36066. ......................
  36067.  
  36068. `MYSQL *mysql_real_connect(MYSQL *mysql, const char *host,
  36069.             const char *user, const char *passwd, const char *db,
  36070.                     unsigned int port, const char *unix_socket,
  36071.                   unsigned int client_flag)'
  36072.  
  36073. Description
  36074. ...........
  36075.  
  36076. `mysql_real_connect()' attempts to establish a connection to a MySQL
  36077. database engine running on `host'.  `mysql_real_connect()' must
  36078. complete successfully before you can execute any of the other API
  36079. functions, with the exception of `mysql_get_client_info()'.
  36080.  
  36081. The parameters are specified as follows:
  36082.  
  36083.    * The first parameter should be the address of an existing `MYSQL'
  36084.      structure.  Before calling `mysql_real_connect()' you must call
  36085.      `mysql_init()' to initialize the `MYSQL' structure. You can change
  36086.      a lot of connect options with the `mysql_options()' call. *Note
  36087.      mysql_options::.
  36088.  
  36089.    * The value of `host' may be either a hostname or an IP address.  If
  36090.      `host' is `NULL' or the string `"localhost"', a connection to the
  36091.      local host is assumed. If the OS supports sockets (Unix) or named
  36092.      pipes (Windows), they are used instead of TCP/IP to connect to the
  36093.      server.
  36094.  
  36095.    * The `user' parameter contains the user's MySQL login ID.  If
  36096.      `user' is `NULL', the current user is assumed.  Under Unix, this is
  36097.      the current login name.  Under Windows ODBC, the current user name
  36098.      must be specified explicitly.  *Note ODBC administrator::.
  36099.  
  36100.    * The `passwd' parameter contains the password for `user'.  If
  36101.      `passwd' is `NULL', only entries in the `user' table for the user
  36102.      that have a blank (empty) password field will be checked for a
  36103.      match. This allows the database administrator to set up the MySQL
  36104.      privilege system in such a way that users get different privileges
  36105.      depending on whether or not they have specified a password.
  36106.  
  36107.      NOTE: Do not attempt to encrypt the password before calling
  36108.      `mysql_real_connect()'; password encryption is handled
  36109.      automatically by the client API.
  36110.  
  36111.    * `db' is the database name.  If `db' is not `NULL', the connection
  36112.      will set the default database to this value.
  36113.  
  36114.    * If `port' is not 0, the value will be used as the port number for
  36115.      the TCP/IP connection.  Note that the `host' parameter determines
  36116.      the type of the connection.
  36117.  
  36118.    * If `unix_socket' is not `NULL', the string specifies the socket or
  36119.      named pipe that should be used.  Note that the `host' parameter
  36120.      determines the type of the connection.
  36121.  
  36122.    * The value of `client_flag' is usually 0, but can be set to a
  36123.      combination of the following flags in very special circumstances:
  36124.  
  36125.      *Flag name*       *Flag meaning* `mysqld' to be more
  36126.                        ODBC-friendly.
  36127.      `CLIENT_COMPRESS' Use compression protocol.
  36128.      `CLIENT_FOUND_ROWS'Return the number of found (matched) rows, not
  36129.                        the number of affected rows.
  36130.      `CLIENT_IGNORE_SPACE'Allow spaces after function names. Makes all
  36131.                        functions names reserved words.
  36132.      `CLIENT_INTERACTIVE'Allow `interactive_timeout' seconds (instead
  36133.                        of `wait_timeout' seconds) of inactivity
  36134.                        before closing the connection.
  36135.      `CLIENT_NO_SCHEMA'Don't allow the `db_name.tbl_name.col_name'
  36136.                        syntax.  This is for ODBC. It causes the
  36137.                        parser to generate an error if you use that
  36138.                        syntax, which is useful for trapping bugs in
  36139.                        some ODBC programs.
  36140.      `CLIENT_ODBC'     The client is an ODBC client. This changes
  36141.      `CLIENT_SSL'      Use SSL (encrypted protocol).
  36142.  
  36143. Return Values
  36144. .............
  36145.  
  36146. A `MYSQL*' connection handle if the connection was successful, `NULL'
  36147. if the connection was unsuccessful.  For a successful connection, the
  36148. return value is the same as the value of the first parameter.
  36149.  
  36150. Errors
  36151. ......
  36152.  
  36153. `CR_CONN_HOST_ERROR'
  36154.      Failed to connect to the MySQL server.
  36155.  
  36156. `CR_CONNECTION_ERROR'
  36157.      Failed to connect to the local MySQL server.
  36158.  
  36159. `CR_IPSOCK_ERROR'
  36160.      Failed to create an IP socket.
  36161.  
  36162. `CR_OUT_OF_MEMORY'
  36163.      Out of memory.
  36164.  
  36165. `CR_SOCKET_CREATE_ERROR'
  36166.      Failed to create a Unix socket.
  36167.  
  36168. `CR_UNKNOWN_HOST'
  36169.      Failed to find the IP address for the hostname.
  36170.  
  36171. `CR_VERSION_ERROR'
  36172.      A protocol mismatch resulted from attempting to connect to a
  36173.      server with a client library that uses a different protocol
  36174.      version.  This can happen if you use a very old client library to
  36175.      connect to a new server that wasn't started with the
  36176.      `--old-protocol' option.
  36177.  
  36178. `CR_NAMEDPIPEOPEN_ERROR'
  36179.      Failed to create a named pipe on Windows.
  36180.  
  36181. `CR_NAMEDPIPEWAIT_ERROR'
  36182.      Failed to wait for a named pipe on Windows.
  36183.  
  36184. `CR_NAMEDPIPESETSTATE_ERROR'
  36185.      Failed to get a pipe handler on Windows.
  36186.  
  36187. `CR_SERVER_LOST'
  36188.      If `connect_timeout' > 0 and it took longer then `connect_timeout'
  36189.      seconds to connect to the server or if the server died while
  36190.      executing the `init-command'.
  36191.  
  36192. Example
  36193. .......
  36194.  
  36195.      MYSQL mysql;
  36196.      
  36197.      mysql_init(&mysql);
  36198.      mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"your_prog_name");
  36199.      if (!mysql_real_connect(&mysql,"host","user","passwd","database",0,NULL,0))
  36200.      {
  36201.          fprintf(stderr, "Failed to connect to database: Error: %s\n",
  36202.                mysql_error(&mysql));
  36203.      }
  36204.  
  36205. By using `mysql_options()' the MySQL library will read the `[client]'
  36206. and `your_prog_name' sections in the `my.cnf' file which will ensure
  36207. that your program will work, even if someone has set up MySQL in some
  36208. non-standard way.
  36209.  
  36210. Note that upon connection, `mysql_real_connect()' sets the `reconnect'
  36211. flag (part of the MYSQL structure) to a value of `1'. This flag
  36212. indicates, in the event that a query cannot be performed because of a
  36213. lost connection, to try reconnecting to the server before giving up.
  36214.  
  36215. 
  36216. File: mysql.info,  Node: mysql_real_escape_string,  Next: mysql_real_query,  Prev: mysql_real_connect,  Up: C API functions
  36217.  
  36218. `mysql_real_escape_string()'
  36219. ............................
  36220.  
  36221. `unsigned int mysql_real_escape_string(MYSQL *mysql, char *to, const
  36222. char *from, unsigned int length)'
  36223.  
  36224. Description
  36225. ...........
  36226.  
  36227. This function is used to create a legal SQL string that you can use in a
  36228. SQL statement. *Note String syntax::.
  36229.  
  36230. The string in `from' is encoded to an escaped SQL string, taking into
  36231. account the current character set of the connection. The result is
  36232. placed in `to' and a terminating null byte is appended.  Characters
  36233. encoded are `NUL' (ASCII 0), `\n', `\r', `\', `'', `"', and Control-Z
  36234. (*note Literals::).
  36235.  
  36236. The string pointed to by `from' must be `length' bytes long.  You must
  36237. allocate the `to' buffer to be at least `length*2+1' bytes long.  (In
  36238. the worse case, each character may need to be encoded as using two
  36239. bytes, and you need room for the terminating null byte.)  When
  36240. `mysql_escape_string()' returns, the contents of `to' will be a
  36241. null-terminated string.  The return value is the length of the encoded
  36242. string, not including the terminating null character.
  36243.  
  36244. Example
  36245. .......
  36246.  
  36247.      char query[1000],*end;
  36248.      
  36249.      end = strmov(query,"INSERT INTO test_table values(");
  36250.      *end++ = '\'';
  36251.      end += mysql_real_escape_string(&mysql, end,"What's this",11);
  36252.      *end++ = '\'';
  36253.      *end++ = ',';
  36254.      *end++ = '\'';
  36255.      end += mysql_real_escape_string(&mysql, end,"binary data: \0\r\n",16);
  36256.      *end++ = '\'';
  36257.      *end++ = ')';
  36258.      
  36259.      if (mysql_real_query(&mysql,query,(unsigned int) (end - query)))
  36260.      {
  36261.         fprintf(stderr, "Failed to insert row, Error: %s\n",
  36262.                 mysql_error(&mysql));
  36263.      }
  36264.  
  36265. The `strmov()' function used in the example is included in the
  36266. `mysqlclient' library and works like `strcpy()' but returns a pointer
  36267. to the terminating null of the first parameter.
  36268.  
  36269. Return Values
  36270. .............
  36271.  
  36272. The length of the value placed into `to', not including the terminating
  36273. null character.
  36274.  
  36275. Errors
  36276. ......
  36277.  
  36278. None.
  36279.  
  36280. 
  36281. File: mysql.info,  Node: mysql_real_query,  Next: mysql_reload,  Prev: mysql_real_escape_string,  Up: C API functions
  36282.  
  36283. `mysql_real_query()'
  36284. ....................
  36285.  
  36286. `int mysql_real_query(MYSQL *mysql, const char *query, unsigned int
  36287. length)'
  36288.  
  36289. Description
  36290. ...........
  36291.  
  36292. Executes the SQL query pointed to by `query', which should be a string
  36293. `length' bytes long.  The query must consist of a single SQL statement.
  36294. You should not add a terminating semicolon (`;') or `\g' to the
  36295. statement.
  36296.  
  36297. You _must_ use `mysql_real_query()' rather than `mysql_query()' for
  36298. queries that contain binary data, because binary data may contain the
  36299. `\0' character.  In addition, `mysql_real_query()' is faster than
  36300. `mysql_query()' because it does not call `strlen()' on the query string.
  36301.  
  36302. If you want to know if the query should return a result set or not, you
  36303. can use `mysql_field_count()' to check for this.  *Note
  36304. `mysql_field_count': mysql_field_count.
  36305.  
  36306. Return Values
  36307. .............
  36308.  
  36309. Zero if the query was successful. Non-zero if an error occurred.
  36310.  
  36311. Errors
  36312. ......
  36313.  
  36314. `CR_COMMANDS_OUT_OF_SYNC'
  36315.      Commands were executed in an improper order.
  36316.  
  36317. `CR_SERVER_GONE_ERROR'
  36318.      The MySQL server has gone away.
  36319.  
  36320. `CR_SERVER_LOST'
  36321.      The connection to the server was lost during the query.
  36322.  
  36323. `CR_UNKNOWN_ERROR'
  36324.      An unknown error occurred.
  36325.  
  36326. 
  36327. File: mysql.info,  Node: mysql_reload,  Next: mysql_row_seek,  Prev: mysql_real_query,  Up: C API functions
  36328.  
  36329. `mysql_reload()'
  36330. ................
  36331.  
  36332. `int mysql_reload(MYSQL *mysql)'
  36333.  
  36334. Description
  36335. ...........
  36336.  
  36337. Asks the MySQL server to reload the grant tables. The connected user
  36338. must have the *reload* privilege.
  36339.  
  36340. This function is deprecated.  It is preferable to use `mysql_query()'
  36341. to issue a SQL `FLUSH PRIVILEGES' statement instead.
  36342.  
  36343. Return Values
  36344. .............
  36345.  
  36346. Zero for success.  Non-zero if an error occurred.
  36347.  
  36348. Errors
  36349. ......
  36350.  
  36351. `CR_COMMANDS_OUT_OF_SYNC'
  36352.      Commands were executed in an improper order.
  36353.  
  36354. `CR_SERVER_GONE_ERROR'
  36355.      The MySQL server has gone away.
  36356.  
  36357. `CR_SERVER_LOST'
  36358.      The connection to the server was lost during the query.
  36359.  
  36360. `CR_UNKNOWN_ERROR'
  36361.      An unknown error occurred.
  36362.  
  36363. 
  36364. File: mysql.info,  Node: mysql_row_seek,  Next: mysql_row_tell,  Prev: mysql_reload,  Up: C API functions
  36365.  
  36366. `mysql_row_seek()'
  36367. ..................
  36368.  
  36369. `MYSQL_ROW_OFFSET mysql_row_seek(MYSQL_RES *result, MYSQL_ROW_OFFSET
  36370. offset)'
  36371.  
  36372. Description
  36373. ...........
  36374.  
  36375. Sets the row cursor to an arbitrary row in a query result set.  This
  36376. requires that the result set structure contains the entire result of
  36377. the query, so `mysql_row_seek()' may be used in conjunction only with
  36378. `mysql_store_result()', not with `mysql_use_result()'.
  36379.  
  36380. The offset should be a value returned from a call to `mysql_row_tell()'
  36381. or to `mysql_row_seek()'.  This value is not simply a row number; if you
  36382. want to seek to a row within a result set using a row number, use
  36383. `mysql_data_seek()' instead.
  36384.  
  36385. Return Values
  36386. .............
  36387.  
  36388. The previous value of the row cursor.  This value may be passed to a
  36389. subsequent call to `mysql_row_seek()'.
  36390.  
  36391. Errors
  36392. ......
  36393.  
  36394. None.
  36395.  
  36396. 
  36397. File: mysql.info,  Node: mysql_row_tell,  Next: mysql_select_db,  Prev: mysql_row_seek,  Up: C API functions
  36398.  
  36399. `mysql_row_tell()'
  36400. ..................
  36401.  
  36402. `MYSQL_ROW_OFFSET mysql_row_tell(MYSQL_RES *result)'
  36403.  
  36404. Description
  36405. ...........
  36406.  
  36407. Returns the current position of the row cursor for the last
  36408. `mysql_fetch_row()'. This value can be used as an argument to
  36409. `mysql_row_seek()'.
  36410.  
  36411. You should use `mysql_row_tell()' only after `mysql_store_result()',
  36412. not after `mysql_use_result()'.
  36413.  
  36414. Return Values
  36415. .............
  36416.  
  36417. The current offset of the row cursor.
  36418.  
  36419. Errors
  36420. ......
  36421.  
  36422. None.
  36423.  
  36424. 
  36425. File: mysql.info,  Node: mysql_select_db,  Next: mysql_shutdown,  Prev: mysql_row_tell,  Up: C API functions
  36426.  
  36427. `mysql_select_db()'
  36428. ...................
  36429.  
  36430. `int mysql_select_db(MYSQL *mysql, const char *db)'
  36431.  
  36432. Description
  36433. ...........
  36434.  
  36435. Causes the database specified by `db' to become the default (current)
  36436. database on the connection specified by `mysql'.  In subsequent queries,
  36437. this database is the default for table references that do not include an
  36438. explicit database specifier.
  36439.  
  36440. `mysql_select_db()' fails unless the connected user can be authenticated
  36441. as having permission to use the database.
  36442.  
  36443. Return Values
  36444. .............
  36445.  
  36446. Zero for success.  Non-zero if an error occurred.
  36447.  
  36448. Errors
  36449. ......
  36450.  
  36451. `CR_COMMANDS_OUT_OF_SYNC'
  36452.      Commands were executed in an improper order.
  36453.  
  36454. `CR_SERVER_GONE_ERROR'
  36455.      The MySQL server has gone away.
  36456.  
  36457. `CR_SERVER_LOST'
  36458.      The connection to the server was lost during the query.
  36459.  
  36460. `CR_UNKNOWN_ERROR'
  36461.      An unknown error occurred.
  36462.  
  36463. 
  36464. File: mysql.info,  Node: mysql_shutdown,  Next: mysql_stat,  Prev: mysql_select_db,  Up: C API functions
  36465.  
  36466. `mysql_shutdown()'
  36467. ..................
  36468.  
  36469. `int mysql_shutdown(MYSQL *mysql)'
  36470.  
  36471. Description
  36472. ...........
  36473.  
  36474. Asks the database server to shut down. The connected user must have
  36475. *shutdown* privileges.
  36476.  
  36477. Return Values
  36478. .............
  36479.  
  36480. Zero for success.  Non-zero if an error occurred.
  36481.  
  36482. Errors
  36483. ......
  36484.  
  36485. `CR_COMMANDS_OUT_OF_SYNC'
  36486.      Commands were executed in an improper order.
  36487.  
  36488. `CR_SERVER_GONE_ERROR'
  36489.      The MySQL server has gone away.
  36490.  
  36491. `CR_SERVER_LOST'
  36492.      The connection to the server was lost during the query.
  36493.  
  36494. `CR_UNKNOWN_ERROR'
  36495.      An unknown error occurred.
  36496.  
  36497. 
  36498. File: mysql.info,  Node: mysql_stat,  Next: mysql_store_result,  Prev: mysql_shutdown,  Up: C API functions
  36499.  
  36500. `mysql_stat()'
  36501. ..............
  36502.  
  36503. `char *mysql_stat(MYSQL *mysql)'
  36504.  
  36505. Description
  36506. ...........
  36507.  
  36508. Returns a character string containing information similar to that
  36509. provided by the `mysqladmin status' command.  This includes uptime in
  36510. seconds and the number of running threads, questions, reloads, and open
  36511. tables.
  36512.  
  36513. Return Values
  36514. .............
  36515.  
  36516. A character string describing the server status. `NULL' if an error
  36517. occurred.
  36518.  
  36519. Errors
  36520. ......
  36521.  
  36522. `CR_COMMANDS_OUT_OF_SYNC'
  36523.      Commands were executed in an improper order.
  36524.  
  36525. `CR_SERVER_GONE_ERROR'
  36526.      The MySQL server has gone away.
  36527.  
  36528. `CR_SERVER_LOST'
  36529.      The connection to the server was lost during the query.
  36530.  
  36531. `CR_UNKNOWN_ERROR'
  36532.      An unknown error occurred.
  36533.  
  36534. 
  36535. File: mysql.info,  Node: mysql_store_result,  Next: mysql_thread_id,  Prev: mysql_stat,  Up: C API functions
  36536.  
  36537. `mysql_store_result()'
  36538. ......................
  36539.  
  36540. `MYSQL_RES *mysql_store_result(MYSQL *mysql)'
  36541.  
  36542. Description
  36543. ...........
  36544.  
  36545. You must call `mysql_store_result()' or `mysql_use_result()' for every
  36546. query that successfully retrieves data (`SELECT', `SHOW', `DESCRIBE',
  36547. `EXPLAIN').
  36548.  
  36549. You don't have to call `mysql_store_result()' or `mysql_use_result()'
  36550. for other queries, but it will not do any harm or cause any notable
  36551. performance if you call `mysql_store_result()' in all cases.  You can
  36552. detect if the query didn't have a result set by checking if
  36553. `mysql_store_result()' returns 0 (more about this later one).
  36554.  
  36555. If you want to know if the query should return a result set or not, you
  36556. can use `mysql_field_count()' to check for this.  *Note
  36557. `mysql_field_count': mysql_field_count.
  36558.  
  36559. `mysql_store_result()' reads the entire result of a query to the client,
  36560. allocates a `MYSQL_RES' structure, and places the result into this
  36561. structure.
  36562.  
  36563. `mysql_store_results()' returns a null pointer if the query didn't
  36564. return a result set (if the query was, for example, an `INSERT'
  36565. statement).
  36566.  
  36567. `mysql_store_results()' also returns a null pointer if reading of the
  36568. result set failed. You can check if you got an error by checking if
  36569. `mysql_error()' doesn't return a null pointer, if `mysql_errno()'
  36570. returns <> 0, or if `mysql_field_count()' returns <> 0.
  36571.  
  36572. An empty result set is returned if there are no rows returned.  (An
  36573. empty result set differs from a null pointer as a return value.)
  36574.  
  36575. Once you have called `mysql_store_result()' and got a result back that
  36576. isn't a null pointer, you may call `mysql_num_rows()' to find out how
  36577. many rows are in the result set.
  36578.  
  36579. You can call `mysql_fetch_row()' to fetch rows from the result set, or
  36580. `mysql_row_seek()' and `mysql_row_tell()' to obtain or set the current
  36581. row position within the result set.
  36582.  
  36583. You must call `mysql_free_result()' once you are done with the result
  36584. set.
  36585.  
  36586. *Note `NULL mysql_store_result()': NULL mysql_store_result.
  36587.  
  36588. Return Values
  36589. .............
  36590.  
  36591. A `MYSQL_RES' result structure with the results. `NULL' if an error
  36592. occurred.
  36593.  
  36594. Errors
  36595. ......
  36596.  
  36597. `CR_COMMANDS_OUT_OF_SYNC'
  36598.      Commands were executed in an improper order.
  36599.  
  36600. `CR_OUT_OF_MEMORY'
  36601.      Out of memory.
  36602.  
  36603. `CR_SERVER_GONE_ERROR'
  36604.      The MySQL server has gone away.
  36605.  
  36606. `CR_SERVER_LOST'
  36607.      The connection to the server was lost during the query.
  36608.  
  36609. `CR_UNKNOWN_ERROR'
  36610.      An unknown error occurred.
  36611.  
  36612. 
  36613. File: mysql.info,  Node: mysql_thread_id,  Next: mysql_use_result,  Prev: mysql_store_result,  Up: C API functions
  36614.  
  36615. `mysql_thread_id()'
  36616. ...................
  36617.  
  36618. `unsigned long mysql_thread_id(MYSQL *mysql)'
  36619.  
  36620. Description
  36621. ...........
  36622.  
  36623. Returns the thread ID of the current connection.  This value can be
  36624. used as an argument to `mysql_kill()' to kill the thread.
  36625.  
  36626. If the connection is lost and you reconnect with `mysql_ping()', the
  36627. thread ID will change.  This means you should not get the thread ID and
  36628. store it for later. You should get it when you need it.
  36629.  
  36630. Return Values
  36631. .............
  36632.  
  36633. The thread ID of the current connection.
  36634.  
  36635. Errors
  36636. ......
  36637.  
  36638. None.
  36639.  
  36640. 
  36641. File: mysql.info,  Node: mysql_use_result,  Prev: mysql_thread_id,  Up: C API functions
  36642.  
  36643. `mysql_use_result()'
  36644. ....................
  36645.  
  36646. `MYSQL_RES *mysql_use_result(MYSQL *mysql)'
  36647.  
  36648. Description
  36649. ...........
  36650.  
  36651. You must call `mysql_store_result()' or `mysql_use_result()' for every
  36652. query that successfully retrieves data (`SELECT', `SHOW', `DESCRIBE',
  36653. `EXPLAIN').
  36654.  
  36655. `mysql_use_result()' initiates a result set retrieval but does not
  36656. actually read the result set into the client like `mysql_store_result()'
  36657. does.  Instead, each row must be retrieved individually by making calls
  36658. to `mysql_fetch_row()'.  This reads the result of a query directly from
  36659. the server without storing it in a temporary table or local buffer,
  36660. which is somewhat faster and uses much less memory than
  36661. `mysql_store_result()'.  The client will only allocate memory for the
  36662. current row and a communication buffer that may grow up to
  36663. `max_allowed_packet' bytes.
  36664.  
  36665. On the other hand, you shouldn't use `mysql_use_result()' if you are
  36666. doing a lot of processing for each row on the client side, or if the
  36667. output is sent to a screen on which the user may type a `^S' (stop
  36668. scroll).  This will tie up the server and prevent other threads from
  36669. updating any tables from which the data is being fetched.
  36670.  
  36671. When using `mysql_use_result()', you must execute `mysql_fetch_row()'
  36672. until a `NULL' value is returned, otherwise the unfetched rows will be
  36673. returned as part of the result set for your next query. The C API will
  36674. give the error `Commands out of sync; You can't run this command now'
  36675. if you forget to do this!
  36676.  
  36677. You may not use `mysql_data_seek()', `mysql_row_seek()',
  36678. `mysql_row_tell()', `mysql_num_rows()', or `mysql_affected_rows()' with
  36679. a result returned from `mysql_use_result()', nor may you issue other
  36680. queries until the `mysql_use_result()' has finished.  (However, after
  36681. you have fetched all the rows, `mysql_num_rows()' will accurately
  36682. return the number of rows fetched.)
  36683.  
  36684. You must call `mysql_free_result()' once you are done with the result
  36685. set.
  36686.  
  36687. Return Values
  36688. .............
  36689.  
  36690. A `MYSQL_RES' result structure. `NULL' if an error occurred.
  36691.  
  36692. Errors
  36693. ......
  36694.  
  36695. `CR_COMMANDS_OUT_OF_SYNC'
  36696.      Commands were executed in an improper order.
  36697.  
  36698. `CR_OUT_OF_MEMORY'
  36699.      Out of memory.
  36700.  
  36701. `CR_SERVER_GONE_ERROR'
  36702.      The MySQL server has gone away.
  36703.  
  36704. `CR_SERVER_LOST'
  36705.      The connection to the server was lost during the query.
  36706.  
  36707. `CR_UNKNOWN_ERROR'
  36708.      An unknown error occurred.
  36709.  
  36710. 
  36711. File: mysql.info,  Node: C Thread functions,  Next: C API problems,  Prev: C API functions,  Up: C
  36712.  
  36713. C Threaded Function Descriptions
  36714. --------------------------------
  36715.  
  36716. You need to use the following functions when you want to create a
  36717. threaded client. *Note Threaded clients::.
  36718.  
  36719. * Menu:
  36720.  
  36721. * my_init::
  36722. * my_thread_init()::
  36723. * my_thread_end()::
  36724.  
  36725. 
  36726. File: mysql.info,  Node: my_init,  Next: my_thread_init(),  Prev: C Thread functions,  Up: C Thread functions
  36727.  
  36728. `my_init()'
  36729. ...........
  36730.  
  36731. Description
  36732. ...........
  36733.  
  36734. This function needs to be called once in the program before calling any
  36735. MySQL function.  This initializes some global variables that MySQL
  36736. needs.  If you are using a thread safe client library, this will also
  36737. call `my_thread_init()' for this thread.
  36738.  
  36739. This is automatically called by `mysql_init()' and `mysql_connect()'.
  36740.  
  36741. Return Values
  36742. .............
  36743.  
  36744. none.
  36745.  
  36746. 
  36747. File: mysql.info,  Node: my_thread_init(),  Next: my_thread_end(),  Prev: my_init,  Up: C Thread functions
  36748.  
  36749. `my_thread_init()'
  36750. ..................
  36751.  
  36752. Description
  36753. ...........
  36754.  
  36755. This function needs to be called for each created thread to initialize
  36756. thread specific variables.
  36757.  
  36758. This is automatically called by `my_init()' and `mysql_connect()'.
  36759.  
  36760. Return Values
  36761. .............
  36762.  
  36763. none.
  36764.  
  36765. 
  36766. File: mysql.info,  Node: my_thread_end(),  Prev: my_thread_init(),  Up: C Thread functions
  36767.  
  36768. `my_thread_end()'
  36769. .................
  36770.  
  36771. Description
  36772. ...........
  36773.  
  36774. This function needs to be called before calling `pthread_exit()' to
  36775. freed memory allocated by `my_thread_init()'.
  36776.  
  36777. Note that this function is NOT invoked automatically by the client
  36778. library!
  36779.  
  36780. Return Values
  36781. .............
  36782.  
  36783. none.
  36784.  
  36785. 
  36786. File: mysql.info,  Node: C API problems,  Next: Building clients,  Prev: C Thread functions,  Up: C
  36787.  
  36788. Common questions and problems when using the C API
  36789. --------------------------------------------------
  36790.  
  36791. * Menu:
  36792.  
  36793. * NULL mysql_store_result::     Why Is It that After `mysql_query()' Returns Success, `mysql_store_result()' Sometimes Returns `NULL?'
  36794. * Query results::               What Results Can I Get From a Query?
  36795. * Getting unique ID::           How Can I Get the Unique ID for the Last Inserted Row?
  36796. * C API linking problems::      Problems Linking with the C API
  36797.  
  36798. 
  36799. File: mysql.info,  Node: NULL mysql_store_result,  Next: Query results,  Prev: C API problems,  Up: C API problems
  36800.  
  36801. Why Is It that After `mysql_query()' Returns Success, `mysql_store_result()' Sometimes Returns `NULL?'
  36802. ......................................................................................................
  36803.  
  36804. It is possible for `mysql_store_result()' to return `NULL' following a
  36805. successful call to `mysql_query()'.  When this happens, it means one of
  36806. the following conditions occurred:
  36807.  
  36808.    * There was a `malloc()' failure (for example, if the result set was
  36809.      too large).
  36810.  
  36811.    * The data couldn't be read (an error occurred on the connection).
  36812.  
  36813.    * The query returned no data (for example, it was an `INSERT',
  36814.      `UPDATE', or `DELETE').
  36815.  
  36816. You can always check whether or not the statement should have produced a
  36817. non-empty result by calling `mysql_field_count()'.  If
  36818. `mysql_field_count()' returns zero, the result is empty and the last
  36819. query was a statement that does not return values (for example, an
  36820. `INSERT' or a `DELETE').  If `mysql_field_count()' returns a non-zero
  36821. value, the statement should have produced a non-empty result.  See the
  36822. description of the `mysql_field_count()' function for an example.
  36823.  
  36824. You can test for an error by calling `mysql_error()' or `mysql_errno()'.
  36825.  
  36826. * Menu:
  36827.  
  36828. * Query results::               What Results Can I Get From a Query?
  36829. * Getting unique ID::           How Can I Get the Unique ID for the Last Inserted Row?
  36830. * C API linking problems::      Problems Linking with the C API
  36831.  
  36832. 
  36833. File: mysql.info,  Node: Query results,  Next: Getting unique ID,  Prev: NULL mysql_store_result,  Up: C API problems
  36834.  
  36835. What Results Can I Get From a Query?
  36836. ....................................
  36837.  
  36838. In addition to the result set returned by a query, you can also get the
  36839. following information:
  36840.  
  36841.    * `mysql_affected_rows()' returns the number of rows affected by the
  36842.      last query when doing an `INSERT', `UPDATE', or `DELETE'. An
  36843.      exception is that if `DELETE' is used without a `WHERE' clause, the
  36844.      table is re-created empty, which is much faster! In this case,
  36845.      `mysql_affected_rows()' returns zero for the number of records
  36846.      affected.
  36847.  
  36848.    * `mysql_num_rows()' returns the number of rows in a result set.
  36849.      With `mysql_store_result()', `mysql_num_rows()' may be called as
  36850.      soon as `mysql_store_result()' returns.  With `mysql_use_result()',
  36851.      `mysql_num_rows()' may be called only after you have fetched all
  36852.      the rows with `mysql_fetch_row()'.
  36853.  
  36854.    * `mysql_insert_id()' returns the ID generated by the last query
  36855.      that inserted a row into a table with an `AUTO_INCREMENT' index.
  36856.      *Note `mysql_insert_id()': mysql_insert_id.
  36857.  
  36858.    * Some queries (`LOAD DATA INFILE ...', `INSERT INTO ... SELECT
  36859.      ...', `UPDATE') return additional information.  The result is
  36860.      returned by `mysql_info()'.  See the description for `mysql_info()'
  36861.      for the format of the string that it returns.  `mysql_info()'
  36862.      returns a `NULL' pointer if there is no additional information.
  36863.  
  36864. 
  36865. File: mysql.info,  Node: Getting unique ID,  Next: C API linking problems,  Prev: Query results,  Up: C API problems
  36866.  
  36867. How Can I Get the Unique ID for the Last Inserted Row?
  36868. ......................................................
  36869.  
  36870. If you insert a record in a table containing a column that has the
  36871. `AUTO_INCREMENT' attribute, you can get the most recently generated ID
  36872. by calling the `mysql_insert_id()' function.
  36873.  
  36874. You can also retrieve the ID by using the `LAST_INSERT_ID()' function in
  36875. a query string that you pass to `mysql_query()'.
  36876.  
  36877. You can check if an `AUTO_INCREMENT' index is used by executing the
  36878. following code. This also checks if the query was an `INSERT' with an
  36879. `AUTO_INCREMENT' index:
  36880.  
  36881.      if (mysql_error(&mysql)[0] == 0 &&
  36882.          mysql_num_fields(result) == 0 &&
  36883.          mysql_insert_id(&mysql) != 0)
  36884.      {
  36885.          used_id = mysql_insert_id(&mysql);
  36886.      }
  36887.  
  36888. The most recently generated ID is maintained in the server on a
  36889. per-connection basis.  It will not be changed by another client. It
  36890. will not even be changed if you update another `AUTO_INCREMENT' column
  36891. with a non-magic value (that is, a value that is not `NULL' and not
  36892. `0').
  36893.  
  36894. If you want to use the ID that was generated for one table and insert
  36895. it into a second table, you can use SQL statements like this:
  36896.  
  36897.      INSERT INTO foo (auto,text)
  36898.          VALUES(NULL,'text');              # generate ID by inserting NULL
  36899.      INSERT INTO foo2 (id,text)
  36900.          VALUES(LAST_INSERT_ID(),'text');  # use ID in second table
  36901.  
  36902. 
  36903. File: mysql.info,  Node: C API linking problems,  Prev: Getting unique ID,  Up: C API problems
  36904.  
  36905. Problems Linking with the C API
  36906. ...............................
  36907.  
  36908. When linking with the C API, the following errors may occur on some
  36909. systems:
  36910.  
  36911.      gcc -g -o client test.o -L/usr/local/lib/mysql -lmysqlclient -lsocket -lnsl
  36912.      
  36913.      Undefined        first referenced
  36914.       symbol          in file
  36915.      floor            /usr/local/lib/mysql/libmysqlclient.a(password.o)
  36916.      ld: fatal: Symbol referencing errors. No output written to client
  36917.  
  36918. If this happens on your system, you must include the math library by
  36919. adding `-lm' to the end of the compile/link line.
  36920.  
  36921. 
  36922. File: mysql.info,  Node: Building clients,  Next: Threaded clients,  Prev: C API problems,  Up: C
  36923.  
  36924. Building Client Programs
  36925. ------------------------
  36926.  
  36927. If you compile MySQL clients that you've written yourself or that you
  36928. obtain from a third party, they must be linked using the `-lmysqlclient
  36929. -lz' option on the link command.  You may also need to specify a `-L'
  36930. option to tell the linker where to find the library.  For example, if
  36931. the library is installed in `/usr/local/mysql/lib', use
  36932. `-L/usr/local/mysql/lib -lmysqlclient -lz' on the link command.
  36933.  
  36934. For clients that use MySQL header files, you may need to specify a `-I'
  36935. option when you compile them (for example,
  36936. `-I/usr/local/mysql/include'), so the compiler can find the header
  36937. files.
  36938.  
  36939. 
  36940. File: mysql.info,  Node: Threaded clients,  Prev: Building clients,  Up: C
  36941.  
  36942. How to Make a Threaded Client
  36943. -----------------------------
  36944.  
  36945. The client library is almost thread safe. The biggest problem is that
  36946. the subroutines in `net.c' that read from sockets are not interrupt
  36947. safe.  This was done with the thought that you might want to have your
  36948. own alarm that can break a long read to a server.  If you install
  36949. interrupt handlers for the `SIGPIPE' interrupt, the socket handling
  36950. should be thread safe.
  36951.  
  36952. In the older binaries we distribute on our Web site, the client
  36953. libraries are not normally compiled with the thread-safe option (the
  36954. Windows binaries are by default compiled to be thread safe).  Newer
  36955. binary distributions should have both a normal and a thread-safe client
  36956. library.
  36957.  
  36958. To get a threaded client where you can interrupt the client from other
  36959. threads and set timeouts when talking with the MySQL server, you should
  36960. use the `-lmysys', `-lstring', and `-ldbug' libraries and the
  36961. `net_serv.o' code that the server uses.
  36962.  
  36963. If you don't need interrupts or timeouts, you can just compile a thread
  36964. safe client library `(mysqlclient_r)' and use this.  *Note MySQL C API:
  36965. C.  In this case you don't have to worry about the `net_serv.o' object
  36966. file or the other MySQL libraries.
  36967.  
  36968. When using a threaded client and you want to use timeouts and
  36969. interrupts, you can make great use of the routines in the `thr_alarm.c'
  36970. file.  If you are using routines from the `mysys' library, the only
  36971. thing you must remember is to call `my_init()' first! *Note C Thread
  36972. functions::.
  36973.  
  36974. All functions except `mysql_real_connect()' are by default thread safe.
  36975. The following notes describe how to compile a thread safe client
  36976. library and use it in a thread-safe manner.  (The notes below for
  36977. `mysql_real_connect()' actually apply to `mysql_connect()' as well, but
  36978. because `mysql_connect()' is deprecated, you should be using
  36979. `mysql_real_connect()' anyway.)
  36980.  
  36981. To make `mysql_real_connect()' thread safe, you must recompile the
  36982. client library with this command:
  36983.  
  36984.      shell> ./configure --enable-thread-safe-client
  36985.  
  36986. This will create a thread-safe client library `libmysqlclient_r'.
  36987. `--enable-thread-safe-client'.  This library is thread safe per
  36988. connection.  You can let two threads share the same connection as long
  36989. as you do the following:
  36990.  
  36991.    * Two threads can't send a query to the MySQL at the same time on
  36992.      the same connection.  In particular, you have to ensure that
  36993.      between a `mysql_query()' and `mysql_store_result()' no other
  36994.      thread is using the same connection.
  36995.  
  36996.    * Many threads can access different result sets that are retrieved
  36997.      with `mysql_store_result()'.
  36998.  
  36999.    * If you use `mysql_use_result', you have to ensure that no other
  37000.      thread is asking anything on the same connection until the result
  37001.      set is closed.  However, it really is best for threaded clients
  37002.      that share the same connection to use `mysql_use_result()'.
  37003.  
  37004.    * If you want to use multiple threads on the same connection, you
  37005.      must have a mutex lock around your `mysql_query()' and
  37006.      `mysql_store_result()' call combination.  Once
  37007.      `mysql_store_result()' is ready, the lock can be released and other
  37008.      threads may query the same connection.
  37009.  
  37010.    * If you program with POSIX threads, you can use
  37011.      `pthread_mutex_lock()' and `pthread_mutex_unlock()' to establish
  37012.      and release a mutex lock.
  37013.  
  37014. You need to know the following if you have a thread that is calling
  37015. MySQL functions, but that thread has not created the connection to the
  37016. MySQL database:
  37017.  
  37018. When you call `mysql_init()' or `mysql_connect()', MySQL will create a
  37019. thread specific variable for the thread that is used by the debug
  37020. library (among other things).
  37021.  
  37022. If you have in a thread call a MySQL function, before a thread has
  37023. called `mysql_init()' or `mysql_connect()', the thread will not have
  37024. the necessary thread specific variables in place and you are likely to
  37025. end up with a core dump sooner or later.
  37026.  
  37027. The get things to work smoothly you have to do the following:
  37028.  
  37029.   1. Call `my_init()' at the start of your program if it calls any
  37030.      other MySQL function before calling `mysql_real_connect()'.
  37031.  
  37032.   2. Call `my_thread_init()' in the thread handler before calling any
  37033.      MySQL function.
  37034.  
  37035.   3. In the thread, call `my_thread_end()' before calling
  37036.      `pthread_exit()'.  This will free the memory used by MySQL thread
  37037.      specific variables.
  37038.  
  37039. You may get some errors because of undefined symbols when linking your
  37040. client with `mysqlclient_r'. In most cases this is because you haven't
  37041. included the thread libraries on the link/compile line.
  37042.  
  37043. 
  37044. File: mysql.info,  Node: Cplusplus,  Next: Java,  Prev: C,  Up: Clients
  37045.  
  37046. MySQL C++ APIs
  37047. ==============
  37048.  
  37049. * Menu:
  37050.  
  37051. * Borland C++::                 Borland C++
  37052.  
  37053. Two APIs are available in the MySQL Contrib directory
  37054. (http://www.mysql.com/Downloads/Contrib/).
  37055.  
  37056. 
  37057. File: mysql.info,  Node: Borland C++,  Prev: Cplusplus,  Up: Cplusplus
  37058.  
  37059. Borland C++
  37060. -----------
  37061.  
  37062. You can compile the MySQL Windows source with Borland C++ 5.02.  (The
  37063. Windows source includes only projects for Microsoft VC++, for Borland
  37064. C++ you have to do the project files yourself).
  37065.  
  37066. One known problem with Borland C++ is that it uses a different structure
  37067. alignment than VC++.  This means that you will run into problems if you
  37068. try to use the default `libmysql.dll' libraries (that was compiled with
  37069. VC++) with Borland C++. You can do one of the following to avoid this
  37070. problem.
  37071.  
  37072.    * You can use the static MySQL libraries for Borland C++ that you
  37073.      can find on `http://www.mysql.com/downloads/os-win32.html'.
  37074.  
  37075.    * Only call `mysql_init()' with `NULL' as an argument, not a
  37076.      pre-allocated MYSQL struct.
  37077.  
  37078. 
  37079. File: mysql.info,  Node: Java,  Next: Python,  Prev: Cplusplus,  Up: Clients
  37080.  
  37081. MySQL Java Connectivity (JDBC)
  37082. ==============================
  37083.  
  37084. There are 2 supported JDBC drivers for MySQL (the mm driver and the
  37085. Reisin JDBC driver).  You can find a copy of the mm driver at
  37086. `http://mmmysql.sourceforge.net/' or
  37087. `http://www.mysql.com/Downloads/Contrib/' and the Reisin driver at
  37088. `http://www.caucho.com/projects/jdbc-mysql/index.xtp' For documentation
  37089. consult any JDBC documentation and the driver's own documentation for
  37090. MySQL-specific features.
  37091.  
  37092. 
  37093. File: mysql.info,  Node: Python,  Next: Tcl,  Prev: Java,  Up: Clients
  37094.  
  37095. MySQL Python APIs
  37096. =================
  37097.  
  37098. The MySQL Contrib directory (http://www.mysql.com/Downloads/Contrib/)
  37099. contains a Python interface written by Joseph Skinner.
  37100.  
  37101. You can also use the Python interface to iODBC to access a MySQL server.
  37102. mxODBC (http://starship.skyport.net/~lemburg/)
  37103.  
  37104. 
  37105. File: mysql.info,  Node: Tcl,  Next: Eiffel,  Prev: Python,  Up: Clients
  37106.  
  37107. MySQL Tcl APIs
  37108. ==============
  37109.  
  37110. Tcl at binevolve (http://www.binevolve.com/~tdarugar/tcl-sql/).  The
  37111. Contrib directory (http://www.mysql.com/Downloads/Contrib) contains a
  37112. Tcl interface that is based on msqltcl 1.50.
  37113.  
  37114. 
  37115. File: mysql.info,  Node: Eiffel,  Prev: Tcl,  Up: Clients
  37116.  
  37117. MySQL Eiffel wrapper
  37118. ====================
  37119.  
  37120. The MySQL Contrib directory (http://www.mysql.com/Downloads/Contrib/)
  37121. contains an Eiffel wrapper written by Michael Ravits.
  37122.  
  37123. You can also find this at: <http://www.netpedia.net/hosting/newplayer/>
  37124.  
  37125. 
  37126. File: mysql.info,  Node: Extending MySQL,  Next: Problems,  Prev: Clients,  Up: Top
  37127.  
  37128. Extending MySQL
  37129. ***************
  37130.  
  37131. * Menu:
  37132.  
  37133. * Adding functions::            Adding New Functions to MySQL
  37134. * Adding procedures::           Adding New Procedures to MySQL
  37135. * MySQL internals::             MySQL Internals
  37136.  
  37137. 
  37138. File: mysql.info,  Node: Adding functions,  Next: Adding procedures,  Prev: Extending MySQL,  Up: Extending MySQL
  37139.  
  37140. Adding New Functions to MySQL
  37141. =============================
  37142.  
  37143. There are two ways to add new functions to MySQL:
  37144.  
  37145.    * You can add the function through the user-definable function (UDF)
  37146.      interface.  User-definable functions are added and removed
  37147.      dynamically using the `CREATE FUNCTION' and `DROP FUNCTION'
  37148.      statements.  *Note `CREATE FUNCTION': CREATE FUNCTION.
  37149.  
  37150.    * You can add the function as a native (built in) MySQL function.
  37151.      Native functions are compiled into the `mysqld' server and become
  37152.      available on a permanent basis.
  37153.  
  37154. Each method has advantages and disadvantages:
  37155.  
  37156.    * If you write a user-definable function, you must install the
  37157.      object file in addition to the server itself.  If you compile your
  37158.      function into the server, you don't need to do that.
  37159.  
  37160.    * You can add UDFs to a binary MySQL distribution.  Native functions
  37161.      require you to modify a source distribution.
  37162.  
  37163.    * If you upgrade your MySQL distribution, you can continue to use
  37164.      your previously installed UDFs.  For native functions, you must
  37165.      repeat your modifications each time you upgrade.
  37166.  
  37167. Whichever method you use to add new functions, they may be used just
  37168. like native functions such as `ABS()' or `SOUNDEX()'.
  37169.  
  37170. * Menu:
  37171.  
  37172. * CREATE FUNCTION::             `CREATE FUNCTION/DROP FUNCTION' Syntax
  37173. * Adding UDF::                  Adding a new user-definable function
  37174. * Adding native function::      Adding a new native function
  37175.  
  37176. 
  37177. File: mysql.info,  Node: CREATE FUNCTION,  Next: Adding UDF,  Prev: Adding functions,  Up: Adding functions
  37178.  
  37179. `CREATE FUNCTION/DROP FUNCTION' Syntax
  37180. --------------------------------------
  37181.  
  37182.      CREATE [AGGREGATE] FUNCTION function_name RETURNS {STRING|REAL|INTEGER}
  37183.             SONAME shared_library_name
  37184.      
  37185.      DROP FUNCTION function_name
  37186.  
  37187. A user-definable function (UDF) is a way to extend MySQL with a new
  37188. function that works like native (built in) MySQL functions such as
  37189. `ABS()' and `CONCAT()'.
  37190.  
  37191. `AGGREGATE' is a new option for MySQL Version 3.23.  An `AGGREGATE'
  37192. function works exactly like a native MySQL `GROUP' function like `SUM'
  37193. or `COUNT()'.
  37194.  
  37195. `CREATE FUNCTION' saves the function's name, type, and shared library
  37196. name in the `mysql.func' system table.  You must have the *insert* and
  37197. *delete* privileges for the `mysql' database to create and drop
  37198. functions.
  37199.  
  37200. All active functions are reloaded each time the server starts, unless
  37201. you start `mysqld' with the `--skip-grant-tables' option.  In this
  37202. case, UDF initialization is skipped and UDFs are unavailable.  (An
  37203. active function is one that has been loaded with `CREATE FUNCTION' and
  37204. not removed with `DROP FUNCTION'.)
  37205.  
  37206. For instructions on writing user-definable functions, see *Note Adding
  37207. functions::.  For the UDF mechanism to work, functions must be written
  37208. in C or C++, your operating system must support dynamic loading and you
  37209. must have compiled `mysqld' dynamically (not statically).
  37210.  
  37211. 
  37212. File: mysql.info,  Node: Adding UDF,  Next: Adding native function,  Prev: CREATE FUNCTION,  Up: Adding functions
  37213.  
  37214. Adding a New User-definable Function
  37215. ------------------------------------
  37216.  
  37217. * Menu:
  37218.  
  37219. * UDF calling sequences::       UDF calling sequences
  37220. * UDF arguments::               Argument processing
  37221. * UDF return values::           Return values and error handling
  37222. * UDF compiling::               Compiling and installing user-definable functions
  37223.  
  37224. For the UDF mechanism to work, functions must be written in C or C++
  37225. and your operating system must support dynamic loading.  The MySQL
  37226. source distribution includes a file `sql/udf_example.cc' that defines 5
  37227. new functions.  Consult this file to see how UDF calling conventions
  37228. work.
  37229.  
  37230. For `mysqld' to be able to use UDF functions, you should configure MySQL
  37231. with `--with-mysqld-ldflags=-rdynamic' The reason is that to on many
  37232. platforms (including Linux) you can load a dynamic library (with
  37233. `dlopen()') from a static linked program, which you would get if you
  37234. are using `--with-mysqld-ldflags=-all-static' If you want to use an UDF
  37235. that needs to access symbols from `mysqld' (like the `methaphone'
  37236. example in `sql/udf_example.cc' that uses `default_charset_info'), you
  37237. must link the program with `-rdynamic'.  (see `man dlopen').
  37238.  
  37239. For each function that you want to use in SQL statements, you should
  37240. define corresponding C (or C++) functions.  In the discussion below,
  37241. the name "xxx" is used for an example function name.  To distinquish
  37242. between SQL and C/C++ usage, `XXX()' (uppercase) indicates a SQL
  37243. function call, and `xxx()' (lowercase) indicates a C/C++ function call.
  37244.  
  37245. The C/C++ functions that you write to implement the interface for
  37246. `XXX()' are:
  37247.  
  37248. `xxx()' (required)
  37249.      The main function.  This is where the function result is computed.
  37250.      The correspondence between the SQL type and return type of your
  37251.      C/C++ function is shown below:
  37252.  
  37253.      *SQL type*    *C/C++ type*
  37254.      `STRING'      `char *'
  37255.      `INTEGER'     `long long'
  37256.      `REAL'        `double'
  37257.  
  37258. `xxx_init()' (optional)
  37259.      The initialization function for `xxx()'.  It can be used to:
  37260.  
  37261.         * Check the number of arguments to `XXX()'.
  37262.  
  37263.         * Check that the arguments are of a required type or,
  37264.           alternatively, tell MySQL to coerce arguments to the types
  37265.           you want when the main function is called.
  37266.  
  37267.         * Allocate any memory required by the main function.
  37268.  
  37269.         * Specify the maximum length of the result.
  37270.  
  37271.         * Specify (for `REAL' functions) the maximum number of decimals.
  37272.  
  37273.         * Specify whether or not the result can be `NULL'.
  37274.  
  37275. `xxx_deinit()' (optional)
  37276.      The deinitialization function for `xxx()'.  It should deallocate
  37277.      any memory allocated by the initialization function.
  37278.  
  37279. When a SQL statement invokes `XXX()', MySQL calls the initialization
  37280. function `xxx_init()' to let it perform any required setup, such as
  37281. argument checking or memory allocation.  If `xxx_init()' returns an
  37282. error, the SQL statement is aborted with an error message and the main
  37283. and deinitialization functions are not called.  Otherwise, the main
  37284. function `xxx()' is called once for each row.  After all rows have been
  37285. processed, the deinitialization function `xxx_deinit()' is called so it
  37286. can perform any required cleanup.
  37287.  
  37288. All functions must be thread safe (not just the main function, but the
  37289. initialization and deinitialization functions as well). This means that
  37290. you are not allowed to allocate any global or static variables that
  37291. change!  If you need memory, you should allocate it in `xxx_init()' and
  37292. free it in `xxx_deinit()'.
  37293.  
  37294. 
  37295. File: mysql.info,  Node: UDF calling sequences,  Next: UDF arguments,  Prev: Adding UDF,  Up: Adding UDF
  37296.  
  37297. UDF Calling Sequences
  37298. .....................
  37299.  
  37300. The main function should be declared as shown below.  Note that the
  37301. return type and parameters differ, depending on whether you will
  37302. declare the SQL function `XXX()' to return `STRING', `INTEGER', or
  37303. `REAL' in the `CREATE FUNCTION' statement:
  37304.  
  37305. For `STRING' functions:
  37306.  
  37307.      char *xxx(UDF_INIT *initid, UDF_ARGS *args,
  37308.                    char *result, unsigned long *length,
  37309.                    char *is_null, char *error);
  37310.  
  37311. For `INTEGER' functions:
  37312.  
  37313.      long long xxx(UDF_INIT *initid, UDF_ARGS *args,
  37314.                    char *is_null, char *error);
  37315.  
  37316. For `REAL' functions:
  37317.  
  37318.      double xxx(UDF_INIT *initid, UDF_ARGS *args,
  37319.                    char *is_null, char *error);
  37320.  
  37321. The initialization and deinitialization functions are declared like
  37322. this:
  37323.  
  37324.      my_bool xxx_init(UDF_INIT *initid, UDF_ARGS *args, char *message);
  37325.      
  37326.      void xxx_deinit(UDF_INIT *initid);
  37327.  
  37328. The `initid' parameter is passed to all three functions.  It points to a
  37329. `UDF_INIT' structure that is used to communicate information between
  37330. functions.  The `UDF_INIT' structure members are listed below.  The
  37331. initialization function should fill in any members that it wishes to
  37332. change.  (To use the default for a member, leave it unchanged.):
  37333.  
  37334. `my_bool maybe_null'
  37335.      `xxx_init()' should set `maybe_null' to `1' if `xxx()' can return
  37336.      `NULL'.  The default value is `1' if any of the arguments are
  37337.      declared `maybe_null'.
  37338.  
  37339. `unsigned int decimals'
  37340.      Number of decimals.  The default value is the maximum number of
  37341.      decimals in the arguments passed to the main function.  (For
  37342.      example, if the function is passed `1.34', `1.345', and `1.3', the
  37343.      default would be 3, because `1.345' has 3 decimals.
  37344.  
  37345. `unsigned int max_length'
  37346.      The maximum length of the string result.  The default value
  37347.      differs depending on the result type of the function.  For string
  37348.      functions, the default is the length of the longest argument.  For
  37349.      integer functions, the default is 21 digits.  For real functions,
  37350.      the default is 13 plus the number of decimals indicated by
  37351.      `initid->decimals'.  (For numeric functions, the length includes
  37352.      any sign or decimal point characters.)
  37353.  
  37354. `char *ptr'
  37355.      A pointer that the function can use for its own purposes.  For
  37356.      example, functions can use `initid->ptr' to communicate allocated
  37357.      memory between functions.  In `xxx_init()', allocate the memory
  37358.      and assign it to this pointer:
  37359.  
  37360.           initid->ptr = allocated_memory;
  37361.  
  37362.      In `xxx()' and `xxx_deinit()', refer to `initid->ptr' to use or
  37363.      deallocate the memory.
  37364.  
  37365. 
  37366. File: mysql.info,  Node: UDF arguments,  Next: UDF return values,  Prev: UDF calling sequences,  Up: Adding UDF
  37367.  
  37368. Argument Processing
  37369. ...................
  37370.  
  37371. The `args' parameter points to a `UDF_ARGS' structure that thas the
  37372. members listed below:
  37373.  
  37374. `unsigned int arg_count'
  37375.      The number of arguments.  Check this value in the initialization
  37376.      function if you want your function to be called with a particular
  37377.      number of arguments.  For example:
  37378.  
  37379.           if (args->arg_count != 2)
  37380.           {
  37381.               strcpy(message,"XXX() requires two arguments");
  37382.               return 1;
  37383.           }
  37384.  
  37385. `enum Item_result *arg_type'
  37386.      The types for each argument.  The possible type values are
  37387.      `STRING_RESULT', `INT_RESULT', and `REAL_RESULT'.
  37388.  
  37389.      To make sure that arguments are of a given type and return an
  37390.      error if they are not, check the `arg_type' array in the
  37391.      initialization function.  For example:
  37392.  
  37393.           if (args->arg_type[0] != STRING_RESULT ||
  37394.               args->arg_type[1] != INT_RESULT)
  37395.           {
  37396.               strcpy(message,"XXX() requires a string and an integer");
  37397.               return 1;
  37398.           }
  37399.  
  37400.      As an alternative to requiring your function's arguments to be of
  37401.      particular types, you can use the initialization function to set
  37402.      the `arg_type' elements to the types you want.  This causes MySQL
  37403.      to coerce arguments to those types for each call to `xxx()'.  For
  37404.      example, to specify coercion of the first two arguments to string
  37405.      and integer, do this in `xxx_init()':
  37406.  
  37407.           args->arg_type[0] = STRING_RESULT;
  37408.           args->arg_type[1] = INT_RESULT;
  37409.  
  37410. `char **args'
  37411.      `args->args' communicates information to the initialization
  37412.      function about the general nature of the arguments your function
  37413.      was called with.  For a constant argument `i', `args->args[i]'
  37414.      points to the argument value.  (See below for instructions on how
  37415.      to access the value properly.)  For a non-constant argument,
  37416.      `args->args[i]' is `0'.  A constant argument is an expression that
  37417.      uses only constants, such as `3' or `4*7-2' or `SIN(3.14)'.  A
  37418.      non-constant argument is an expression that refers to values that
  37419.      may change from row to row, such as column names or functions that
  37420.      are called with non-constant arguments.
  37421.  
  37422.      For each invocation of the main function, `args->args' contains the
  37423.      actual arguments that are passed for the row currently being
  37424.      processed.
  37425.  
  37426.      Functions can refer to an argument `i' as follows:
  37427.  
  37428.         * An argument of type `STRING_RESULT' is given as a string
  37429.           pointer plus a length, to allow handling of binary data or
  37430.           data of arbitrary length.  The string contents are available
  37431.           as `args->args[i]' and the string length is
  37432.           `args->lengths[i]'.  You should not assume that strings are
  37433.           null-terminated.
  37434.  
  37435.         * For an argument of type `INT_RESULT', you must cast
  37436.           `args->args[i]' to a `long long' value:
  37437.  
  37438.                long long int_val;
  37439.                int_val = *((long long*) args->args[i]);
  37440.  
  37441.         * For an argument of type `REAL_RESULT', you must cast
  37442.           `args->args[i]' to a `double' value:
  37443.  
  37444.                double    real_val;
  37445.                real_val = *((double*) args->args[i]);
  37446.  
  37447. `unsigned long *lengths'
  37448.      For the initialization function, the `lengths' array indicates the
  37449.      maximum string length for each argument.  For each invocation of
  37450.      the main function, `lengths' contains the actual lengths of any
  37451.      string arguments that are passed for the row currently being
  37452.      processed.  For arguments of types `INT_RESULT' or `REAL_RESULT',
  37453.      `lengths' still contains the maximum length of the argument (as
  37454.      for the initialization function).
  37455.  
  37456. 
  37457. File: mysql.info,  Node: UDF return values,  Next: UDF compiling,  Prev: UDF arguments,  Up: Adding UDF
  37458.  
  37459. Return Values and Error Handling
  37460. ................................
  37461.  
  37462. The initialization function should return `0' if no error occurred and
  37463. `1' otherwise.  If an error occurs, `xxx_init()' should store a
  37464. null-terminated error message in the `message' parameter.  The message
  37465. will be returned to the client.  The message buffer is
  37466. `MYSQL_ERRMSG_SIZE' characters long, but you should try to keep the
  37467. message to less than 80 characters so that it fits the width of a
  37468. standard terminal screen.
  37469.  
  37470. The return value of the main function `xxx()' is the function value, for
  37471. `long long' and `double' functions.  A string functions should return a
  37472. pointer to the result and store the length of the string in the
  37473. `length' arguments. `result' is a buffer at least 255 bytes long.  Set
  37474. these to the contents and length of the return value.  For example:
  37475.  
  37476.      memcpy(result, "result string", 13);
  37477.      *length = 13;
  37478.  
  37479. If your string functions that needs to return a string longer than 255
  37480. bytes, you must allocate the space for it with `malloc()' in your
  37481. `xxx_init()' function or your `xxx()' function and free it in your
  37482. `xxx_deinit()' function.  You can store the allocated memory in the
  37483. `ptr' slot in the `UDF_INIT' structure for reuse by future `xxx()'
  37484. calls.  *Note UDF calling sequences::.
  37485.  
  37486. To indicate a return value of `NULL' in the main function, set
  37487. `is_null' to `1':
  37488.  
  37489.      *is_null = 1;
  37490.  
  37491. To indicate an error return in the main function, set the `error'
  37492. parameter to `1':
  37493.  
  37494.      *error = 1;
  37495.  
  37496. If `xxx()' sets `*error' to `1' for any row, the function value is
  37497. `NULL' for the current row and for any subsequent rows processed by the
  37498. statement in which `XXX()' was invoked.  (`xxx()' will not even be
  37499. called for subsequent rows.) *NOTE:* In MySQL versions prior to
  37500. 3.22.10, you should set both `*error' and `*is_null':
  37501.  
  37502.      *error = 1;
  37503.      *is_null = 1;
  37504.  
  37505. 
  37506. File: mysql.info,  Node: UDF compiling,  Prev: UDF return values,  Up: Adding UDF
  37507.  
  37508. Compiling and Installing User-definable Functions
  37509. .................................................
  37510.  
  37511. Files implementing UDFs must be compiled and installed on the host
  37512. where the server runs.  This process is described below for the example
  37513. UDF file `udf_example.cc' that is included in the MySQL source
  37514. distribution.  This file contains the following functions:
  37515.  
  37516.    * `metaphon()' returns a metaphon string of the string argument.
  37517.      This is something like a soundex string, but it's more tuned for
  37518.      English.
  37519.  
  37520.    * `myfunc_double()' returns the sum of the ASCII values of the
  37521.      characters in its arguments, divided by the sum of the length of
  37522.      its arguments.
  37523.  
  37524.    * `myfunc_int()' returns the sum of the length of its arguments.
  37525.  
  37526.    * `sequence([const int])' returns an sequence starting from the given
  37527.      number or 1 if no number has been given.
  37528.  
  37529.    * `lookup()' returns the IP number for a hostname.
  37530.  
  37531.    * `reverse_lookup()' returns the hostname for an IP number.  The
  37532.      function may be called with a string `"xxx.xxx.xxx.xxx"' or four
  37533.      numbers.
  37534.  
  37535. A dynamically loadable file should be compiled as a sharable object
  37536. file, using a command something like this:
  37537.  
  37538.      shell> gcc -shared -o udf_example.so myfunc.cc
  37539.  
  37540. You can easily find out the correct compiler options for your system by
  37541. running this command in the `sql' directory of your MySQL source tree:
  37542.  
  37543.      shell> make udf_example.o
  37544.  
  37545. You should run a compile command similar to the one that `make'
  37546. displays, except that you should remove the `-c' option near the end of
  37547. the line and add `-o udf_example.so' to the end of the line.  (On some
  37548. systems, you may need to leave  the `-c' on the command.)
  37549.  
  37550. Once you compile a shared object containing UDFs, you must install it
  37551. and tell MySQL about it.  Compiling a shared object from
  37552. `udf_example.cc' produces a file named something like `udf_example.so'
  37553. (the exact name may vary from platform to platform).  Copy this file to
  37554. some directory searched by `ld', such as `/usr/lib'.  On many systems,
  37555. you can set the `LD_LIBRARY' or `LD_LIBRARY_PATH' environment variable
  37556. to point at the directory where you have your UDF function files. The
  37557. `dlopen' manual page tells you which variable you should use on your
  37558. system. You should set this in `mysql.server' or `safe_mysqld' and
  37559. restart `mysqld'.
  37560.  
  37561. After the library is installed, notify `mysqld' about the new functions
  37562. with these commands:
  37563.  
  37564.      mysql> CREATE FUNCTION metaphon RETURNS STRING SONAME "udf_example.so";
  37565.      mysql> CREATE FUNCTION myfunc_double RETURNS REAL SONAME "udf_example.so";
  37566.      mysql> CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "udf_example.so";
  37567.      mysql> CREATE FUNCTION lookup RETURNS STRING SONAME "udf_example.so";
  37568.      mysql> CREATE FUNCTION reverse_lookup RETURNS STRING SONAME "udf_example.so";
  37569.  
  37570. Functions can be deleted using `DROP FUNCTION':
  37571.  
  37572.      mysql> DROP FUNCTION metaphon;
  37573.      mysql> DROP FUNCTION myfunc_double;
  37574.      mysql> DROP FUNCTION myfunc_int;
  37575.      mysql> DROP FUNCTION lookup;
  37576.      mysql> DROP FUNCTION reverse_lookup;
  37577.  
  37578. The `CREATE FUNCTION' and `DROP FUNCTION' statements update the system
  37579. table `func' in the `mysql' database.  The function's name, type and
  37580. shared library name are saved in the table.  You must have the *insert*
  37581. and *delete* privileges for the `mysql' database to create and drop
  37582. functions.
  37583.  
  37584. You should not use `CREATE FUNCTION' to add a function that has already
  37585. been created.  If you need to reinstall a function, you should remove
  37586. it with `DROP FUNCTION' and then reinstall it with `CREATE FUNCTION'.
  37587. You would need to do this, for example, if you recompile a new version
  37588. of your function, so that `mysqld' gets the new version.  Otherwise the
  37589. server will continue to use the old version.
  37590.  
  37591. Active functions are reloaded each time the server starts, unless you
  37592. start `mysqld' with the `--skip-grant-tables' option.  In this case, UDF
  37593. initialization is skipped and UDFs are unavailable.  (An active
  37594. function is one that has been loaded with `CREATE FUNCTION' and not
  37595. removed with `DROP FUNCTION'.)
  37596.  
  37597. 
  37598. File: mysql.info,  Node: Adding native function,  Prev: Adding UDF,  Up: Adding functions
  37599.  
  37600. Adding a New Native Function
  37601. ----------------------------
  37602.  
  37603. The procedure for adding a new native function is described below.  Note
  37604. that you cannot add native functions to a binary distribution because
  37605. the procedure involves modifying MySQL source code.  You must compile
  37606. MySQL yourself from a source distribution.  Also note that if you
  37607. migrate to another version of MySQL (for example, when a new version is
  37608. released), you will need to repeat the procedure with the new version.
  37609.  
  37610. To add a new native MySQL function, follow these steps:
  37611.  
  37612.   1. Add one line to `lex.h' that defines the function name in the
  37613.      `sql_functions[]' array.
  37614.  
  37615.   2. If the function prototype is simple (just takes zero, one, two or
  37616.      three arguments), you should in lex.h specify SYM(FUNC_ARG#)
  37617.      (where # is the number of arguments) as the second argument in the
  37618.      `sql_functions[]' array and add a function that creates a function
  37619.      object in `item_create.cc'.  Take a look at `"ABS"' and
  37620.      `create_funcs_abs()' for an example of this.
  37621.  
  37622.      If the function prototype is complicated (for example takes a
  37623.      variable number of arguments), you should add two lines to
  37624.      `sql_yacc.yy'. One indicates the preprocessor symbol that `yacc'
  37625.      should define (this should be added at the beginning of the file).
  37626.      Then define the function parameters and add an "item" with these
  37627.      parameters to the `simple_expr' parsing rule.  For an example,
  37628.      check all occurrences of `ATAN' in `sql_yacc.yy' to see how this
  37629.      is done.
  37630.  
  37631.   3. In `item_func.h', declare a class inheriting from `Item_num_func'
  37632.      or `Item_str_func', depending on whether your function returns a
  37633.      number or a string.
  37634.  
  37635.   4. In `item_func.cc', add one of the following declarations, depending
  37636.      on whether you are defining a numeric or string function:
  37637.           double   Item_func_newname::val()
  37638.           longlong Item_func_newname::val_int()
  37639.           String  *Item_func_newname::Str(String *str)
  37640.  
  37641.      If you inherit your object from any of the standard items (like
  37642.      `Item_num_func' you probably only have to define one of the above
  37643.      functions and let the parent object take care of the other
  37644.      functions.  For example, the `Item_str_func' class defines a
  37645.      `val()' function that executes `atof()' on the value returned by
  37646.      `::str()'.
  37647.  
  37648.   5. You should probably also define the following object function:
  37649.           void Item_func_newname::fix_length_and_dec()
  37650.      This function should at least calculate `max_length' based on the
  37651.      given arguments. `max_length' is the maximum number of characters
  37652.      the function may return.  This function should also set `maybe_null
  37653.      = 0' if the main function can't return a `NULL' value.  The
  37654.      function can check if any of the function arguments can return
  37655.      `NULL' by checking the arguments `maybe_null' variable. You can
  37656.      take a look at `Item_func_mod::fix_length_and_dec' for a typical
  37657.      example of how to do this.
  37658.  
  37659. All functions must be thread safe (In other words, don't use any global
  37660. or static variables in the functions without protecting them with
  37661. mutexes).
  37662.  
  37663. If you want to return `NULL', from `::val()', `::val_int()' or
  37664. `::str()' you should set `null_value' to 1 and return 0.
  37665.  
  37666. For `::str()' object functions, there are some additional
  37667. considerations to be aware of:
  37668.  
  37669.    * The `String *str' argument provides a string buffer that may be
  37670.      used to hold the result. (For more information about the `String'
  37671.      type, take a look at the `sql_string.h' file.)
  37672.  
  37673.    * The `::str()' function should return the string that holds the
  37674.      result or `(char*) 0' if the result is `NULL'.
  37675.  
  37676.    * All current string functions try to avoid allocating any memory
  37677.      unless absolutely necessary!
  37678.  
  37679. 
  37680. File: mysql.info,  Node: Adding procedures,  Next: MySQL internals,  Prev: Adding functions,  Up: Extending MySQL
  37681.  
  37682. Adding New Procedures to MySQL
  37683. ==============================
  37684.  
  37685. In MySQL, you can define a procedure in C++ that can access and modify
  37686. the data in a query before it is sent to the client.  The modification
  37687. can be done on row-by-row or `GROUP BY' level.
  37688.  
  37689. We have created an example procedure in MySQL Version 3.23 to show you
  37690. what can be done.
  37691.  
  37692. Additionally we recommend you to take a look at 'mylua', which you can
  37693. find in the Contrib directory. *Note Contrib::.  Which this you can use
  37694. the LUA language to load a procedure at runtime into `mysqld'.
  37695.  
  37696. * Menu:
  37697.  
  37698. * procedure analyse::           Procedure analyse
  37699. * Writing a procedure::         Writing a procedure.
  37700.  
  37701. 
  37702. File: mysql.info,  Node: procedure analyse,  Next: Writing a procedure,  Prev: Adding procedures,  Up: Adding procedures
  37703.  
  37704. Procedure Analyse
  37705. -----------------
  37706.  
  37707. `analyse([max elements,[max memory]])'
  37708.  
  37709. This procedure is defined in the `sql/sql_analyse.cc'.  This examines
  37710. the result from your query and returns an analysis of the results:
  37711.  
  37712.    * `max elements' (default 256) is the maximum number of distinct
  37713.      values `analyse' will notice per column.  This is used by
  37714.      `analyse' to check if the optimal column type should be of type
  37715.      `ENUM'.
  37716.  
  37717.    * `max memory' (default 8192) is the maximum memory `analyse' should
  37718.      allocate per column while trying to find all distinct values.
  37719.  
  37720.      SELECT ... FROM ... WHERE ... PROCEDURE ANALYSE([max elements,[max memory]])
  37721.  
  37722. 
  37723. File: mysql.info,  Node: Writing a procedure,  Prev: procedure analyse,  Up: Adding procedures
  37724.  
  37725. Writing a Procedure
  37726. -------------------
  37727.  
  37728. For the moment, the only documentation for this is the source.
  37729.  
  37730. You can find all information about procedures by examining the
  37731. following files:
  37732.  
  37733.    * `sql/sql_analyse.cc'
  37734.  
  37735.    * `sql/procedure.h'
  37736.  
  37737.    * `sql/procedure.cc'
  37738.  
  37739.    * `sql/sql_select.cc'
  37740.  
  37741. 
  37742. File: mysql.info,  Node: MySQL internals,  Prev: Adding procedures,  Up: Extending MySQL
  37743.  
  37744. MySQL Internals
  37745. ===============
  37746.  
  37747. This chapter describes a lot of things that you need to know when
  37748. working on the MySQL code. If you plan to contribute to MySQL
  37749. development, want to have access to the bleeding-edge in-between
  37750. versions code, or just want to keep track of development, follow the
  37751. instructions in *Note Installing source tree::.  If you are interested
  37752. in MySQL internals, you should also subscribe to
  37753. <internals@lists.mysql.com>.  This is a relatively low traffic list, in
  37754. comparison with <mysql@lists.mysql.com>.
  37755.  
  37756. * Menu:
  37757.  
  37758. * MySQL threads::               MySQL threads
  37759. * MySQL test suite::            MySQL test suite
  37760.  
  37761. 
  37762. File: mysql.info,  Node: MySQL threads,  Next: MySQL test suite,  Prev: MySQL internals,  Up: MySQL internals
  37763.  
  37764. MySQL Threads
  37765. -------------
  37766.  
  37767. The MySQL server creates the following threads:
  37768.  
  37769.    * The TCP/IP connection thread handles all connection requests and
  37770.      creates a new dedicated thread to handle the authentication and
  37771.      and SQL query processing for each connection.
  37772.  
  37773.    * On Windows NT there is a named pipe handler thread that does the
  37774.      same work as the TCP/IP connection thread on named pipe connect
  37775.      requests.
  37776.  
  37777.    * The signal thread handles all signals.  This thread also normally
  37778.      handles alarms and calls `process_alarm()' to force timeouts on
  37779.      connections that have been idle too long.
  37780.  
  37781.    * If `mysqld' is compiled with `-DUSE_ALARM_THREAD', a dedicated
  37782.      thread that handles alarms is created.  This is only used on some
  37783.      systems where there are problems with `sigwait()' or if one wants
  37784.      to use the `thr_alarm()' code in ones application without a
  37785.      dedicated signal handling thread.
  37786.  
  37787.    * If one uses the `--flush_time=#' option, a dedicated thread is
  37788.      created to flush all tables at the given interval.
  37789.  
  37790.    * Every connection has its own thread.
  37791.  
  37792.    * Every different table on which one uses `INSERT DELAYED' gets its
  37793.      own thread.
  37794.  
  37795.    * If you use `--master-host', a slave replication thread will be
  37796.      started to read and apply updates from the master.
  37797.  
  37798. `mysqladmin processlist' only shows the connection, `INSERT DELAYED',
  37799. and replication threads.
  37800.  
  37801. 
  37802. File: mysql.info,  Node: MySQL test suite,  Prev: MySQL threads,  Up: MySQL internals
  37803.  
  37804. MySQL Test Suite
  37805. ----------------
  37806.  
  37807. Until recently, our main full-coverage test suite was based on
  37808. proprietary customer data and for that reason has not been publicly
  37809. available. The only publicly available part of our testing process
  37810. consisted of the `crash-me' test, a Perl DBI/DBD benchmark found in the
  37811. `sql-bench' directory, and miscellaneous tests located in `tests'
  37812. directory. The lack of a standardized publicly available test suite has
  37813. made it difficult for our users, as well developers, to do regression
  37814. tests on the MySQL code. To address this problem, we have created a new
  37815. test system that is included in the source and binary distributions
  37816. starting in Version 3.23.29.
  37817.  
  37818. The current set of test cases doesn't test everything in MySQL, but it
  37819. should catch most obvious bugs in the SQL processing code, OS/library
  37820. issues, and is quite thorough in testing replication.  Our eventual goal
  37821. is to have the tests cover 100% of the code.  We welcome contributions
  37822. to our test suite.  You may especially want to contribute tests that
  37823. examine the functionality critical to your system, as this will ensure
  37824. that all future MySQL releases will work well with your applications.
  37825.  
  37826. * Menu:
  37827.  
  37828. * running mysqltest::           Running the MySQL Test Suite
  37829. * extending mysqltest::         Extending the MySQL Test Suite
  37830. * Reporting mysqltest bugs::    Reporting Bugs in the MySQL Test Suite
  37831.  
  37832. 
  37833. File: mysql.info,  Node: running mysqltest,  Next: extending mysqltest,  Prev: MySQL test suite,  Up: MySQL test suite
  37834.  
  37835. Running the MySQL Test Suite
  37836. ............................
  37837.  
  37838. The test system consist of a test language interpreter (`mysqltest'), a
  37839. shell script to run all tests(`mysql-test-run'), the actual test cases
  37840. written in a special test language, and their expected results.  To run
  37841. the test suite on your system after a build, type `make test' or
  37842. `mysql-test/mysql-test-run' from the source root.  If you have
  37843. installed a binary distribution, `cd' to the install root (eg.
  37844. `/usr/local/mysql'), and do `scripts/mysql-test-run'.  All tests should
  37845. succeed.  If not, you should try to find out why and report the problem
  37846. if this is a bug in MySQL.  *Note Reporting mysqltest bugs::.
  37847.  
  37848. If you have a copy of `mysqld' running on the machine where you want to
  37849. run the test suite you do not have to stop it, as long as it is not
  37850. using ports `9306' and `9307'.  If one of those ports is taken, you
  37851. should edit `mysql-test-run' and change the values of the master and/or
  37852. slave port to one that is available.
  37853.  
  37854. You can run one individual test case with `mysql-test/mysql-test-run
  37855. test_name'.
  37856.  
  37857. If one test fails, you should test running `mysql-test-run' with the
  37858. `--force' option to check if any other tests fails.
  37859.  
  37860. 
  37861. File: mysql.info,  Node: extending mysqltest,  Next: Reporting mysqltest bugs,  Prev: running mysqltest,  Up: MySQL test suite
  37862.  
  37863. Extending the MySQL Test Suite
  37864. ..............................
  37865.  
  37866. You can use the `mysqltest' language to write your own test cases.
  37867. Unfortunately, we have not yet written full documentation for it - we
  37868. plan to do this shortly.  You can, however, look at our current test
  37869. cases and use them as an example.  The following points should help you
  37870. get started:
  37871.  
  37872.    * The tests are located in `mysql-test/t/*.test'
  37873.  
  37874.    * A test case consists of `;' terminated statements and is similar
  37875.      to the input of `mysql' command line client.  A statement by
  37876.      default is a query to be sent to MySQL server, unless it is
  37877.      recognized as internal command ( eg. `sleep' ).
  37878.  
  37879.    * All queries that produce results, e.g. `SELECT', `SHOW',
  37880.      `EXPLAIN', etc., must be preceded with `@/path/to/result/file'.
  37881.      The file must contain the expected results.  An easy way to
  37882.      generate the result file is to run `mysqltest -r <
  37883.      t/test-case-name.test' from `mysql-test' directory, and then edit
  37884.      the generated result files, if needed, to adjust them to the
  37885.      expected output.  In that case, be very careful about not adding
  37886.      or deleting any invisible characters - make sure to only change
  37887.      the text and/or delete lines.  If you have to insert a line, make
  37888.      sure the fields are separated with a hard tab, and there is a hard
  37889.      tab at the end.  You may want to use `od -c' to make sure your
  37890.      text editor has not messed anything up during edit.  We, of
  37891.      course, hope that you will never have to edit the output of
  37892.      `mysqltest -r' as you only have to do it when you find a bug.
  37893.  
  37894.    * To be consistent with our setup, you should put your result files
  37895.      in `mysql-test/r' directory and name them `test_name.result'.  If
  37896.      the test produces more than one result, you should use
  37897.      `test_name.a.result', `test_name.b.result', etc.
  37898.  
  37899.    * If a statement returns an error, you should on the line before the
  37900.      statement specify with the `--error error-number'.  The error
  37901.      number can be a list of possible error numbers separated with
  37902.      `',''.
  37903.  
  37904.    * If you are writing a replication test case, you should on the
  37905.      first line of the test file, put `source
  37906.      include/master-slave.inc;'.  To switch between master and slave,
  37907.      use `connection master;' and `connection slave;'.  If you need to
  37908.      do something on an alternate connection, you can do `connection
  37909.      master1;' for the master, and `connection slave1;' for the slave.
  37910.  
  37911.    * If you need to do something in a loop, you can use something like
  37912.      this:
  37913.           let $1=1000;
  37914.           while ($1)
  37915.           {
  37916.            # do your queries here
  37917.            dec $1;
  37918.           }
  37919.  
  37920.    * To sleep between queries, use the `sleep' command. It supports
  37921.      fractions of a second, so you can do `sleep 1.3;', for example, to
  37922.      sleep 1.3 seconds.
  37923.  
  37924.    * To run the slave with additional options for your test case, put
  37925.      them in the command-line format in
  37926.      `mysql-test/t/test_name-slave.opt'. For the master, put them in
  37927.      `mysql-test/t/test_name-master.opt'.
  37928.  
  37929.    * If you have a question about the test suite, or have a test case
  37930.      to contribute, e-mail to <internals@lists.mysql.com>. As the list
  37931.      does not accept attachments, you should ftp all the relevant files
  37932.      to: <ftp://support.mysql.com/pub/mysql/Incoming>
  37933.  
  37934.  
  37935. 
  37936. File: mysql.info,  Node: Reporting mysqltest bugs,  Prev: extending mysqltest,  Up: MySQL test suite
  37937.  
  37938. Reporting Bugs in the MySQL Test Suite
  37939. ......................................
  37940.  
  37941. If your MySQL version doesn't pass the test suite you should do the
  37942. following:
  37943.  
  37944.    * Don't send a bug report before you have found out as much as
  37945.      possible of what when wrong!  When you do it, please use the
  37946.      `mysqlbug' script so that we can get information about your system
  37947.      and `MySQL' version. *Note Bug reports::.
  37948.  
  37949.    * Make sure to include the output of `mysql-test-run', as well as
  37950.      contents of all `.reject' files in `mysql-test/r' directory.
  37951.  
  37952.    * If a test in the test suite fails, check if the test fails also
  37953.      when run by its own:
  37954.  
  37955.           cd mysql-test
  37956.           mysql-test-run --local test-name
  37957.  
  37958.      If this fails, then you should configure MySQL with `--with-debug'
  37959.      and run `mysql-test-run' with the `--debug' option. If this also
  37960.      fails send the trace file `var/tmp/master.trace' to
  37961.      ftp://support.mysql.com/pub/mysql/secret so that we can examine
  37962.      it. Please remember to also include a full description of your
  37963.      system, the version of the mysqld binary and how you compiled it.
  37964.  
  37965.    * Try also to run `mysql-test-run' with the `--force' option to see
  37966.      if there is any other test that fails.
  37967.  
  37968.    * If you have compiled MySQL yourself, check our manual for how to
  37969.      compile MySQL on your platform or, preferable, use one of the
  37970.      binaries we have compiled for you at
  37971.      `http://www.mysql.com/downloads/'.  All our standard binaries
  37972.      should pass the test suite !
  37973.  
  37974.    * If you get an error, like `Result length mismatch' or `Result
  37975.      content mismatch' it means that the output of the test didn't match
  37976.      exactly the expected output. This could be a bug in MySQL or that
  37977.      your mysqld version produces slight different results under some
  37978.      circumstances.
  37979.  
  37980.      Failed test results are put in a file with the same base name as
  37981.      the result file with the `.reject' extension.  If your test case is
  37982.      failing, you should do a diff on the two files.  If you cannot see
  37983.      how they are different, examine both with `od -c' and also check
  37984.      their lengths.
  37985.  
  37986.    * If a test fails totally, you should check the logs file in the
  37987.      `mysql-test/var/log' directory for hints of what went wrong.
  37988.  
  37989.    * If you have compiled MySQL with debugging you can try to debug this
  37990.      by running `mysql-test-run' with the `--gdb' and/or `--debug'
  37991.      options.  *Note Making trace files::.
  37992.  
  37993.      If you have not compiled MySQL for debugging you should probably
  37994.      do that.  Just specify the `--with-debug' options to `configure'!
  37995.      *Note Installing source::.
  37996.  
  37997. 
  37998. File: mysql.info,  Node: Problems,  Next: Users,  Prev: Extending MySQL,  Up: Top
  37999.  
  38000. Problems and Common Errors
  38001. **************************
  38002.  
  38003. * Menu:
  38004.  
  38005. * What is crashing::            How to determine what is causing problems
  38006. * Common errors::               Some common errors when using MySQL
  38007. * Installation Issues::         Installation Related Issues
  38008. * Administration Issues::       Administration Related Issues
  38009. * Query Issues::                Query Related Issues
  38010. * Table Definition Issues::     Table Definition Related Issues
  38011.  
  38012. This chapter lists some common problems and error messages that users
  38013. have run into.  You will learn how to figure out what the problem is,
  38014. and what to do to solve it.  You will also find proper solutions to
  38015. some common problems.
  38016.  
  38017. 
  38018. File: mysql.info,  Node: What is crashing,  Next: Common errors,  Prev: Problems,  Up: Problems
  38019.  
  38020. How to Determine What Is Causing Problems
  38021. =========================================
  38022.  
  38023. When you run into problems, the first thing you should do is to find out
  38024. which program / piece of equipment is causing problems:
  38025.  
  38026.    * If you have one of the following symptoms, then it is probably a
  38027.      hardware (like memory, motherboard, CPU, or hard disk) or kernel
  38028.      problem:
  38029.         - The keyboard doesn't work.  This can normally be checked by
  38030.           pressing Caps Lock. If the Caps Lock light doesn't change you
  38031.           have to replace your keyboard.  (Before doing this, you
  38032.           should try to reboot your computer and check all cables to
  38033.           the keyboard.)
  38034.  
  38035.         - The mouse pointer doesn't move.
  38036.  
  38037.         - The machine doesn't answer to a remote machine's pings.
  38038.  
  38039.         - Different, unrelated programs don't behave correctly.
  38040.  
  38041.         - If your system rebooted unexpectedly (a faulty user level
  38042.           program should NEVER be able to take down your system).
  38043.  
  38044.      In this case you should start by checking all your cables and run
  38045.      some diagnostic tool to check your hardware!  You should also
  38046.      check if there are any patches, updates, or service packs for your
  38047.      operating system that could likely solve your problems.  Check
  38048.      also that all your libraries (like glibc) are up to date.
  38049.  
  38050.      It's always good to use a machine with ECC memory to discover
  38051.      memory problems early!
  38052.  
  38053.    * If your keyboard is locked up, you may be able to fix this by
  38054.      logging into your machine from another machine and execute
  38055.      `kbd_mode -a' on it.
  38056.  
  38057.    * Please examine your system log file (/var/log/messages or similar)
  38058.      for reasons for your problems.  If you think the problem is in
  38059.      MySQL then you should also examine MySQL's log files. *Note Update
  38060.      log::.
  38061.  
  38062.    * If you don't think you have hardware problems, you should try to
  38063.      find out which program is causing problems.
  38064.  
  38065.      Try using `top', `ps', `taskmanager', or some similar program, to
  38066.      check which program is taking all CPU or is locking the machine.
  38067.  
  38068.    * Check with `top', `df', or a similar program if you are out of
  38069.      memory, disk space, open files, or some other critical resource.
  38070.  
  38071.    * If the problem is some runaway process, you can always try to kill
  38072.      it. If it doesn't want to die, there is probably a bug in the
  38073.      operating system.
  38074.  
  38075. If after you have examined all other possibilities and you have
  38076. concluded that it's the MySQL server or a MySQL client that is causing
  38077. the problem, it's time to do a bug report for our mailing list or our
  38078. support team.  In the bug report, try to give a very detailed
  38079. description of how the system is behaving and what you think is
  38080. happening. You should also state why you think it's MySQL that is
  38081. causing the problems.  Take into consideration all the situations in
  38082. this chapter. State any problems exactly how they appear when you
  38083. examine your system. Use the 'cut and paste' method for any output
  38084. and/or error messages from programs and/or log files!
  38085.  
  38086. Try to describe in detail which program is not working and all symptoms
  38087. you see!  We have in the past received many bug reports that just state
  38088. "the system doesn't work".  This doesn't provide us with any
  38089. information about what could be the problem.
  38090.  
  38091. If a program fails, it's always useful to know:
  38092.  
  38093.    * Has the program in question made a segmentation fault (core
  38094.      dumped)?
  38095.  
  38096.    * Is the program taking the whole CPU? Check with `top'. Let the
  38097.      program run for a while, it may be evaluating something heavy.
  38098.  
  38099.    * If it's the `mysqld' server that is causing problems, can you do
  38100.      `mysqladmin -u root ping' or `mysqladmin -u root processlist'?
  38101.  
  38102.    * What does a client program say (try with `mysql', for example)
  38103.      when you try to connect to the MySQL server?  Does the client jam?
  38104.      Do you get any output from the program?
  38105.  
  38106. When sending a bug report, you should of follow the outlines described
  38107. in this manual. *Note Asking questions::.
  38108.  
  38109. 
  38110. File: mysql.info,  Node: Common errors,  Next: Installation Issues,  Prev: What is crashing,  Up: Problems
  38111.  
  38112. Some Common Errors When Using MySQL
  38113. ===================================
  38114.  
  38115. * Menu:
  38116.  
  38117. * Error Access denied::         `Access denied' Error
  38118. * Gone away::                   `MySQL server has gone away' error
  38119. * Can not connect to server::   `Can't connect to [local] MySQL server' error
  38120. * Blocked host::                `Host '...' is blocked' error
  38121. * Too many connections::        `Too many connections' error
  38122. * Non-transactional tables::    `Some non-transactional changed tables couldn't be rolled back' Error
  38123. * Out of memory::               `Out of memory' error
  38124. * Packet too large::            `Packet too large' error
  38125. * Communication errors::        Communication errors / Aborted connection
  38126. * Full table::                  `The table is full' error
  38127. * Cannot create::               `Can't create/write to file' Error
  38128. * Commands out of sync::        `Commands out of sync' error in client
  38129. * Ignoring user::               `Ignoring user' error
  38130. * Cannot find table::           `Table 'xxx' doesn't exist' error
  38131. * Cannot initialize character set::  `Cant' initialize character set xxx' error.
  38132. * Not enough file handles::     File Not Found
  38133.  
  38134. This section lists some errors that users frequently get.  You will find
  38135. descriptions of the errors, and how to solve the problem here.
  38136.  
  38137. 
  38138. File: mysql.info,  Node: Error Access denied,  Next: Gone away,  Prev: Common errors,  Up: Common errors
  38139.  
  38140. `Access denied' Error
  38141. ---------------------
  38142.  
  38143. *Note Privileges::, and especially. *Note Access denied::.
  38144.  
  38145. 
  38146. File: mysql.info,  Node: Gone away,  Next: Can not connect to server,  Prev: Error Access denied,  Up: Common errors
  38147.  
  38148. `MySQL server has gone away' Error
  38149. ----------------------------------
  38150.  
  38151. This section also covers the related `Lost connection to server during
  38152. query' error.
  38153.  
  38154. The most common reason for the `MySQL server has gone away' error is
  38155. that the server timed out and closed the connection. By default, the
  38156. server closes the connection after 8 hours if nothing has happened. You
  38157. can change the time limit by setting the `wait_timeout' variable when
  38158. you start `mysqld'.
  38159.  
  38160. Another common reason to receive the `MySQL server has gone away' error
  38161. is because you have issued a "close" on your MySQL connection and then
  38162. tried to run a query on the closed connection.
  38163.  
  38164. You can check that the MySQL hasn't died by executing `mysqladmin
  38165. version' and examining the uptime.
  38166.  
  38167. If you have a script, you just have to issue the query again for the
  38168. client to do an automatic reconnection.
  38169.  
  38170. You normally can get the following error codes in this case (which one
  38171. you get is OS-dependent):
  38172.  
  38173. `CR_SERVER_GONE_ERROR' The client couldn't send a question to the server.
  38174. `CR_SERVER_LOST'       The client didn't get an error when writing to
  38175.                        the server, but it didn't get a full answer (or
  38176.                        any answer) to the question.
  38177.  
  38178. You can also get these errors if you send a query to the server that is
  38179. incorrect or too large. If `mysqld' gets a packet that is too large or
  38180. out of order, it assumes that something has gone wrong with the client
  38181. and closes the connection.  If you need big queries (for example, if
  38182. you are working with big `BLOB' columns), you can increase the query
  38183. limit by starting `mysqld' with the `-O max_allowed_packet=#' option
  38184. (default 1M). The extra memory is allocated on demand, so `mysqld' will
  38185. use more memory only when you issue a big query or when `mysqld' must
  38186. return a big result row!
  38187.  
  38188. 
  38189. File: mysql.info,  Node: Can not connect to server,  Next: Blocked host,  Prev: Gone away,  Up: Common errors
  38190.  
  38191. `Can't connect to [local] MySQL server' error
  38192. ---------------------------------------------
  38193.  
  38194. A MySQL client on Unix can connect to the `mysqld' server in two
  38195. different ways: Unix sockets, which connect through a file in the file
  38196. system (default `/tmp/mysqld.sock') or TCP/IP, which connects through a
  38197. port number.  Unix sockets are faster than TCP/IP but can only be used
  38198. when connecting to a server on the same computer.  Unix sockets are
  38199. used if you don't specify a hostname or if you specify the special
  38200. hostname `localhost'.
  38201.  
  38202. On Windows you can connect only with TCP/IP if the `mysqld' server is
  38203. running on Win95/Win98. If mysqld is running on NT and started with
  38204. `enable-named-pipe', you can also connect with named pipes.  The name
  38205. of the named pipe is MySQL.  If you don't give a hostname when
  38206. connecting to `mysqld', a MySQL client will first try to connect to the
  38207. named pipe, and if this doesn't work it will connect to the TCP/IP
  38208. port.  You can force the use of named pipes on Windows by using `.' as
  38209. the hostname.
  38210.  
  38211. The error (2002) `Can't connect to ...' normally means that there isn't
  38212. a MySQL server running on the system or that you are using a wrong
  38213. socket file or TCP/IP port when trying to connect to the `mysqld'
  38214. server.
  38215.  
  38216. Start by checking (using `ps' or the task manager on Windows) that
  38217. there is a process running named `mysqld' on your server!  If there
  38218. isn't any `mysqld' process, you should start one. *Note Starting
  38219. server::.
  38220.  
  38221. If a `mysqld' process is running, you can check the server by trying
  38222. these different connections (the port number and socket pathname might
  38223. be different in your setup, of course):
  38224.  
  38225.      shell> mysqladmin version
  38226.      shell> mysqladmin variables
  38227.      shell> mysqladmin -h `hostname` version variables
  38228.      shell> mysqladmin -h `hostname` --port=3306 version
  38229.      shell> mysqladmin -h 'ip for your host' version
  38230.      shell> mysqladmin --socket=/tmp/mysql.sock version
  38231.  
  38232. Note the use of backquotes rather than forward quotes with the
  38233. `hostname' command; these cause the output of `hostname' (that is, the
  38234. current hostname) to be substituted into the `mysqladmin' command.
  38235.  
  38236. Here are some reasons the `Can't connect to local MySQL server' error
  38237. might occur:
  38238.  
  38239.    * `mysqld' is not running.
  38240.  
  38241.    * You are running on a system that uses MIT-pthreads.  If you are
  38242.      running on a system that doesn't have native threads, `mysqld'
  38243.      uses the MIT-pthreads package.  *Note Which OS::.  However, all
  38244.      MIT-pthreads versions doesn't support Unix sockets. On a system
  38245.      without sockets support you must always specify the hostname
  38246.      explicitly when connecting to the server. Try using this command
  38247.      to check the connection to the server:
  38248.           shell> mysqladmin -h `hostname` version
  38249.  
  38250.    * Someone has removed the Unix socket that `mysqld' uses (default
  38251.      `/tmp/mysqld.sock').  You might have a `cron' job that removes the
  38252.      MySQL socket (for example, a job that removes old files from the
  38253.      `/tmp' directory).  You can always run `mysqladmin version' and
  38254.      check that the socket `mysqladmin' is trying to use really exists.
  38255.      The fix in this case is to change the `cron' job to not remove
  38256.      `mysqld.sock' or to place the socket somewhere else.  *Note
  38257.      Problems with mysql.sock::.
  38258.  
  38259.    * You have started the `mysqld' server with the
  38260.      `--socket=/path/to/socket' option.  If you change the socket
  38261.      pathname for the server, you must also notify the MySQL clients
  38262.      about the new path. You can do this by providing the socket path
  38263.      as an argument to the client. *Note Problems with mysql.sock::.
  38264.  
  38265.    * You are using Linux and one thread has died (core dumped).  In
  38266.      this case you must kill the other `mysqld' threads (for example,
  38267.      with the `mysql_zap' script before you can start a new MySQL
  38268.      server.  *Note Crashing::.
  38269.  
  38270.    * You may not have read and write privilege to either the directory
  38271.      that holds the socket file or privilege to the socket file itself.
  38272.      In this case you have to either change the privilege for the
  38273.      directory / file or restart `mysqld' so that it uses a directory
  38274.      that you can access.
  38275.  
  38276. If you get the error message `Can't connect to MySQL server on
  38277. some_hostname', you can try the following things to find out what the
  38278. problem is :
  38279.  
  38280.    * Check if the server is up by doing `telnet your-host-name
  38281.      tcp-ip-port-number' and press `RETURN' a couple of times.  If there
  38282.      is a MySQL server running on this port you should get a responses
  38283.      that includes the version number of the running MySQL server.  If
  38284.      you get an error like `telnet: Unable to connect to remote host:
  38285.      Connection refused', then there is no server running on the given
  38286.      port.
  38287.  
  38288.    * Try connecting to the `mysqld' daemon on the local machine and
  38289.      check the TCP/IP port that `mysqld' it's configured to use
  38290.      (variable `port') with `mysqladmin variables'.
  38291.  
  38292.    * Check that your `mysqld' server is not started with the
  38293.      `--skip-networking' option.
  38294.  
  38295. 
  38296. File: mysql.info,  Node: Blocked host,  Next: Too many connections,  Prev: Can not connect to server,  Up: Common errors
  38297.  
  38298. `Host '...' is blocked' Error
  38299. -----------------------------
  38300.  
  38301. If you get an error like this:
  38302.  
  38303.      Host 'hostname' is blocked because of many connection errors.
  38304.      Unblock with 'mysqladmin flush-hosts'
  38305.  
  38306. this means that `mysqld' has gotten a lot (`max_connect_errors') of
  38307. connect requests from the host `'hostname'' that have been interrupted
  38308. in the middle. After `max_connect_errors' failed requests, `mysqld'
  38309. assumes that something is wrong (like an attack from a cracker), and
  38310. blocks the site from further connections until someone executes the
  38311. command `mysqladmin flush-hosts'.
  38312.  
  38313. By default, `mysqld' blocks a host after 10 connection errors.  You can
  38314. easily adjust this by starting the server like this:
  38315.  
  38316.      shell> safe_mysqld -O max_connect_errors=10000 &
  38317.  
  38318. Note that if you get this error message for a given host, you should
  38319. first check that there isn't anything wrong with TCP/IP connections
  38320. from that host.  If your TCP/IP connections aren't working, it won't do
  38321. you any good to increase the value of the `max_connect_errors' variable!
  38322.  
  38323. 
  38324. File: mysql.info,  Node: Too many connections,  Next: Non-transactional tables,  Prev: Blocked host,  Up: Common errors
  38325.  
  38326. `Too many connections' Error
  38327. ----------------------------
  38328.  
  38329. If you get the error `Too many connections' when you try to connect to
  38330. MySQL, this means that there is already `max_connections' clients
  38331. connected to the `mysqld' server.
  38332.  
  38333. If you need more connections than the default (100), then you should
  38334. restart `mysqld' with a bigger value for the `max_connections' variable.
  38335.  
  38336. Note that `mysqld' actually allows (`max_connections'+1) clients to
  38337. connect.  The last connection is reserved for a user with the *process*
  38338. privilege.  By not giving this privilege to normal users (they
  38339. shouldn't need this), an administrator with this privilege can log in
  38340. and use `SHOW PROCESSLIST' to find out what could be wrong. *Note
  38341. SHOW::.
  38342.  
  38343. The maximum number of connects MySQL is depending on how good the
  38344. thread library is on a given platform. Linux or Solaris should be able
  38345. to support 500-1000 simultaneous connections, depending on how much RAM
  38346. you have and what your clients are doing.
  38347.  
  38348. 
  38349. File: mysql.info,  Node: Non-transactional tables,  Next: Out of memory,  Prev: Too many connections,  Up: Common errors
  38350.  
  38351. `Some non-transactional changed tables couldn't be rolled back' Error
  38352. ---------------------------------------------------------------------
  38353.  
  38354. If you get the error/warning: `Warning: Some non-transactional changed
  38355. tables couldn't be rolled back' when trying to do a `ROLLBACK', this
  38356. means that some of the tables you used in the transaction didn't
  38357. support transactions.  These non-transactional tables will not be
  38358. affected by the `ROLLBACK' statement.
  38359.  
  38360. The most typical case when this happens is when you have tried to create
  38361. a table of a type that is not supported by your `mysqld' binary.  If
  38362. `mysqld' doesn't support a table type (or if the table type is disabled
  38363. by a startup option) , it will instead create the table type with the
  38364. table type that is most resembles to the one you requested, probably
  38365. `MyISAM'.
  38366.  
  38367. You can check the table type for a table by doing:
  38368.  
  38369. `SHOW TABLE STATUS LIKE 'table_name''. *Note SHOW TABLE STATUS::.
  38370.  
  38371. You can check the extensions your `mysqld' binary supports by doing:
  38372.  
  38373. `show variables like 'have_%''. *Note SHOW VARIABLES::.
  38374.  
  38375. 
  38376. File: mysql.info,  Node: Out of memory,  Next: Packet too large,  Prev: Non-transactional tables,  Up: Common errors
  38377.  
  38378. `Out of memory' Error
  38379. ---------------------
  38380.  
  38381. If you issue a query and get something like the following error:
  38382.  
  38383.      mysql: Out of memory at line 42, 'malloc.c'
  38384.      mysql: needed 8136 byte (8k), memory in use: 12481367 bytes (12189k)
  38385.      ERROR 2008: MySQL client ran out of memory
  38386.  
  38387. note that the error refers to the MySQL client `mysql'. The reason for
  38388. this error is simply that the client does not have enough memory to
  38389. store the whole result.
  38390.  
  38391. To remedy the problem, first check that your query is correct. Is it
  38392. reasonable that it should return so many rows?  If so, you can use
  38393. `mysql --quick', which uses `mysql_use_result()' to retrieve the result
  38394. set.  This places less of a load on the client (but more on the server).
  38395.  
  38396. 
  38397. File: mysql.info,  Node: Packet too large,  Next: Communication errors,  Prev: Out of memory,  Up: Common errors
  38398.  
  38399. `Packet too large' Error
  38400. ------------------------
  38401.  
  38402. When a MySQL client or the `mysqld' server gets a packet bigger than
  38403. `max_allowed_packet' bytes, it issues a `Packet too large' error and
  38404. closes the connection.
  38405.  
  38406. If you are using the `mysql' client, you may specify a bigger buffer by
  38407. starting the client with `mysql --set-variable=max_allowed_packet=8M'.
  38408.  
  38409. If you are using other clients that do not allow you to specify the
  38410. maximum packet size (such as `DBI'), you need to set the packet size
  38411. when you start the server.  You cau use a command-line option to
  38412. `mysqld' to set `max_allowed_packet' to a larger size.  For example, if
  38413. you are expecting to store the full length of a `BLOB' into a table,
  38414. you'll need to start the server with the
  38415. `--set-variable=max_allowed_packet=16M' option.
  38416.  
  38417. You can also get strange problems with large packets if you are using
  38418. big blobs, but you haven't given `mysqld' access to enough memory to
  38419. handle the query.  If you suspect this is the case, try adding `ulimit
  38420. -d 256000' to the beginning of the `safe_mysqld' script and restart
  38421. `mysqld'.
  38422.  
  38423. 
  38424. File: mysql.info,  Node: Communication errors,  Next: Full table,  Prev: Packet too large,  Up: Common errors
  38425.  
  38426. Communication Errors / Aborted Connection
  38427. -----------------------------------------
  38428.  
  38429. Starting with `MySQL 3.23.40' you only get the `Aborted connection'
  38430. error of you start `mysqld' with `--warnings'.
  38431.  
  38432. If you find errors like the following in your error log.
  38433.  
  38434.      010301 14:38:23  Aborted connection 854 to db: 'users' user: 'josh'
  38435.  
  38436. *Note Error log::.
  38437.  
  38438. This means that something of the following has happened:
  38439.  
  38440.    * The client program did not call `mysql_close()' before exit.
  38441.  
  38442.    * The client had been sleeping more than `wait_timeout' or
  38443.      `interactive_timeout' without doing any requests. *Note SHOW
  38444.      VARIABLES::.
  38445.  
  38446.    * The client program ended abruptly in the middle of the transfer.
  38447.  
  38448. When the above happens, the server variable `Aborted_clients' is
  38449. incremented.
  38450.  
  38451. The server variable `Aborted_connects' is incremented when:
  38452.  
  38453.    * When a connection packet doesn't contain the right information.
  38454.  
  38455.    * When the user didn't have privileges to connect to a database.
  38456.  
  38457.    * When a user uses a wrong password.
  38458.  
  38459.    * When it takes more than `connect_timeout' seconds to get a connect
  38460.      package.
  38461.  
  38462. Note that the above could indicate that someone is trying to break into
  38463. your database!
  38464.  
  38465. *Note SHOW VARIABLES::.
  38466.  
  38467. Other reasons for problems with Aborted clients / Aborted connections.
  38468.    * Usage of duplex Ethernet protocol, both half and full with Linux.
  38469.      Many Linux Ethernet drivers have this bug. You should test for
  38470.      this bug by transferring a huge file via ftp between these two
  38471.      machines. If a transfer goes in burst-pause-burst-pause ... mode
  38472.      then you are experiencing a Linux duplex syndrome. The only
  38473.      solution to this problem is switching of both half and full
  38474.      duplexing on hubs and switches.
  38475.  
  38476.    * Some problem with the thread library that causes interrupts on
  38477.      reads.
  38478.  
  38479.    * Badly configured TCP/IP.
  38480.  
  38481.    * Faulty Ethernets or hubs or switches, cables ... This can be
  38482.      diagnosed properly only by replacing hardware.
  38483.  
  38484.    * `max_allowed_packet' is too small or queries require more memory
  38485.      than you have alloacated for `mysqld'. *Note Packet too large::.
  38486.  
  38487. 
  38488. File: mysql.info,  Node: Full table,  Next: Cannot create,  Prev: Communication errors,  Up: Common errors
  38489.  
  38490. `The table is full' Error
  38491. -------------------------
  38492.  
  38493. This error occurs in older MySQL versions when an in-memory temporary
  38494. table becomes larger than `tmp_table_size' bytes. To avoid this
  38495. problem, you can use the `-O tmp_table_size=#' option to `mysqld' to
  38496. increase the temporary table size or use the SQL option
  38497. `SQL_BIG_TABLES' before you issue the problematic query. *Note `SET
  38498. OPTION': SET OPTION.
  38499.  
  38500. You can also start `mysqld' with the `--big-tables' option.  This is
  38501. exactly the same as using `SQL_BIG_TABLES' for all queries.
  38502.  
  38503. In MySQL Version 3.23, in-memory temporary tables will automatically be
  38504. converted to a disk-based `MyISAM' table after the table size gets
  38505. bigger than `tmp_table_size'.
  38506.  
  38507. 
  38508. File: mysql.info,  Node: Cannot create,  Next: Commands out of sync,  Prev: Full table,  Up: Common errors
  38509.  
  38510. `Can't create/write to file' Error
  38511. ----------------------------------
  38512.  
  38513. If you get an error for some queries of type:
  38514.  
  38515.      Can't create/write to file '\\sqla3fe_0.ism'.
  38516.  
  38517. this means that MySQL can't create a temporary file for the result set
  38518. in the given temporary directory. (The above error is a typical error
  38519. message on Windows, and the Unix error message is similar.)  The fix is
  38520. to start `mysqld' with `--tmpdir=path' or to add to your option file:
  38521.  
  38522.      [mysqld]
  38523.      tmpdir=C:/temp
  38524.  
  38525. assuming that the `c:\\temp' directory exists. *Note Option files::.
  38526.  
  38527. Check also the error code that you get with `perror'. One reason may
  38528. also be a disk full error;
  38529.  
  38530.      shell> perror 28
  38531.      Error code  28:  No space left on device
  38532.  
  38533. 
  38534. File: mysql.info,  Node: Commands out of sync,  Next: Ignoring user,  Prev: Cannot create,  Up: Common errors
  38535.  
  38536. `Commands out of sync' Error in Client
  38537. --------------------------------------
  38538.  
  38539. If you get `Commands out of sync; You can't run this command now' in
  38540. your client code, you are calling client functions in the wrong order!
  38541.  
  38542. This can happen, for example, if you are using `mysql_use_result()' and
  38543. try to execute a new query before you have called `mysql_free_result()'.
  38544. It can also happen if you try to execute two queries that return data
  38545. without a `mysql_use_result()' or `mysql_store_result()' in between.
  38546.  
  38547. 
  38548. File: mysql.info,  Node: Ignoring user,  Next: Cannot find table,  Prev: Commands out of sync,  Up: Common errors
  38549.  
  38550. `Ignoring user' Error
  38551. ---------------------
  38552.  
  38553. If you get the following error:
  38554.  
  38555. `Found wrong password for user: 'some_user@some_host'; Ignoring user'
  38556.  
  38557. this means that when `mysqld' was started or when it reloaded the
  38558. permissions tables, it found an entry in the `user' table with an
  38559. invalid password.  As a result, the entry is simply ignored by the
  38560. permission system.
  38561.  
  38562. Possible causes of and fixes for this problem:
  38563.  
  38564.    * You may be running a new version of `mysqld' with an old `user'
  38565.      table.  You can check this by executing `mysqlshow mysql user' to
  38566.      see if the password field is shorter than 16 characters. If so,
  38567.      you can correct this condition by running the
  38568.      `scripts/add_long_password' script.
  38569.  
  38570.    * The user has an old password (8 characters long) and you didn't
  38571.      start `mysqld' with the `--old-protocol' option.  Update the user
  38572.      in the `user' table with a new password or restart `mysqld' with
  38573.      `--old-protocol'.
  38574.  
  38575.    * You have specified a password in the `user' table without using the
  38576.      `PASSWORD()' function.  Use `mysql' to update the user in the
  38577.      `user' table with a new password. Make sure to use the `PASSWORD()'
  38578.      function:
  38579.  
  38580.           mysql> update user set password=PASSWORD('your password')
  38581.                      where user='XXX';
  38582.  
  38583. 
  38584. File: mysql.info,  Node: Cannot find table,  Next: Cannot initialize character set,  Prev: Ignoring user,  Up: Common errors
  38585.  
  38586. `Table 'xxx' doesn't exist' Error
  38587. ---------------------------------
  38588.  
  38589. If you get the error `Table 'xxx' doesn't exist' or `Can't find file:
  38590. 'xxx' (errno: 2)', this means that no table exists in the current
  38591. database with the name `xxx'.
  38592.  
  38593. Note that as MySQL uses directories and files to store databases and
  38594. tables, the database and table names are *case sensitive*!  (On Windows
  38595. the databases and tables names are not case sensitive, but all
  38596. references to a given table within a query must use the same case!)
  38597.  
  38598. You can check which tables you have in the current database with `SHOW
  38599. TABLES'. *Note `SHOW': SHOW.
  38600.  
  38601. 
  38602. File: mysql.info,  Node: Cannot initialize character set,  Next: Not enough file handles,  Prev: Cannot find table,  Up: Common errors
  38603.  
  38604. `Cant' initialize character set xxx' error.
  38605. -------------------------------------------
  38606.  
  38607. If you get an error like:
  38608.  
  38609.      MySQL Connection Failed: Can't initialize character set xxx
  38610.  
  38611. This means one of the following things:
  38612.  
  38613.    * The character set is a multi-byte character set and you have not
  38614.      support for the character set in the client.
  38615.  
  38616.      In this case you need to recompile the client with
  38617.      `--with-charset=xxx' or with `--with-extra-charsets=xxx'.  *Note
  38618.      configure options::.
  38619.  
  38620.      All standard MySQL binaries are compiled with
  38621.      `--with-extra-character-sets=complex' which will enable support for
  38622.      all multi-byte character sets. *Note Character sets::.
  38623.  
  38624.    * The character set is a simple character set which is not compiled
  38625.      into `mysqld' and the character set definition files is not in the
  38626.      place where the client expect to find them.
  38627.  
  38628.      In this case you need to:
  38629.  
  38630.         * Recompile the client with support for the character set.
  38631.           *Note configure options::.
  38632.  
  38633.         * Specify to the client where the character set definition
  38634.           files are. For many client you can do this with the
  38635.           `--character-sets-dir=path-to-charset-dir' option.
  38636.  
  38637.         * Copy the character definition files to the path where the
  38638.           client expect them to be.
  38639.  
  38640. 
  38641. File: mysql.info,  Node: Not enough file handles,  Prev: Cannot initialize character set,  Up: Common errors
  38642.  
  38643. File Not Found
  38644. --------------
  38645.  
  38646. If you get `ERROR '...' not found (errno: 23)', `Can't open file: ...
  38647. (errno: 24)', or any other error with `errno 23' or `errno 24' from
  38648. MySQL, it means that you haven't allocated enough file descriptors for
  38649. MySQL.  You can use the `perror' utility to get a description of what
  38650. the error number means:
  38651.  
  38652.      shell> perror 23
  38653.      File table overflow
  38654.      shell> perror 24
  38655.      Too many open files
  38656.      shell> perror 11
  38657.      Resource temporarily unavailable
  38658.  
  38659. The problem here is that `mysqld' is trying to keep open too many files
  38660. simultaneously.  You can either tell `mysqld' not to open so many files
  38661. at once or increase the number of file descriptors available to
  38662. `mysqld'.
  38663.  
  38664. To tell `mysqld' to keep open fewer files at a time, you can make the
  38665. table cache smaller by using the `-O table_cache=32' option to
  38666. `safe_mysqld' (the default value is 64). Reducing the value of
  38667. `max_connections' will also reduce the number of open files (the
  38668. default value is 90).
  38669.  
  38670. To change the number of file descriptors available to `mysqld', you can
  38671. use the option `--open-files-limit=#' to `safe_mysqld' or `-O
  38672. open-files-limit=#' to `mysqld'. *Note SHOW VARIABLES::.  The easiest
  38673. way to do that is to add the option to your option file.  *Note Option
  38674. files::.  If you have an old `mysqld' version that doesn't support
  38675. this, you can edit the `safe_mysqld' script.  There is a commented-out
  38676. line `ulimit -n 256' in the script.  You can remove the `'#'' character
  38677. to uncomment this line, and change the number 256 to affect the number
  38678. of file descriptors available to `mysqld'.
  38679.  
  38680. `ulimit' (and `open-files-limit') can increase the number of file
  38681. descriptors, but only up to the limit imposed by the operating system.
  38682. There is also a 'hard' limit that can only be overrided if you start
  38683. `safe_mysqld' or `mysqld' as root (Just remember that you need to also
  38684. use the `--user=..' option in this case).  If you need to increase the
  38685. OS limit on the number of file descriptors available to each process,
  38686. consult the documentation for your operating system.
  38687.  
  38688. Note that if you run the `tcsh' shell, `ulimit' will not work!  `tcsh'
  38689. will also report incorrect values when you ask for the current limits!
  38690. In this case you should start `safe_mysqld' with `sh'!
  38691.  
  38692. 
  38693. File: mysql.info,  Node: Installation Issues,  Next: Administration Issues,  Prev: Common errors,  Up: Problems
  38694.  
  38695. Installation Related Issues
  38696. ===========================
  38697.  
  38698. * Menu:
  38699.  
  38700. * Link errors::                 Problems When Linking with the MySQL Client Library
  38701. * Changing MySQL user::         How to Run MySQL As a Normal User
  38702. * File permissions ::           Problems with File Permissions
  38703.  
  38704. 
  38705. File: mysql.info,  Node: Link errors,  Next: Changing MySQL user,  Prev: Installation Issues,  Up: Installation Issues
  38706.  
  38707. Problems When Linking with the MySQL Client Library
  38708. ---------------------------------------------------
  38709.  
  38710. If you are linking your program and you get errors for unreferenced
  38711. symbols that start with `mysql_', like the following:
  38712.  
  38713.      /tmp/ccFKsdPa.o: In function `main':
  38714.      /tmp/ccFKsdPa.o(.text+0xb): undefined reference to `mysql_init'
  38715.      /tmp/ccFKsdPa.o(.text+0x31): undefined reference to `mysql_real_connect'
  38716.      /tmp/ccFKsdPa.o(.text+0x57): undefined reference to `mysql_real_connect'
  38717.      /tmp/ccFKsdPa.o(.text+0x69): undefined reference to `mysql_error'
  38718.      /tmp/ccFKsdPa.o(.text+0x9a): undefined reference to `mysql_close'
  38719.  
  38720. you should be able to solve this by adding `-Lpath-to-the-mysql-library
  38721. -lmysqlclient' *LAST* on your link line.
  38722.  
  38723. If you get `undefined reference' errors for the `uncompress' or
  38724. `compress' function, add `-lz' *LAST* on your link line and try again!
  38725.  
  38726. If you get `undefined reference' errors for functions that should exist
  38727. on your system, like `connect', check the man page for the function in
  38728. question, for which libraries you should add to the link line!
  38729.  
  38730. If you get `undefined reference' errors for functions that don't exist
  38731. on your system, like the following:
  38732.  
  38733.      mf_format.o(.text+0x201): undefined reference to `__lxstat'
  38734.  
  38735. it usually means that your library is compiled on a system that is not
  38736. 100 % compatible with yours.  In this case you should download the
  38737. latest MySQL source distribution and compile this yourself.  *Note
  38738. Installing source::.
  38739.  
  38740. If you are trying to run a program and you then get errors for
  38741. unreferenced symbols that start with `mysql_' or that the `mysqlclient'
  38742. library can't be found, this means that your system can't find the
  38743. share `libmysqlclient.so' library.
  38744.  
  38745. The fix for this is to tell your system to search after shared
  38746. libraries where the library is located by one of the following methods:
  38747.  
  38748.    * Add the path to the directory where you have `libmysqlclient.so'
  38749.      the `LD_LIBRARY_PATH' environment variable.
  38750.  
  38751.    * Add the path to the directory where you have `libmysqlclient.so'
  38752.      the `LD_LIBRARY' environment variable.
  38753.  
  38754.    * Copy `libmysqlclient.so' to some place that is searched by your
  38755.      system, like `/lib', and update the shared library information by
  38756.      executing `ldconfig'.
  38757.  
  38758. Another way to solve this problem is to link your program statically,
  38759. with `-static', or by removing the dynamic MySQL libraries before
  38760. linking your code. In the second case you should be sure that no other
  38761. programs are using the dynamic libraries!
  38762.  
  38763. 
  38764. File: mysql.info,  Node: Changing MySQL user,  Next: File permissions,  Prev: Link errors,  Up: Installation Issues
  38765.  
  38766. How to Run MySQL As a Normal User
  38767. ---------------------------------
  38768.  
  38769. The MySQL server `mysqld' can be started and run by any user.  In order
  38770. to change `mysqld' to run as a Unix user `user_name', you must do the
  38771. following:
  38772.  
  38773.   1. Stop the server if it's running (use `mysqladmin shutdown').
  38774.  
  38775.   2. Change the database directories and files so that `user_name' has
  38776.      privileges to read and write files in them (you may need to do
  38777.      this as the Unix `root' user):
  38778.  
  38779.           shell> chown -R user_name /path/to/mysql/datadir
  38780.  
  38781.      If directories or files within the MySQL data directory are
  38782.      symlinks, you'll also need to follow those links and change the
  38783.      directories and files they point to.  `chown -R' may not follow
  38784.      symlinks for you.
  38785.  
  38786.   3. Start the server as user `user_name', or, if you are using MySQL
  38787.      Version 3.22 or later, start `mysqld' as the Unix `root' user and
  38788.      use the `--user=user_name' option.  `mysqld' will switch to run as
  38789.      the Unix user `user_name' before accepting any connections.
  38790.  
  38791.   4. To start the server as the given user name automatically at system
  38792.      startup time, add a `user' line that specifies the user name to
  38793.      the `[mysqld]' group of the `/etc/my.cnf' option file or the
  38794.      `my.cnf' option file in the server's data directory. For example:
  38795.  
  38796.           [mysqld]
  38797.           user=user_name
  38798.  
  38799. At this point, your `mysqld' process should be running fine and dandy as
  38800. the Unix user `user_name'. One thing hasn't changed, though: the
  38801. contents of the permissions tables. By default (right after running the
  38802. permissions table install script `mysql_install_db'), the MySQL user
  38803. `root' is the only user with permission to access the `mysql' database
  38804. or to create or drop databases.  Unless you have changed those
  38805. permissions, they still hold. This shouldn't stop you from accessing
  38806. MySQL as the MySQL `root' user when you're logged in as a Unix user
  38807. other than `root'; just specify the `-u root' option to the client
  38808. program.
  38809.  
  38810. Note that accessing MySQL as `root', by supplying `-u root' on the
  38811. command line, has _nothing_ to do with MySQL running as the Unix `root'
  38812. user, or, indeed, as another Unix user. The access permissions and user
  38813. names of MySQL are completely separate from Unix user names. The only
  38814. connection with Unix user names is that if you don't provide a `-u'
  38815. option when you invoke a client program, the client will try to connect
  38816. using your Unix login name as your MySQL user name.
  38817.  
  38818. If your Unix box itself isn't secured, you should probably at least put
  38819. a password on the MySQL `root' users in the access tables.  Otherwise,
  38820. any user with an account on that machine can run `mysql -u root
  38821. db_name' and do whatever he likes.
  38822.  
  38823. 
  38824. File: mysql.info,  Node: File permissions,  Prev: Changing MySQL user,  Up: Installation Issues
  38825.  
  38826. Problems with File Permissions
  38827. ------------------------------
  38828.  
  38829. If you have problems with file permissions, for example, if `mysql'
  38830. issues the following error message when you create a table:
  38831.  
  38832.      ERROR: Can't find file: 'path/with/filename.frm' (Errcode: 13)
  38833.  
  38834. then the environment variable `UMASK' might be set incorrectly when
  38835. `mysqld' starts up.  The default umask value is `0660'. You can change
  38836. this behavior by starting `safe_mysqld' as follows:
  38837.  
  38838.      shell> UMASK=384  # = 600 in octal
  38839.      shell> export UMASK
  38840.      shell> /path/to/safe_mysqld &
  38841.  
  38842. By default MySQL will create database and `RAID' directories with
  38843. permission type 0700.  You can modify this behavior by setting the
  38844. `UMASK_DIR' variable. If you set this, new directories are created with
  38845. the combined `UMASK' and `UMASK_DIR'. For example, if you want to give
  38846. group access to all new directories, you can do:
  38847.  
  38848.      shell> UMASK_DIR=504  # = 770 in octal
  38849.      shell> export UMASK_DIR
  38850.      shell> /path/to/safe_mysqld &
  38851.  
  38852. In MySQL Version 3.23.25 and above, MySQL assumes that the value for
  38853. `UMASK' and `UMASK_DIR' is in octal if it starts with a zero.
  38854.  
  38855. *Note Environment variables::.
  38856.  
  38857. 
  38858. File: mysql.info,  Node: Administration Issues,  Next: Query Issues,  Prev: Installation Issues,  Up: Problems
  38859.  
  38860. Administration Related Issues
  38861. =============================
  38862.  
  38863. * Menu:
  38864.  
  38865. * Crashing::                    What To Do If MySQL Keeps Crashing
  38866. * Resetting permissions::       How to Reset a Forgotten Password
  38867. * Full disk::                   How MySQL Handles a Full Disk
  38868. * Temporary files::             Where MySQL Stores Temporary Files
  38869. * Problems with mysql.sock::    How to Protect `/tmp/mysql.sock' from Being Deleted
  38870. * Timezone problems::           Time Zone Problems
  38871.  
  38872. 
  38873. File: mysql.info,  Node: Crashing,  Next: Resetting permissions,  Prev: Administration Issues,  Up: Administration Issues
  38874.  
  38875. What To Do If MySQL Keeps Crashing
  38876. ----------------------------------
  38877.  
  38878. All MySQL versions are tested on many platforms before they are
  38879. released.  This doesn't mean that there aren't any bugs in MySQL, but
  38880. it means if there are bugs, they are very few and can be hard to find.
  38881. If you have a problem, it will always help if you try to find out
  38882. exactly what crashes your system, as you will have a much better chance
  38883. of getting this fixed quickly.
  38884.  
  38885. First, you should try to find out whether the problem is that the
  38886. `mysqld' daemon dies or whether your problem has to do with your
  38887. client.  You can check how long your `mysqld' server has been up by
  38888. executing `mysqladmin version'.  If `mysqld' has died, you may find the
  38889. reason for this in the file `mysql-data-directory/`hostname`.err'.
  38890. *Note Error log::.
  38891.  
  38892. Many crashes of MySQL are caused by corrupted index / data files.
  38893. MySQL will update the data on disk, with the `write()' system call,
  38894. after every SQL statement and before the client is notified about the
  38895. result. (This is not true if you are running with `delayed_key_writes',
  38896. in which case only the data is written.)  This means that the data is
  38897. safe even if `mysqld' crashes, as the OS will ensure that the not
  38898. flushed data is written to disk.  You can force MySQL to sync
  38899. everything to disk after every SQL command by starting `mysqld' with
  38900. `--flush'.
  38901.  
  38902. The above means that normally you shouldn't get corrupted tables unless:
  38903.  
  38904.    * Someone/something killed `mysqld' or the machine in the middle of
  38905.      an update.
  38906.  
  38907.    * You have found a bug in `mysqld' that caused it to die in the
  38908.      middle of an update.
  38909.  
  38910.    * Someone is manipulating the data/index files outside of *mysqld*
  38911.      without locking the table properly.
  38912.  
  38913.    * If you are running many `mysqld' servers on the same data on a
  38914.      system that doesn't support good file system locks (normally
  38915.      handled by the `lockd' daemon ) or if you are running multiple
  38916.      servers with `--skip-locking'
  38917.  
  38918.    * You have a crashed index/data file that contains very wrong data
  38919.      that got `mysqld' confused.
  38920.  
  38921.    * You have found a bug in the data storage code. This isn't that
  38922.      likely, but it's at least possible.  In this case you can try to
  38923.      change the file type to another database handler by using `ALTER
  38924.      TABLE' on a repaired copy of the table!
  38925.  
  38926. Because it is very difficult to know why something is crashing, first
  38927. try to check whether or not things that work for others crash for you.
  38928. Please try the following things:
  38929.  
  38930.    * Take down the `mysqld' daemon with `mysqladmin shutdown', run
  38931.      `myisamchk --silent --force */*.MYI' on all tables, and restart the
  38932.      `mysqld' daemon.  This will ensure that you are running from a
  38933.      clean state.  *Note MySQL Database Administration::.
  38934.  
  38935.    * Use `mysqld --log' and try to determine from the information in
  38936.      the log whether or not some specific query kills the server. About
  38937.      95% of all bugs are related to a particular query!  Normally this
  38938.      is one of the last queries in the log file just before MySQL
  38939.      restarted. *Note Query log::.  If you can repeatadly kill MySQL
  38940.      with one of the queries, even when you have checked all tables
  38941.      just before doing the query, then you have been able to locate the
  38942.      bug and should do a bug report for this!  *Note Bug reports::.
  38943.  
  38944.    * Try to make a test case that we can use to reproduce the problem.
  38945.      *Note Reproduceable test case::.
  38946.  
  38947.    * Try running the included mysql-test test and the MySQL benchmarks.
  38948.      *Note MySQL test suite::.  They should test MySQL rather well.
  38949.      You can also add code that to the benchmarks to simulates your
  38950.      application!  The benchmarks can be found in the `bench' directory
  38951.      in the source distribution or, for a binary distribution, in the
  38952.      `sql-bench' directory under your MySQL installation directory.
  38953.  
  38954.    * Try `fork_test.pl' and `fork2_test.pl'.
  38955.  
  38956.    * If you configure MySQL for debugging, it will be much easier to
  38957.      gather information about possible errors if something goes wrong.
  38958.      Reconfigure MySQL with the `--with-debug' option or
  38959.      `--with-debug=full' to `configure' and then recompile.  *Note
  38960.      Debugging server::.
  38961.  
  38962.    * Configuring MySQL for debugging causes a safe memory allocator to
  38963.      be included that can find some errors. It also provides a lot of
  38964.      output about what is happening.
  38965.  
  38966.    * Have you applied the latest patches for your operating system?
  38967.  
  38968.    * Use the `--skip-locking' option to `mysqld'.  On some systems, the
  38969.      `lockd' lock manager does not work properly; the `--skip-locking'
  38970.      option tells `mysqld' not to use external locking.  (This means
  38971.      that you cannot run 2 `mysqld' servers on the same data and that
  38972.      you must be careful if you use `myisamchk', but it may be
  38973.      instructive to try the option as a test.)
  38974.  
  38975.    * Have you tried `mysqladmin -u root processlist' when `mysqld'
  38976.      appears to be running but not responding?  Sometimes `mysqld' is
  38977.      not comatose even though you might think so.  The problem may be
  38978.      that all connections are in use, or there may be some internal
  38979.      lock problem.  `mysqladmin processlist' will usually be able to
  38980.      make a connection even in these cases, and can provide useful
  38981.      information about the current number of connections and their
  38982.      status.
  38983.  
  38984.    * Run the command `mysqladmin -i 5 status' or `mysqladmin -i 5 -r
  38985.      status' or in a separate window to produce statistics while you run
  38986.      your other queries.
  38987.  
  38988.    * Try the following:
  38989.        1. Start `mysqld' from `gdb' (or in another debugger).  *Note
  38990.           Using gdb on mysqld::.
  38991.  
  38992.        2. Run your test scripts.
  38993.  
  38994.        3. Print the backtrace and the local variables at the 3 lowest
  38995.           levels. In gdb you can do this with the following commands
  38996.           when `mysqld' has crashed inside gdb:
  38997.  
  38998.                backtrace
  38999.                info local
  39000.                up
  39001.                info local
  39002.                up
  39003.                info local
  39004.  
  39005.           With gdb you can also examine which threads exist with `info
  39006.           threads' and switch to a specific thread with `thread #',
  39007.           where `#' is the thread id.
  39008.  
  39009.    * Try to simulate your application with a Perl script to force MySQL
  39010.      to crash or misbehave.
  39011.  
  39012.    * Send a normal bug report. *Note Bug reports::. Be even more
  39013.      detailed than usual.  Because MySQL works for many people, it may
  39014.      be that the crash results from something that exists only on your
  39015.      computer (for example, an error that is related to your particular
  39016.      system libraries).
  39017.  
  39018.    * If you have a problem with tables with dynamic-length rows and you
  39019.      are not using `BLOB/TEXT' columns (but only `VARCHAR' columns), you
  39020.      can try to change all `VARCHAR' to `CHAR' with `ALTER TABLE'.
  39021.      This will force MySQL to use fixed-size rows.  Fixed-size rows
  39022.      take a little extra space, but are much more tolerant to
  39023.      corruption!
  39024.  
  39025.      The current dynamic row code has been in use at MySQL AB for at
  39026.      least 3 years without any problems, but by nature dynamic-length
  39027.      rows are more prone to errors, so it may be a good idea to try the
  39028.      above to see if it helps!
  39029.  
  39030. 
  39031. File: mysql.info,  Node: Resetting permissions,  Next: Full disk,  Prev: Crashing,  Up: Administration Issues
  39032.  
  39033. How to Reset a Forgotten Password
  39034. ---------------------------------
  39035.  
  39036. If you have forgotten the `root' user password for MySQL, you can
  39037. restore it with the following procedure:
  39038.  
  39039.   1. Take down the `mysqld' server by sending a `kill' (not `kill -9')
  39040.      to the `mysqld' server.  The pid is stored in a `.pid' file, which
  39041.      is normally in the MySQL database directory:
  39042.  
  39043.           kill `cat /mysql-data-directory/hostname.pid`
  39044.  
  39045.      You must be either the Unix `root' user or the same user the server
  39046.      runs as to do this.
  39047.  
  39048.   2. Restart `mysqld' with the `--skip-grant-tables' option.
  39049.  
  39050.   3. Connect to the `mysqld' server with `mysql -h hostname mysql' and
  39051.      change the password with a `GRANT' command. *Note `GRANT': GRANT.
  39052.      You can also do this with `mysqladmin -h hostname -u user password
  39053.      'new password''
  39054.  
  39055.   4. Load the privilege tables with: `mysqladmin -h hostname
  39056.      flush-privileges' or with the SQL command `FLUSH PRIVILEGES'.
  39057.  
  39058. Note that after you started `mysqld' with `--skip-grant-tables', any
  39059. usage of `GRANT' commands will give you an `Unknown command' error
  39060. until you have executed `FLUSH PRIVILEGES'.
  39061.  
  39062. 
  39063. File: mysql.info,  Node: Full disk,  Next: Temporary files,  Prev: Resetting permissions,  Up: Administration Issues
  39064.  
  39065. How MySQL Handles a Full Disk
  39066. -----------------------------
  39067.  
  39068. When a disk-full condition occurs, MySQL does the following:
  39069.  
  39070.    * It checks once every minute to see whether or not there is enough
  39071.      space to write the current row. If there is enough space, it
  39072.      continues as if nothing had happened.
  39073.  
  39074.    * Every 6 minutes it writes an entry to the log file warning about
  39075.      the disk full condition.
  39076.  
  39077. To alleviate the problem, you can take the following actions:
  39078.  
  39079.    * To continue, you only have to free enough disk space to insert all
  39080.      records.
  39081.  
  39082.    * To abort the thread, you must send a `mysqladmin kill' to the
  39083.      thread.  The thread will be aborted the next time it checks the
  39084.      disk (in 1 minute).
  39085.  
  39086.    * Note that other threads may be waiting for the table that caused
  39087.      the disk full condition.  If you have several "locked" threads,
  39088.      killing the one thread that is waiting on the disk-full condition
  39089.      will allow the other threads to continue.
  39090.  
  39091. Exceptions to the above behaveour is when you use `REPAIR' or
  39092. `OPTIMIZE' or when the indexes are created in a batch after an `LOAD
  39093. DATA INFILE' or after an `ALTER TABLE' statement.
  39094.  
  39095. All of the above commands may use big temporary files that left to
  39096. themself would cause big problems for the rest of the system.  If MySQL
  39097. gets disk full while doing any of the above operations, it will remove
  39098. the big temporary files and mark the table as crashed (except for
  39099. `ALTER TABLE', in which the old table will be left unchanged).
  39100.  
  39101. 
  39102. File: mysql.info,  Node: Temporary files,  Next: Problems with mysql.sock,  Prev: Full disk,  Up: Administration Issues
  39103.  
  39104. Where MySQL Stores Temporary Files
  39105. ----------------------------------
  39106.  
  39107. MySQL uses the value of the `TMPDIR' environment variable as the
  39108. pathname of the directory in which to store temporary files.  If you
  39109. don't have `TMPDIR' set, MySQL uses the system default, which is
  39110. normally `/tmp' or `/usr/tmp'.  If the file system containing your
  39111. temporary file directory is too small, you should edit `safe_mysqld' to
  39112. set `TMPDIR' to point to a directory in a file system where you have
  39113. enough space!  You can also set the temporary directory using the
  39114. `--tmpdir' option to `mysqld'.
  39115.  
  39116. MySQL creates all temporary files as hidden files. This ensures that
  39117. the temporary files will be removed if `mysqld' is terminated.  The
  39118. disadvantage of using hidden files is that you will not see a big
  39119. temporary file that fills up the file system in which the temporary
  39120. file directory is located.
  39121.  
  39122. When sorting (`ORDER BY' or `GROUP BY'), MySQL normally uses one or two
  39123. temporary files. The maximum disk-space needed is:
  39124.  
  39125.      (length of what is sorted + sizeof(database pointer))
  39126.      * number of matched rows
  39127.      * 2
  39128.  
  39129. `sizeof(database pointer)' is usually 4, but may grow in the future for
  39130. really big tables.
  39131.  
  39132. For some `SELECT' queries, MySQL also creates temporary SQL tables.
  39133. These are not hidden and have names of the form `SQL_*'.
  39134.  
  39135. `ALTER TABLE' creates a temporary table in the same directory as the
  39136. original table.
  39137.  
  39138. 
  39139. File: mysql.info,  Node: Problems with mysql.sock,  Next: Timezone problems,  Prev: Temporary files,  Up: Administration Issues
  39140.  
  39141. How to Protect or change the MySQL socket file `/tmp/mysql.sock'
  39142. ----------------------------------------------------------------
  39143.  
  39144. If you have problems with the fact that anyone can delete the MySQL
  39145. communication socket `/tmp/mysql.sock', you can, on most versions of
  39146. Unix, protect your `/tmp' file system by setting the `sticky' bit on
  39147. it.  Log in as `root' and do the following:
  39148.  
  39149.      shell> chmod +t /tmp
  39150.  
  39151. This will protect your `/tmp' file system so that files can be deleted
  39152. only by their owners or the superuser (`root').
  39153.  
  39154. You can check if the `sticky' bit is set by executing `ls -ld /tmp'.
  39155. If the last permission bit is `t', the bit is set.
  39156.  
  39157. You can change the place where MySQL uses / puts the socket file the
  39158. following ways:
  39159.  
  39160.    * Specify the path in a global or local option file.  For example,
  39161.      put in `/etc/my.cnf':
  39162.  
  39163.           [client]
  39164.           socket=path-for-socket-file
  39165.           
  39166.           [mysqld]
  39167.           socket=path-for-socket-file
  39168.      *Note Option files::.
  39169.  
  39170.    * Specifying this on the command line to `safe_mysqld' and most
  39171.      clients with the `--socket=path-for-socket-file' option.
  39172.  
  39173.    * Specify the path to the socket in the `MYSQL_UNIX_PORT' environment
  39174.      variable.
  39175.  
  39176.    * Defining the path with the `configure' option
  39177.      `--with-unix-socket-path=path-for-socket-file'. *Note configure
  39178.      options::.
  39179.  
  39180. You can test that the socket works with this command:
  39181.  
  39182.      shell> mysqladmin --socket=/path/to/socket version
  39183.  
  39184. 
  39185. File: mysql.info,  Node: Timezone problems,  Prev: Problems with mysql.sock,  Up: Administration Issues
  39186.  
  39187. Time Zone Problems
  39188. ------------------
  39189.  
  39190. If you have a problem with `SELECT NOW()' returning values in GMT and
  39191. not your local time, you have to set the `TZ' environment variable to
  39192. your current time zone.  This should be done for the environment in
  39193. which the server runs, for example, in `safe_mysqld' or `mysql.server'.
  39194. *Note Environment variables::.
  39195.  
  39196. 
  39197. File: mysql.info,  Node: Query Issues,  Next: Table Definition Issues,  Prev: Administration Issues,  Up: Problems
  39198.  
  39199. Query Related Issues
  39200. ====================
  39201.  
  39202. * Menu:
  39203.  
  39204. * Case sensitivity::            Case Sensitivity in Searches
  39205. * Using DATE::                  Problems Using `DATE' Columns
  39206. * Problems with NULL::          Problems with `NULL' Values
  39207. * Problems with alias::         Problems with `alias'
  39208. * Deleting from related tables::  Deleting Rows from Related Tables
  39209. * No matching rows::            Solving Problems with No Matching Rows
  39210.  
  39211. 
  39212. File: mysql.info,  Node: Case sensitivity,  Next: Using DATE,  Prev: Query Issues,  Up: Query Issues
  39213.  
  39214. Case Sensitivity in Searches
  39215. ----------------------------
  39216.  
  39217. By default, MySQL searches are case-insensitive (although there are
  39218. some character sets that are never case insensitive, such as `czech').
  39219. That means that if you search with `col_name LIKE 'a%'', you will get
  39220. all column values that start with `A' or `a'. If you want to make this
  39221. search case-sensitive, use something like `INSTR(col_name, "A")=1' to
  39222. check a prefix. Or use `STRCMP(col_name, "A") = 0' if the column value
  39223. must be exactly `"A"'.
  39224.  
  39225. Simple comparison operations (`>=, >, = , < , <=', sorting and
  39226. grouping) are based on each character's "sort value". Characters with
  39227. the same sort value (like E, e and Θ) are treated as the same character!
  39228.  
  39229. In older MySQL versions `LIKE' comparisons where done on the uppercase
  39230. value of each character (E == e but E <> Θ).  In newer MySQL versions
  39231. `LIKE' works just like the other comparison operators.
  39232.  
  39233. If you want a column always to be treated in case-sensitive fashion,
  39234. declare it as `BINARY'. *Note `CREATE TABLE': CREATE TABLE.
  39235.  
  39236. If you are using Chinese data in the so-called big5 encoding, you want
  39237. to make all character columns `BINARY'. This works because the sorting
  39238. order of big5 encoding characters is based on the order of ASCII codes.
  39239.  
  39240. 
  39241. File: mysql.info,  Node: Using DATE,  Next: Problems with NULL,  Prev: Case sensitivity,  Up: Query Issues
  39242.  
  39243. Problems Using `DATE' Columns
  39244. -----------------------------
  39245.  
  39246. The format of a `DATE' value is `'YYYY-MM-DD''. According to ANSI SQL,
  39247. no other format is allowed. You should use this format in `UPDATE'
  39248. expressions and in the WHERE clause of `SELECT' statements.  For
  39249. example:
  39250.  
  39251.      mysql> SELECT * FROM tbl_name WHERE date >= '1997-05-05';
  39252.  
  39253. As a convenience, MySQL automatically converts a date to a number if
  39254. the date is used in a numeric context (and vice versa). It is also smart
  39255. enough to allow a "relaxed" string form when updating and in a `WHERE'
  39256. clause that compares a date to a `TIMESTAMP', `DATE', or a `DATETIME'
  39257. column.  (Relaxed form means that any punctuation character may be used
  39258. as the separator between parts. For example, `'1998-08-15'' and
  39259. `'1998#08#15'' are equivalent.) MySQL can also convert a string
  39260. containing no separators (such as `'19980815''), provided it makes
  39261. sense as a date.
  39262.  
  39263. The special date `'0000-00-00'' can be stored and retrieved as
  39264. `'0000-00-00'.' When using a `'0000-00-00'' date through *MyODBC*, it
  39265. will automatically be converted to `NULL' in *MyODBC* Version 2.50.12
  39266. and above, because ODBC can't handle this kind of date.
  39267.  
  39268. Because MySQL performs the conversions described above, the following
  39269. statements work:
  39270.  
  39271.      mysql> INSERT INTO tbl_name (idate) VALUES (19970505);
  39272.      mysql> INSERT INTO tbl_name (idate) VALUES ('19970505');
  39273.      mysql> INSERT INTO tbl_name (idate) VALUES ('97-05-05');
  39274.      mysql> INSERT INTO tbl_name (idate) VALUES ('1997.05.05');
  39275.      mysql> INSERT INTO tbl_name (idate) VALUES ('1997 05 05');
  39276.      mysql> INSERT INTO tbl_name (idate) VALUES ('0000-00-00');
  39277.      
  39278.      mysql> SELECT idate FROM tbl_name WHERE idate >= '1997-05-05';
  39279.      mysql> SELECT idate FROM tbl_name WHERE idate >= 19970505;
  39280.      mysql> SELECT mod(idate,100) FROM tbl_name WHERE idate >= 19970505;
  39281.      mysql> SELECT idate FROM tbl_name WHERE idate >= '19970505';
  39282.  
  39283. However, the following will not work:
  39284.  
  39285.      mysql> SELECT idate FROM tbl_name WHERE STRCMP(idate,'19970505')=0;
  39286.  
  39287. `STRCMP()' is a string function, so it converts `idate' to a string and
  39288. performs a string comparison.  It does not convert `'19970505'' to a
  39289. date and perform a date comparison.
  39290.  
  39291. Note that MySQL does no checking whether or not the date is correct.
  39292. If you store an incorrect date, such as `'1998-2-31'', the wrong date
  39293. will be stored. If the date cannot be converted to any reasonable
  39294. value, a `0' is stored in the `DATE' field.  This is mainly a speed
  39295. issue and we think it is up to the application to check the dates, and
  39296. not the server.
  39297.  
  39298. 
  39299. File: mysql.info,  Node: Problems with NULL,  Next: Problems with alias,  Prev: Using DATE,  Up: Query Issues
  39300.  
  39301. Problems with `NULL' Values
  39302. ---------------------------
  39303.  
  39304. The concept of the `NULL' value is a common source of confusion for
  39305. newcomers to SQL, who often think that `NULL' is the same thing as an
  39306. empty string `'''.  This is not the case! For example, the following
  39307. statements are completely different:
  39308.  
  39309.      mysql> INSERT INTO my_table (phone) VALUES (NULL);
  39310.      mysql> INSERT INTO my_table (phone) VALUES ("");
  39311.  
  39312. Both statements insert a value into the `phone' column, but the first
  39313. inserts a `NULL' value and the second inserts an empty string.  The
  39314. meaning of the first can be regarded as "phone number is not known" and
  39315. the meaning of the second can be regarded as "she has no phone".
  39316.  
  39317. In SQL, the `NULL' value is always false in comparison to any other
  39318. value, even `NULL'.  An expression that contains `NULL' always produces
  39319. a `NULL' value unless otherwise indicated in the documentation for the
  39320. operators and functions involved in the expression. All columns in the
  39321. following example return `NULL':
  39322.  
  39323.      mysql> SELECT NULL,1+NULL,CONCAT('Invisible',NULL);
  39324.  
  39325. If you want to search for column values that are `NULL', you cannot use
  39326. the `=NULL' test. The following statement returns no rows, because
  39327. `expr = NULL' is FALSE, for any expression:
  39328.  
  39329.      mysql> SELECT * FROM my_table WHERE phone = NULL;
  39330.  
  39331. To look for `NULL' values, you must use the `IS NULL' test.  The
  39332. following shows how to find the `NULL' phone number and the empty phone
  39333. number:
  39334.  
  39335.      mysql> SELECT * FROM my_table WHERE phone IS NULL;
  39336.      mysql> SELECT * FROM my_table WHERE phone = "";
  39337.  
  39338. In MySQL, as in many other SQL servers, you can't index columns that
  39339. can have `NULL' values.  You must declare such columns `NOT NULL'.
  39340. Conversely, you cannot insert `NULL' into an indexed column.
  39341.  
  39342. When reading data with `LOAD DATA INFILE', empty columns are updated
  39343. with `'''. If you want a `NULL' value in a column, you should use `\N'
  39344. in the text file. The literal word `'NULL'' may also be used under some
  39345. circumstances.  *Note `LOAD DATA': LOAD DATA.
  39346.  
  39347. When using `ORDER BY', `NULL' values are presented first. If you sort
  39348. in descending order using `DESC', `NULL' values are presented last.
  39349. When using `GROUP BY', all `NULL' values are regarded as equal.
  39350.  
  39351. To help with `NULL' handling, you can use the `IS NULL' and `IS NOT
  39352. NULL' operators and the `IFNULL()' function.
  39353.  
  39354. For some column types, `NULL' values are handled specially.  If you
  39355. insert `NULL' into the first `TIMESTAMP' column of a table, the current
  39356. date and time is inserted.  If you insert `NULL' into an
  39357. `AUTO_INCREMENT' column, the next number in the sequence is inserted.
  39358.  
  39359. 
  39360. File: mysql.info,  Node: Problems with alias,  Next: Deleting from related tables,  Prev: Problems with NULL,  Up: Query Issues
  39361.  
  39362. Problems with `alias'
  39363. ---------------------
  39364.  
  39365. You can use an alias to refer to a column in the `GROUP BY', `ORDER
  39366. BY', or in the `HAVING' part.  Aliases can also be used to give columns
  39367. better names:
  39368.  
  39369.      SELECT SQRT(a*b) as rt FROM table_name GROUP BY rt HAVING rt > 0;
  39370.      SELECT id,COUNT(*) AS cnt FROM table_name GROUP BY id HAVING cnt > 0;
  39371.      SELECT id AS "Customer identity" FROM table_name;
  39372.  
  39373. Note that ANSI SQL doesn't allow you to refer to an alias in a `WHERE'
  39374. clause.  This is because when the `WHERE' code is executed the column
  39375. value may not yet be determined. For example, the following query is
  39376. *illegal*:
  39377.  
  39378.      SELECT id,COUNT(*) AS cnt FROM table_name WHERE cnt > 0 GROUP BY id;
  39379.  
  39380. The `WHERE' statement is executed to determine which rows should be
  39381. included in the `GROUP BY' part while `HAVING' is used to decide which
  39382. rows from the result set should be used.
  39383.  
  39384. 
  39385. File: mysql.info,  Node: Deleting from related tables,  Next: No matching rows,  Prev: Problems with alias,  Up: Query Issues
  39386.  
  39387. Deleting Rows from Related Tables
  39388. ---------------------------------
  39389.  
  39390. As MySQL doesn't support sub-selects or use of more than one table in
  39391. the `DELETE' statement, you should use the following approach to delete
  39392. rows from 2 related tables:
  39393.  
  39394.   1. `SELECT' the rows based on some `WHERE' condition in the main
  39395.      table.
  39396.  
  39397.   2. `DELETE' the rows in the main table based on the same condition.
  39398.  
  39399.   3. `DELETE FROM related_table WHERE related_column IN
  39400.      (selected_rows)'.
  39401.  
  39402. If the total number of characters in the query with `related_column' is
  39403. more than 1,048,576 (the default value of `max_allowed_packet', you
  39404. should split it into smaller parts and execute multiple `DELETE'
  39405. statements.  You will probably get the fastest `DELETE' by only
  39406. deleting 100-1000 `related_column' id's per query if the
  39407. `related_column' is an index.  If the `related_column' isn't an index,
  39408. the speed is independent of the number of arguments in the `IN' clause.
  39409.  
  39410. 
  39411. File: mysql.info,  Node: No matching rows,  Prev: Deleting from related tables,  Up: Query Issues
  39412.  
  39413. Solving Problems with No Matching Rows
  39414. --------------------------------------
  39415.  
  39416. If you have a complicated query that has many tables and that doesn't
  39417. return any rows, you should use the following procedure to find out what
  39418. is wrong with your query:
  39419.  
  39420.   1. Test the query with `EXPLAIN' and check if you can find something
  39421.      that is obviously wrong. *Note `EXPLAIN': EXPLAIN.
  39422.  
  39423.   2. Select only those fields that are used in the `WHERE' clause.
  39424.  
  39425.   3. Remove one table at a time from the query until it returns some
  39426.      rows.  If the tables are big, it's a good idea to use `LIMIT 10'
  39427.      with the query.
  39428.  
  39429.   4. Do a `SELECT' for the column that should have matched a row against
  39430.      the table that was last removed from the query.
  39431.  
  39432.   5. If you are comparing `FLOAT' or `DOUBLE' columns with numbers that
  39433.      have decimals, you can't use `='!  This problem is common in most
  39434.      computer languages because floating-point values are not exact
  39435.      values:
  39436.  
  39437.           mysql> SELECT * FROM table_name WHERE float_column=3.5;
  39438.              ->
  39439.           mysql> SELECT * FROM table_name WHERE float_column between 3.45 and 3.55;
  39440.  
  39441.      In most cases, changing the `FLOAT' to a `DOUBLE' will fix this!
  39442.  
  39443.   6. If you still can't figure out what's wrong, create a minimal test
  39444.      that can be run with `mysql test < query.sql' that shows your
  39445.      problems.  You can create a test file with `mysqldump --quick
  39446.      database tables > query.sql'. Open the file in an editor, remove
  39447.      some insert lines (if there are too many of these), and add your
  39448.      select statement at the end of the file.
  39449.  
  39450.      Test that you still have your problem by doing:
  39451.  
  39452.           shell> mysqladmin create test2
  39453.           shell> mysql test2 < query.sql
  39454.  
  39455.      Post the test file using `mysqlbug' to <mysql@lists.mysql.com>.
  39456.  
  39457. 
  39458. File: mysql.info,  Node: Table Definition Issues,  Prev: Query Issues,  Up: Problems
  39459.  
  39460. Table Definition Related Issues
  39461. ===============================
  39462.  
  39463. * Menu:
  39464.  
  39465. * ALTER TABLE problems::        Problems with `ALTER TABLE'.
  39466. * Change column order::         How To Change the Order of Columns in a Table
  39467. * Temporary table problems::    TEMPORARY TABLE problems
  39468.  
  39469. 
  39470. File: mysql.info,  Node: ALTER TABLE problems,  Next: Change column order,  Prev: Table Definition Issues,  Up: Table Definition Issues
  39471.  
  39472. Problems with `ALTER TABLE'.
  39473. ----------------------------
  39474.  
  39475. `ALTER TABLE' changes a table to the current character set.  If you
  39476. during `ALTER TABLE' get a duplicate key error, then the cause is
  39477. either that the new character sets maps to keys to the same value or
  39478. that the table is corrupted, in which case you should run `REPAIR
  39479. TABLE' on the table.
  39480.  
  39481. If `ALTER TABLE' dies with an error like this:
  39482.  
  39483.      Error on rename of './database/name.frm' to './database/B-a.frm' (Errcode: 17)
  39484.  
  39485. the problem may be that MySQL has crashed in a previous `ALTER TABLE'
  39486. and there is an old table named `A-something' or `B-something' lying
  39487. around.  In this case, go to the MySQL data directory and delete all
  39488. files that have names starting with `A-' or `B-'.  (You may want to
  39489. move them elsewhere instead of deleting them.)
  39490.  
  39491. `ALTER TABLE' works the following way:
  39492.  
  39493.    * Create a new table named `A-xxx' with the requested changes.
  39494.  
  39495.    * All rows from the old table are copied to `A-xxx'.
  39496.  
  39497.    * The old table is renamed `B-xxx'.
  39498.  
  39499.    * `A-xxx' is renamed to your old table name.
  39500.  
  39501.    * `B-xxx' is deleted.
  39502.  
  39503. If something goes wrong with the renaming operation, MySQL tries to
  39504. undo the changes.  If something goes seriously wrong (this shouldn't
  39505. happen, of course), MySQL may leave the old table as `B-xxx', but a
  39506. simple rename on the system level should get your data back.
  39507.  
  39508. 
  39509. File: mysql.info,  Node: Change column order,  Next: Temporary table problems,  Prev: ALTER TABLE problems,  Up: Table Definition Issues
  39510.  
  39511. How To Change the Order of Columns in a Table
  39512. ---------------------------------------------
  39513.  
  39514. The whole point of SQL is to abstract the application from the data
  39515. storage format.  You should always specify the order in which you wish
  39516. to retrieve your data.  For example:
  39517.  
  39518.      SELECT col_name1, col_name2, col_name3 FROM tbl_name;
  39519.  
  39520. will return columns in the order `col_name1', `col_name2', `col_name3',
  39521. whereas:
  39522.  
  39523.      SELECT col_name1, col_name3, col_name2 FROM tbl_name;
  39524.  
  39525. will return columns in the order `col_name1', `col_name3', `col_name2'.
  39526.  
  39527. You should *NEVER*, in an application, use `SELECT *' and retrieve the
  39528. columns based on their position, because the order in which columns are
  39529. returned *CANNOT* be guaranteed over time. A simple change to your
  39530. database may cause your application to fail rather dramatically.
  39531.  
  39532. If you want to change the order of columns anyway, you can do it as
  39533. follows:
  39534.  
  39535.   1. Create a new table with the columns in the right order.
  39536.  
  39537.   2. Execute `INSERT INTO new_table SELECT fields-in-new_table-order
  39538.      FROM old_table'.
  39539.  
  39540.   3. Drop or rename `old_table'.
  39541.  
  39542.   4. `ALTER TABLE new_table RENAME old_table'.
  39543.  
  39544. 
  39545. File: mysql.info,  Node: Temporary table problems,  Prev: Change column order,  Up: Table Definition Issues
  39546.  
  39547. TEMPORARY TABLE problems
  39548. ------------------------
  39549.  
  39550. The following are a list of the limitations with `TEMPORARY TABLES'.
  39551.  
  39552.    * A temporary table can only be of type `HEAP', `ISAM' or `MyISAM'.
  39553.  
  39554.    * You can't use temporary tables more than once in the same query.
  39555.      For example, the following doesn't work.
  39556.  
  39557.           select * from temporary_table, temporary_table as t2;
  39558.  
  39559.      We plan to fix the above in 4.0.
  39560.  
  39561.    * You can't use `RENAME' on a `TEMPORARY' table.  Note that `ALTER
  39562.      TABLE org_name RENAME new_name' works!
  39563.  
  39564.      We plan to fix the above in 4.0.
  39565.  
  39566. 
  39567. File: mysql.info,  Node: Users,  Next: MySQL customer usage,  Prev: Problems,  Up: Top
  39568.  
  39569. Some MySQL Users
  39570. ****************
  39571.  
  39572. This appendix lists some users of MySQL that have given us permission
  39573. to list them in our documentation.  It is by far not a complete list,
  39574. but should give you a general idea of who uses MySQL and what it can be
  39575. used for.
  39576.  
  39577. General News Sites
  39578. ==================
  39579.  
  39580.    * Yahoo! (http://www.yahoo.com/)
  39581.  
  39582.    * Slashdot: A pro-Linux/tech news and comment/discussion site
  39583.      (http://slashdot.org/)
  39584.  
  39585.    * All about Linux (http://www.linux.com/)
  39586.  
  39587.    * Linuxtoday (http://www.linuxtoday.com/)
  39588.  
  39589.    * 32Bits Online: because there's more than one way to compute
  39590.      (http://www.32bitsonline.com/)
  39591.  
  39592.    * Freshmeat: News about new versions of computer-related stuff
  39593.      (http://www.freshmeat.net/)
  39594.  
  39595.  
  39596. Some Web Search Engines
  39597. =======================
  39598.  
  39599.    * AAA Matilda Web Search (http://www.aaa.com.au)
  39600.  
  39601.    * What's New (http://www.whatsnu.com/)
  39602.  
  39603.    * Aladin (http://www.aladin.de/)
  39604.  
  39605.    * Columbus Finder (http://www.columbus-finder.de/)
  39606.  
  39607.    * Spider (http://www.spider.de/)
  39608.  
  39609.    * Blitzsuche (http://www.blitzsuche.de/)
  39610.  
  39611.    * Indoseek Indonesia (http://www.indoseek.co.id)
  39612.  
  39613.    * Yaboo - Yet Another BOOkmarker (http://www.yaboo.dk/)
  39614.  
  39615.    * OzSearch Internet Guide (http://www.ozsearch.com.au)
  39616.  
  39617.    * Splat! Search (http://www.splatsearch.com/)
  39618.  
  39619.    * The Open Source Digital Library System Project
  39620.      (http://osdls.library.arizona.edu/)
  39621.  
  39622. Some Information Search Engines Concentrated on Some Area
  39623. =========================================================
  39624.  
  39625.    * SpyLOG ; A very popular Web counter site (http://www.spylog.ru/)
  39626.  
  39627.    * TuCows Network; Free Software archive (http://www.tucows.com/)
  39628.  
  39629.    * Jobvertise: Post and search for jobs (http://www.jobvertise.com)
  39630.  
  39631.    * The Music Database (http://www.musicdatabase.com)
  39632.  
  39633.    * Football (Soccer) search page (http://www.soccersearch.com)
  39634.  
  39635.    * TAKEDOWN - wrestling (http://www.headrush.net/takedown)
  39636.  
  39637.    * The International Lyrics Network (http://www.lyrics.net)
  39638.  
  39639.    * Musicians looking for other musicians (Free Service)
  39640.      (http://TheMatrix.com/~matrix/band_search.phtml)
  39641.  
  39642.    * AddALL books searching and price comparison
  39643.      (http://www.addall.com/AddBooks/Stores.html)
  39644.  
  39645.    * Harvard's Gray Herbarium Index of Plant Names
  39646.      (http://www.herbaria.harvard.edu/Data/Gray/gray.html)
  39647.  
  39648.    * The Game Development Search Engine (http://www.game-developer.com/)
  39649.  
  39650.    * The Innkeeper Vacation Guides (www.theinnkeeper.com)
  39651.  
  39652.    * The Mac Game Database uses PHP and MySQL
  39653.      (http://www.macgamedatabase.com/)
  39654.  
  39655.    * Research Publications at Monash University in Australia
  39656.      (http://www.csse.monash.edu.au/publications/)
  39657.  
  39658.    * Occupational Health & Safety Web site database (a project for the
  39659.      ECC) (http://www.ipielle.emr.it/bts/index.html)
  39660.  
  39661.    * Bioinformatics databases at the Montreal Children's Hospital using
  39662.      MySQL (http://data.mch.mcgill.ca/)
  39663.  
  39664. Online Magazines
  39665. ================
  39666.  
  39667.    * Spoiler Webzine (http://www.spoiler.com).  An online magazine
  39668.      featuring music, literature, arts, and design content.
  39669.  
  39670.    * Daily news about Linux in German language
  39671.      (http://www.linux-magazin.de/newsflash/)
  39672.  
  39673.    * Betazine - The Ultimate Online Beta Tester's Magazine
  39674.      (http://www.betazine.com)
  39675.  
  39676.    * Computer Currents Magazine
  39677.      (http://www.currents.net/ccinfo/aboutcc.html)
  39678.  
  39679. Web Sites that Use MySQL as a Backend
  39680. =====================================
  39681.  
  39682.    * NASA (http://liftoff.msfc.nasa.gov)
  39683.  
  39684.    * NASA KIDS (http://kids.msfc.nasa.gov)
  39685.  
  39686.    * Sience@NASA (http://science.nasa.gov)
  39687.  
  39688.    * handy.de (http://www.handy.de/)
  39689.  
  39690.    * Qt Widget and Object Repository (http://lindev.jmc.tju.edu/qwor)
  39691.  
  39692.    * Brazilian samba site (in Portuguese)
  39693.      (http://www.samba-choro.com.br)
  39694.  
  39695.    * Polish General Social Survey
  39696.      (http://pgss.iss.uw.edu.pl/en_index.ISS)
  39697.  
  39698.    * Expo2000 (http://www.expo2000.com) World-wide distribution of
  39699.      tickets for this event is implemented using MySQL and tcl/tk. More
  39700.      than 5000 travel agencies all over the world have access to it.
  39701.  
  39702.    * FreeVote.com is a free voting service with millions of users.
  39703.      (http://www.freevote.com/)
  39704.  
  39705.    * Forza Motorsport (http://f1.tauzero.se)
  39706.  
  39707.    * DreamHost Web Hosting (http://www.dreamhost.com/)
  39708.  
  39709.  
  39710. Some Domain/Internet/Web and Related Services
  39711. =============================================
  39712.  
  39713.    * Registry of Web providers that support MySQL
  39714.      (http://www.wix.com/mysql-hosting)
  39715.  
  39716.    * Dynamic DNS Services (http://www.yi.org/)
  39717.  
  39718.    * Dynamic domain name service (http://www.dynodns.net/)
  39719.  
  39720.    * Open DNS Project; free dynamic DNS service (http://www.ods.org/)
  39721.  
  39722.    * Hammernode; Public DNS Servers (http://www.hn.org/)
  39723.  
  39724.    * Free 3rd level domains (http://www.fdns.net/)
  39725.  
  39726.    * Online Database (http://worldcommunity.com/)
  39727.  
  39728.    * BigBiz Internet Services (http://www.bigbiz.com)
  39729.  
  39730.    * The Virt Gazette (http://virt.circle.net)
  39731.  
  39732.    * Global InfoNet Inc (http://www.california.com)
  39733.  
  39734.    * WebHosters - A Guide to WWW Providers (http://www.webhosters.com)
  39735.  
  39736.    * Internet information server (http://online.dn.ru)
  39737.  
  39738.    * A technology news site (http://www.stopbit.com)
  39739.  
  39740.    * WorldNet Communications - An Internet Services Provider
  39741.      (http://www.worldnetla.net)
  39742.  
  39743.    * Netizen: Australian-based Web consultancy
  39744.      (http://www.netizen.com.au/)
  39745.  
  39746.    * Search site for training courses in the UK
  39747.      (http://www.trainingpages.co.uk)
  39748.  
  39749.    * Gannon Chat (GPL). Written in Perl and Javascript
  39750.      (http://chat.nitco.com)
  39751.  
  39752.    * A general links directory (http://www.addurls.com/)
  39753.  
  39754.    * A Web-based bookmark management service
  39755.      (http://www.bookmarktracker.com)
  39756.  
  39757.    * Walnut Creek CDROM (http://www.cdrom.com)
  39758.  
  39759.    * WWWThreads; Interactive discussion Forums
  39760.      (http://www.wwwthreads.org/)
  39761.  
  39762.    * In Italian; Storage data from meteo station
  39763.      (http://pvmon.portici.enea.it/Meteo)
  39764.  
  39765.    * Online "Person To Person" Auction (http://www.buysell.net/)
  39766.  
  39767.    * Tips on Web development (http://tips.pair.com)
  39768.  
  39769.    * Mailfriends.com is a FREE service for everybody who wants to find
  39770.      friends over the internet. (http://www.mailfriends.com)
  39771.  
  39772.    * Web Page Telnet BBS List
  39773.      (http://www.uninova.com/cgi-bin/wctelnets?list)
  39774.  
  39775.    * UniNova Digital Postcards (http://www.uninova.com/cnc.html)
  39776.  
  39777.    * DSL-provider search with reviews (http://www.dslreports.com).
  39778.      Made with MySQL and Modperl, all pages are generated dynamically
  39779.      out of the MySQL database
  39780.  
  39781. Web Sites that Use `PHP' and MySQL
  39782. ==================================
  39783.  
  39784.    * Jgaa's Internet - Official Support Site (http://support.jgaa.com/)
  39785.  
  39786.    * Ionline - online publication: (http://io.incluso.com) MySQL, PHP,
  39787.      Java, Web programming, DB development
  39788.  
  39789.    * BaBoo(Browse and bookmark). Free Web-based bookmark manager and
  39790.      Calendar (http://www.baboo.com)
  39791.  
  39792.    * Course Schedule System at Pensacola Junior College
  39793.      (http://www.courses.pjc.cc.fl.us/Schedule/index.php)
  39794.  
  39795.    * Florida Community College at Jacksonville (http://www.fccj.org)
  39796.  
  39797.    * 32bit.com; An extensive shareware / freeware archive
  39798.      (http://www.32bit.com/)
  39799.  
  39800.    * Jokes 2000 (http://www.jokes2000.com/)
  39801.  
  39802.    * Burken.NU (http://www.burken.nu/) Burken is a webhotel that
  39803.      provides scripts, among other things, for remote users, like
  39804.      counters, guestbooks etc.
  39805.  
  39806.    * tips.pair.com (http://tips.pair.com) Contains tips on html,
  39807.      javascript, 2d/3d graphics, and PHP3/MySQL. All pages are
  39808.      generated from a database.
  39809.  
  39810.    * Softwarezrus.com (http://www.softwarezrus.com/) Ecommerce site
  39811.      that is selling computers.
  39812.  
  39813. Some MySQL Consultants
  39814. ======================
  39815.  
  39816.    * Ayni AG (http://www.ayni.com)
  39817.  
  39818.    * Online Database (http://worldcommunity.com/)
  39819.  
  39820.    * DataGuard (Uses MySQL and PHP) (http://www2.dataguard.no/)
  39821.  
  39822.    * WWITS (Uses MySQL and PHP) (http://wwits.net/programs/mysql.phtml)
  39823.  
  39824.    * WCN - The World Community Network (http://www.worldcommunity.com/)
  39825.  
  39826.    * Chip Castle Dot Com Inc (http://www.chipcastle.com)
  39827.  
  39828.    * Cybersource Pty. Ltd (http://www.cyber.com.au/)
  39829.  
  39830.    * Spring infotainment gmbh & co. kg (http://www.spring.de)
  39831.  
  39832.    * Develops Web sites using MySQL (http://www.wamdesign.com/)
  39833.  
  39834.    * Berkeley Consultants Group (http://www.berkeleyconsultants.com)
  39835.  
  39836.    * JAMM Consulting Inc. (http://www.jammconsulting.com/)
  39837.  
  39838.  
  39839. Programming
  39840. ===========
  39841.  
  39842. Uncategorized Pages
  39843. ===================
  39844.  
  39845.    * AZC.COM's Feature Showcase
  39846.      (http://www.feature-showcase.com/htmls/demo_mysql.sql)
  39847.  
  39848.    * Course Search
  39849.      (http://www.teach.org.uk/subjects/trainingcourse/g.html)
  39850.  
  39851.    * Northerbys Online Auctions (http://www.northerbys.com)
  39852.  
  39853.    * Amsterdam Airport Schiphol
  39854.      (http://www.schiphol.nl/flights/home.htm)
  39855.  
  39856.    * CD database (http://TheMatrix.com/seventhsin/query.phtml)
  39857.  
  39858.    * Used Audio Gear Database (http://TheMatrix.com/~flmm/GEAR.html)
  39859.  
  39860.    * Musical note-sheets (http://www.kiss.de/musik-mueller)
  39861.  
  39862.    * Bagism - A John Lennon fan page (http://www.bagism.com)
  39863.  
  39864.    * US Folk art broker (http://www.selftaught.com/)
  39865.  
  39866.    * Mail reading on the Web (http://organizer.net/)
  39867.  
  39868.    * Free home pages on www.somecoolname.mypage.org
  39869.      (http://www.mypage.org/)
  39870.  
  39871.    * Der Server fu"r Schulen im Web (In German)
  39872.      (http://www.schulweb.de/)
  39873.  
  39874.    * Auldhaefen Online Services (http://www.ald.net/)
  39875.  
  39876.    * CaryNET Information Center (http://www.cary.net/)
  39877.  
  39878.    * Dataden Computer Systems (http://www.dataden.com/)
  39879.  
  39880.    * Andre'museet (In Swedish) (http://andree.grm.se/)
  39881.  
  39882.    * HOMESITE Internet Marketing (http://www.him.net/)
  39883.  
  39884.    * Jade-V Network Services (http://www.jade-v.com/techinfo.html)
  39885.  
  39886.    * Weather World 2010 Technical Credits
  39887.      (http://ww2010.atmos.uiuc.edu/(Gl)/abt/aknw/tech.rxml)
  39888.    * About The Gimp plugin registry
  39889.      (http://gimp.foebud.org/registry/doc/)
  39890.  
  39891.    * Java tool Archiver technical detail (Slightly optimistic about
  39892.      MySQL ANSI-92 compliance)
  39893.      (http://www.fast-inc.com/Products/Archiver/database.html)
  39894.  
  39895.    * Games Domain Cheats Database
  39896.      (http://www.gamesdomain.com/cheats/usrcheat.phtml)
  39897.  
  39898.    * The "Powered By" Page (Kcilink) (http://www.kcilink.com/poweredby/)
  39899.  
  39900.    * Netcasting (http://www.netcasting.net/index.whtml)
  39901.  
  39902.    * NBL (Australian National Basketball League) tipping
  39903.      (http://homepages.tig.com.au/~mjj/nbltips)
  39904.  
  39905.    * CGI shop (http://www.cgishop.com/)
  39906.  
  39907.    * Whirlycott: Website Design (http://www.whirlycott.com/)
  39908.  
  39909.    * Museum Tusculanum Press (http://www.mtp.dk)
  39910.  
  39911.    * Centro Siciliano di Documentazione
  39912.      (http://csdgi.historie.ku.dk/biblio)
  39913.  
  39914.    * Quake statistics database (http://caribou.dyn.ml.org:8000)
  39915.  
  39916.    * Astroforum: Astrologie and related things (in German)
  39917.      (http://www.astroforum.ch)
  39918.  
  39919.    * OpenDebate - Interactive Polls & Open Discussion
  39920.      (http://www.opendebate.com)
  39921.  
  39922.    * Online chemical dissertation server
  39923.      (http://vermeer.organik.uni-erlangen.de/dissertationen/)
  39924.  
  39925.    * FreSch! The Free Scholarship Search Service
  39926.      (http://www.freschinfo.com)
  39927.  
  39928.    * Stockholm Pinball Locator
  39929.      (http://www.nada.kth.se/~staffanu/pinball)
  39930.  
  39931.    * HEK A construction company (http://www.hek.com)
  39932.  
  39933.    * Elsevier Bussines Information (http://www.nbi.nl)
  39934.  
  39935.    * Medical Links (Using ColdFusion and MySQL)
  39936.      (http://vaccination.medicallink.se/)
  39937.  
  39938.    * Search for jobs & people at JobLink-USA
  39939.      (http://www.joblink-usa.com)
  39940.  
  39941.    * Competition Formation Skydiving (http://www.skydive.net/competfs)
  39942.  
  39943.    * E-commerce and internal accounting
  39944.      (http://www.galaxy-net.net/Galaxy-NET Telecommunications)
  39945.  
  39946.    * Denmark's leading business daily newspaper B/orsen
  39947.      (http://www.borsen.dk/)
  39948.  
  39949.    * The Internet NES Database (http://tmmm.simplenet.com/indb/)
  39950.  
  39951.    * Travel agency in Prague in 3 languages (http://www.russia.cz)
  39952.  
  39953.    * Linkstation (http://www.linkstation.de)
  39954.  
  39955.    * Searchable online database at Peoplestaff
  39956.      (http://www.peoplestaff.com)
  39957.  
  39958.    * A searchable database system for horse classified ads
  39959.      (http://www.dreamhorse.com)
  39960.  
  39961.    * The Poot site (http://pootpoot.com/)
  39962.  
  39963.    * "Playin' in the LAN"; a network monitoring suite
  39964.      (http://grateful.net/hw_html/)
  39965.  
  39966.    * U.S. Army Publishing Agency (http://www.usapa.army.mil)
  39967.  
  39968.    * Realestate handling in Yugoslavia (http://www.nekretnine.co.yu/)
  39969.  
  39970.    * PIMS; a Patient Information Management System
  39971.      (http://demo.cpsoft.com/pims/devFAQ.html)
  39972.  
  39973.    * Pilkington Software Inc (http://cpsoft.com)
  39974.  
  39975.    * A Vietnam Veteran's Memorial (The Wall) database
  39976.      (http://www.no-quarter.org/)
  39977.  
  39978.    * Gamer's Union specializes in auctions of used & out-of-print
  39979.      gaming material (http://www.gamers-union.com/)
  39980.  
  39981.    * A daily bulletin at Monterey High school
  39982.      (http://www.montereyhigh.com/office/dbul.php3)
  39983.  
  39984.    * Community-owned site serving Lake Washington's Eastside residents
  39985.      and businesses (http://www.myEastside.com)
  39986.  
  39987.    * French bowling site (http://bowling-france.net/)
  39988.  
  39989. Send any additions to this list to <webmaster@mysql.com>.
  39990.  
  39991. 
  39992. File: mysql.info,  Node: MySQL customer usage,  Next: Contrib,  Prev: Users,  Up: Top
  39993.  
  39994. MySQL customer usage
  39995. ********************
  39996.  
  39997. The section 'Some MySQL Users' contains a lot of different links to
  39998. MySQL users but doesn't provide that much information about how they
  39999. are using MySQL.  *Note Users::. This manual section is to give you an
  40000. idea of how other MySQL users are using MySQL to solve their problems.
  40001.  
  40002. This manual section is very new and we plan to add more stories here
  40003. shortly.  If you are interested in contributing of how you use MySQL in
  40004. a unique environment or have success store about how you use MySQL, you
  40005. can write to `docs@mysql.com' with subject `Success:'.  Note that as we
  40006. are very busy it may take some time before you get some feedback for
  40007. your story.
  40008.  
  40009.    * *Peter Zaitsev of Spylog.ru* writes: I think you might be
  40010.      interested in my database size.  The whole database is currently
  40011.      on 15 servers and I think it's about 60.000 of tables containing
  40012.      about 5.000.000.000 of rows.  My mostly loaded server currently
  40013.      holds about 10.000 of tables with 1.000.000.000 of rows in it.
  40014.      Hugest tables have about 50.000.000 of rows, and this value will
  40015.      raise as soon as I'll move to 2.4 kernel with large files.
  40016.      Currently I have to delete much of logs for large sites to hold
  40017.      table sizes in 2Gb.
  40018.  
  40019.    * *Texas Instruments* is using MySQL for handling tables that
  40020.      contain up to 2,000 million rows in a validation regression
  40021.      database.
  40022.  
  40023. 
  40024. File: mysql.info,  Node: Contrib,  Next: Credits,  Prev: MySQL customer usage,  Up: Top
  40025.  
  40026. Contributed Programs
  40027. ********************
  40028.  
  40029. Many users of MySQL have contributed _very_ useful support tools and
  40030. add-ons.
  40031.  
  40032. A list of what is available at `http://www.mysql.com/Downloads/Contrib/'
  40033. (or any mirror) is shown below.  If you want to build MySQL support for
  40034. the Perl `DBI'/`DBD' interface, you should fetch the `Data-Dumper',
  40035. `DBI', and `Msql-Mysql-modules' files and install them.  *Note Perl
  40036. support::.
  40037.  
  40038. APIs
  40039. ====
  40040.  
  40041.    * Perl Modules
  40042.         - Data-Dumper-2.101.tar.gz
  40043.           (http://www.mysql.com/Downloads/Contrib/Data-Dumper-2.101.tar.gz)
  40044.           Perl `Data-Dumper' module.  Useful with `DBI'/`DBD' support
  40045.           for older Perl installations.
  40046.  
  40047.         - DBI-1.15.tar.gz
  40048.           (http://www.mysql.com/Downloads/Contrib/DBI-1.15.tar.gz) Perl
  40049.           `DBI' module.
  40050.  
  40051.         - KAMXbase1.2.tar.gz
  40052.           (http://www.mysql.com/Downloads/Contrib/KAMXbase1.2.tar.gz)
  40053.           Convert between `.dbf' files and MySQL tables.  Perl module
  40054.           written by Pratap Pereira <pereira@ee.eng.ohio-state.edu>,
  40055.           extended by Kevin A. McGrail
  40056.           <kmcgrail@digital1.peregrinehw.com>.  This converter can
  40057.           handle MEMO fields.
  40058.  
  40059.         - Msql-Mysql-modules-1.2216.tar.gz
  40060.           (http://www.mysql.com/Downloads/Contrib/Msql-Mysql-modules-1.2216.tar.gz)
  40061.           Perl `DBD' module to access mSQL and MySQL databases.
  40062.  
  40063.         - Data-ShowTable-3.3.tar.gz
  40064.           (http://www.mysql.com/Downloads/Contrib/Data-ShowTable-3.3.tar.gz)
  40065.           Perl `Data-ShowTable' module.  Useful with `DBI'/`DBD'
  40066.           support.
  40067.  
  40068.         - HandySQL-1.1.tar.gz
  40069.           (http://www.mysql.com/Downloads/Contrib/HandySQL-1.1.tar.gz)
  40070.           HandySQL is a MySQL access module. It offers a C interface
  40071.           embedded in Perl and is approximately 20% faster than regular
  40072.           DBI.
  40073.  
  40074.  
  40075.    * JDBC
  40076.         * mm.mysql.jdbc-1.2c.tar.gz
  40077.           (http://www.mysql.com/Downloads/Contrib/mm.mysql.jdbc-1.2c.tar.gz)
  40078.           The mm JDBC driver for MySQL. This is a production release
  40079.           and is actively developed. By Mark Matthews
  40080.           (<mmatthew@ecn.purdue.edu>).
  40081.  
  40082.         * mm.mysql.jdbc-2.0pre5.tar.gz
  40083.           (http://www.mysql.com/Downloads/Contrib/mm.mysql.jdbc-2.0pre5.tar.gz)
  40084.           The mm JDBC driver for MySQL. This is a pre-release beta
  40085.           version and is actively developed. By Mark Matthews
  40086.           (<mmatthew@ecn.purdue.edu>).  The two drivers above have an
  40087.           LGPL license. Please check
  40088.           `http://www.worldserver.com/mm.mysql/' for the latest drivers
  40089.           (and other JDBC information) because these drivers may be out
  40090.           of date.
  40091.  
  40092.         * `http://www.caucho.com/projects/jdbc-mysql/index.xtp' The
  40093.           Resin commercial JDBC driver, which is released under open
  40094.           source.  It claims to be faster than the mm driver, but we
  40095.           haven't received that much information about this yet.
  40096.  
  40097.         * twz1jdbcForMysql-1.0.4-GA.tar.gz
  40098.           (http://www.mysql.com/Downloads/Contrib/twz1jdbcForMysql-1.0.4-GA.tar.gz)
  40099.           The twz driver: A type 4 JDBC driver by Terrence W. Zellers
  40100.           <zellert@voicenet.com>.  This is commercial but is free for
  40101.           private and educational use. (Not supported anymore.)
  40102.  
  40103.         * pmdamysql.tgz
  40104.           (http://www.mysql.com/Downloads/Contrib/pmdamysql.tgz) A
  40105.           MySQL PMDA. Provides MySQL server status and configuration
  40106.           variables.
  40107.  
  40108.    * OLEDB
  40109.         * MyOLEDB.exe (http://www.mysql.com/Downloads/Win32/MyOLEDB.exe)
  40110.           OLEDB handler for MySQL. By SWsoft.
  40111.  
  40112.         * MySamples.zip
  40113.           (http://www.mysql.com/Downloads/Win32/MySamples.zip) Examples
  40114.           and documentation for MyOLEDB. By SWsoft.
  40115.  
  40116.         * Myoledb.zip (http://www.mysql.com/Downloads/Win32/Myoledb.zip)
  40117.           Source for MyOLEDB. By SWsoft.
  40118.  
  40119.         * MyOLEDB.chm (http://www.mysql.com/Downloads/Win32/MyOLEDB.chm)
  40120.           Help files for MyOLEDB.
  40121.  
  40122.         * libmyodbc.zip
  40123.           (http://www.mysql.com/Downloads/Win32/libmyodbc.zip) Static
  40124.           MyODBC library used for build MyOLEDB. Based on MyODBC code.
  40125.  
  40126.    * C++
  40127.         * mysql-c++-0.02.tar.gz
  40128.           (http://www.mysql.com/Downloads/Contrib/mysql-c++-0.02.tar.gz)
  40129.           MySQL C++ wrapper library. By Roland Haenel, <rh@ginster.net>.
  40130.  
  40131.         * MyDAO (http://www.mysql.com/Downloads/Contrib/MyDAO.tar.gz)
  40132.           MySQL C++ API. By Satish <spitfire@pn3.vsnl.net.in>. Inspired
  40133.           by Roland Haenel's C++ API and Ed Carp's MyC library.
  40134.  
  40135.         * mysql++ (http://www.mysql.com/download_mysql++.html) MySQL
  40136.           C++ API (More than just a wrapper library.) Originally by
  40137.           <kevina@clark.net>. Nowadays maintained by Sinisa at MySQL AB.
  40138.  
  40139.         * NJrAPI (http://nelsonjr.homepage.com/NJrAPI) A C++ database
  40140.           independent library that supports MySQL.
  40141.  
  40142.    * Delphi
  40143.         * delphi-interface.gz
  40144.           (http://www.mysql.com/Downloads/Contrib/delphi-interface.gz)
  40145.           Delphi interface to `libmysql.dll', by Blestan Tabakov,
  40146.           <root@tdg.bis.bg>.
  40147.  
  40148.         * DelphiMySQL2.zip
  40149.           (http://www.mysql.com/Downloads/Contrib/DelphiMySQL2.zip)
  40150.           Delphi interface to `libmysql.dll', by
  40151.           <bsilva@umesd.k12.or.us>.
  40152.  
  40153.         * Udmysql.pas
  40154.           (http://www.mysql.com/Downloads/Contrib/Udmysel.pas) A
  40155.           wrapper for libmysql.dll for usage in Delphi. By Reiner
  40156.           Sombrowsky.
  40157.  
  40158.         * A Delphi interface to MySQL.
  40159.           (http://www.fichtner.net/delphi/mysql.delphi.phtml) With
  40160.           source code. By Matthias Fichtner.
  40161.  
  40162.         * *TmySQL* A library to use MySQL with Delphi
  40163.           (http://www.productivity.org/projects/tmysql/).
  40164.  
  40165.         * Delphi TDataset-component
  40166.           (http://www.geocities.com/CapeCanaveral/2064/mysql.html).
  40167.  
  40168.         *        * Delphi 5 Shareware MySQL Dataset Components
  40169.           (http://www.mysql.com/Downloads/Contrib/Win32/SBMySQL50Share.exe)
  40170.  
  40171.    * mysql-ruby-2.2.0.tar.gz
  40172.      (http://www.mysql.com/Downloads/Contrib/mysql-ruby-2.2.0.tar.gz)
  40173.      MySQL Ruby module. By TOMITA Masahiro <tommy@tmtm.org>
  40174.      `http://www.netlab.co.jp/ruby/. Ruby' is an Object-Oriented
  40175.      Interpreter Language.
  40176.  
  40177.    * JdmMysqlDriver-0.1.0.tar.gz
  40178.      (http://www.mysql.com/Downloads/Contrib/JdmMysqlDriver-0.1.0.tar.gz)
  40179.      A VisualWorks 3.0 Smalltalk driver for MySQL. By
  40180.      <joshmiller@earthlink.net>.
  40181.  
  40182.    * Db.py (http://www.mysql.com/Downloads/Contrib/Db.py) Python module
  40183.      with caching. By <gandalf@rosmail.com>.
  40184.  
  40185.    * MySQLmodule-1.4.tar.gz
  40186.      (http://www.mysql.com/Downloads/Contrib/MySQLmodule-1.4.tar.gz)
  40187.      Python interface for MySQL. By Joseph Skinner
  40188.      <joe@earthlight.co.nz>. Modified by Joerg Senekowitsch
  40189.      <senekow@ibm.net>.
  40190.  
  40191.    * MySQL-python-0.3.0.tar.gz
  40192.      (http://www.mysql.com/Downloads/Contrib/MySQL-python-0.3.0.tar.gz)
  40193.      MySQLdb Python is an DB-API v2.0-compliant interface to MySQL.
  40194.      Transactions are supported if the server and tables support them.
  40195.      It is thread-safe, and contains a compatibility module for older
  40196.      code written for the no-longer-maintained MySQLmodule interface.
  40197.  
  40198.    * mysql_mex_1_12.tar.gz
  40199.      (http://www.mysql.com/Downloads/Contrib/mysql_mex_12.tar.gz) An
  40200.      interface program for the Matlab program by MathWorks.  The
  40201.      interface is done by Kimmo Uutela and John Fisher (not by
  40202.      Mathworks).  Check mysqlmex.html
  40203.      (http://boojum.hut.fi/~kuutela/mysqlmex.html) for more information.
  40204.  
  40205.    * mysqltcl-1.53.tar.gz
  40206.      (http://www.mysql.com/Downloads/Contrib/mysqltcl-1.53.tar.gz) Tcl
  40207.      interface for MySQL. Based on `msqltcl-1.50.tar.gz'.  Updated by
  40208.      Tobias Ritzau, <tobri@ida.liu.se>.
  40209.  
  40210.    * MyC-0.1.tar.gz
  40211.      (http://www.mysql.com/Downloads/Contrib/MyC-0.1.tar.gz) A Visual
  40212.      Basic-like API, by Ed Carp.
  40213.  
  40214.    * sqlscreens-1.0.1.tar.gz
  40215.      (http://www.mysql.com/Downloads/Contrib/sqlscreens-1.0.1.tar.gz)
  40216.      Tcl/Tk code to generate database screens. By Jean-Francois Dockes.
  40217.  
  40218.    * Vdb-dflts-2.1.tar.gz
  40219.      (http://www.mysql.com/Downloads/Contrib/Vdb-dflts-2.1.tar.gz) This
  40220.      is a new version of a set of library utilities intended to provide
  40221.      a generic interface to SQL database engines such that your
  40222.      application becomes a 3-tiered application.  The advantage is that
  40223.      you can easily switch between and move to other database engines by
  40224.      implementing one file for the new backend without making any
  40225.      changes to your applications. By <damian@cablenet.net>.
  40226.  
  40227.    * DbFramework-1.10.tar.gz
  40228.      (http://www.mysql.com/Downloads/Contrib/DbFramework-1.10.tar.gz)
  40229.      DbFramework is a collection of classes for manipulating MySQL
  40230.      databases.  The classes are loosely based on the CDIF Data Model
  40231.      Subject Area. By Paul Sharpe <paul@miraclefish.com>.
  40232.  
  40233.    * pike-mysql-1.4.tar.gz
  40234.      (http://www.mysql.com/Downloads/Contrib/pike-mysql-1.4.tar.gz)
  40235.      MySQL module for pike. For use with the Roxen web server.
  40236.  
  40237.    * squile.tar.gz
  40238.      (http://www.mysql.com/Downloads/Contrib/squile.tar.gz) Module for
  40239.      `guile' that allows `guile' to interact with SQL databases. By Hal
  40240.      Roberts.
  40241.  
  40242.    * stk-mysql.tar.gz
  40243.      (http://www.mysql.com/Downloads/Contrib/stk-mysql.tar.gz)
  40244.      Interface for Stk. Stk is the Tk widgets with Scheme underneath
  40245.      instead of Tcl.  By Terry Jones.
  40246.  
  40247.    * eiffel-wrapper-1.0.tar.gz
  40248.      (http://www.mysql.com/Downloads/Contrib/eiffel-wrapper-1.0.tar.gz)
  40249.      Eiffel wrapper by Michael Ravits.
  40250.  
  40251.    * SQLmy0.06.tgz
  40252.      (http://www.mysql.com/Downloads/Contrib/SQLmy0.06.tgz) FlagShip
  40253.      Replaceable Database Driver (RDD) for MySQL. By Alejandro
  40254.      Fernandez Herrero.  Flagship RDD home page
  40255.      (http://www.fship.com/rdds.html)
  40256.  
  40257.    * mydsn-1.0.zip
  40258.      (http://www.mysql.com/Downloads/Contrib/mydsn-1.0.zip) Binary and
  40259.      source for `mydsn.dll'. mydsn should be used to build and remove
  40260.      the DSN registry file for the MyODBC driver in Coldfusion
  40261.      applications.  By Miguel Angel Sol≤rzano.
  40262.  
  40263.    * MySQL-ADA95_API.zip
  40264.      (http://www.mysql.com/Downloads/Contrib/MySQL-ADA95_API.zip) An
  40265.      ADA95 interface to the MySQL API. By Francois Fabien.
  40266.  
  40267.    * MyTool-DLL_for_VB_and_MySQL.zip
  40268.      (http://www.mysql.com/Downloads/Contrib/MyTool-DLL_for_VB_and_MySQL.zip)
  40269.      A DLL with MySQL C API for Visual Basic.  By Ken Menzel
  40270.      <kenm@icarz.com>.
  40271.  
  40272.    * MYSQL.EXE (http://www.mysql.com/Downloads/Contrib/MYSQLX.EXE)
  40273.      MySQL ActiveX Object for directly accessing your MySQL servers
  40274.      from IIS/ASP, VB, VC++ skipping the slower ODBC methods. Fully
  40275.      updatable, multithreaded with full support for all MySQL fieldtypes
  40276.      (version 2001.1.1). By SciBit `http://www.scibit.com/'.
  40277.  
  40278.    * MyLUA home page (http://www.fastflow.it/mylua/) How to use the LUA
  40279.      language to write MySQL `PROCEDURE' that can be loaded runtime.
  40280.  
  40281.         * Lua 4.0
  40282.           (http://www.mysql.com/Downloads/Contrib/lua-4.0.tar.gz) LUA
  40283.           4.0
  40284.  
  40285.         * mylua-3.23.32.1.tar.gz
  40286.           (http://www.mysql.com/Downloads/Contrib/mylua-3.23.32.1.tar.gz)
  40287.           Patch for MySQL 3.23.32 to use LUA 4.0.  By Cristian Giussani.
  40288.  
  40289.    * patched_myodbc.zip
  40290.      (http://www.mysql.com/Downloads/Contrib/patched_myodbc.zip) Patch
  40291.      (for Omniform 4.0 support) to the MyODBC driver.  By Thomas Thaele
  40292.      <tthaele@papenmeier.de>
  40293.  
  40294.  
  40295. Clients
  40296. =======
  40297.  
  40298.    * Graphical clients
  40299.         - DbVisualizer (http://www.ideit.com/products/dbvis/).
  40300.           Freeware JDBC client to graphically visualize the data and
  40301.           structure of several databases simultaneously. By
  40302.           Innovative-IT Development AB.
  40303.  
  40304.         - MySQLGUI (http://www.mysql.com/downloads/gui-clients.html)
  40305.           The MySQL GUI client homepage. By Sinisa at MySQL AB.
  40306.  
  40307.         - MySQL navigator 0.9
  40308.           (http://www.mysql.com/Downloads/Contrib/mysql_navigator_0.9.0.tar.gz)
  40309.           MySQL Navigator is a MySQL database server GUI client
  40310.           program. The purpose of MySQL Navigator is to provide a
  40311.           useful client interface to MySQL database servers, whilst
  40312.           supporting multiple operating systems and languages. You can
  40313.           currently import/export database, enter queries, get result
  40314.           sets, edit scripts, run scripts, add, alter, and delete users,
  40315.           and retrieve client and server information. Uses QT 2.2. GPL
  40316.           Home page for MySQL Navigator (http://sql.kldp.org/mysql).
  40317.  
  40318.         - MySQL Security GUI
  40319.           (http://www.mysql.com/Downloads/Win32/secman.zip) A user and
  40320.           security management GUI for MySQL on Windows.  By Martin
  40321.           Jeremic.  Home page for MySQL Security GUI
  40322.           (http://jsoft.webjump.com/).
  40323.  
  40324.         - kmysqladmin-0.4.1.tar.gz
  40325.           (http://www.mysql.com/Downloads/Contrib/kmysqladmin-0.4.1.tar.gz).
  40326.  
  40327.         - kmysqladmin-0.4.1-1.src.rpm
  40328.           (http://www.mysql.com/Downloads/Contrib/kmysqladmin-0.4.1-1.src.rpm).
  40329.  
  40330.         - kmysqladmin-0.4.1-1.i386.rpm
  40331.           (http://www.mysql.com/Downloads/Contrib/kmysqladmin-0.4.1-1.i386.rpm)
  40332.           An administration tool for the MySQL server using QT / KDE.
  40333.           Tested only on Linux.
  40334.  
  40335.         - Java client using Swing
  40336.           (http://www.mysql.com/Downloads/Contrib/mysql-admin-using-java+swing.tar.gz)
  40337.           By Fredy Fischer, <se-afs@dial.eunet.ch>.  You can always
  40338.           find the latest version here
  40339.           (http://www.trash.net/~ffischer/admin/index.html).
  40340.  
  40341.         - MySQL-Maker 1.0
  40342.           (http://www.mysql.com/Downloads/Win32/MySQL-Maker-1.0.zip).
  40343.           Shareware MySQL client for Windows. It's a WYSIWYG tool which
  40344.           allows you to create, change and delete databases and tables.
  40345.           You can change field - structure and add, change and delete
  40346.           data in these tables directly without ODBC-driver.  MySQL
  40347.           Maker homepage
  40348.           (http://www.presult.de/presult/frames/fs_mysqlmaker.html)
  40349.  
  40350.         - mysqlwinadmn.zip
  40351.           (http://www.mysql.com/Downloads/Contrib/mysqlwinadmn.zip)
  40352.           Windows GUI (binary only) to administrate a database, by
  40353.           David B. Mansel, <david@zhadum.org>.
  40354.  
  40355.         - MyQA (http://home.online.no/~runeberg/myqa) is a Linux-based
  40356.           query client for the MySQL database server. MyQA lets you
  40357.           enter SQL queries, execute them, and view the results, all in
  40358.           a graphical user interface. The GUI is roughly similar to
  40359.           that of the 'Query Analyzer' client that comes with MS SQL
  40360.           Server.
  40361.  
  40362.         - MySQL Manager
  40363.           (http://members.xoom.com/_opex_/mysqlmanager/index.html) a
  40364.           graphical MySQL server manager for MySQL server written in
  40365.           Java, for Windows
  40366.  
  40367.         - netadmin.zip
  40368.           (http://www.mysql.com/Downloads/Win32/netadmin.zip) An
  40369.           administrator tool for MySQL on Windows 95/98 and Windows NT
  40370.           4.0. Only tested with MySQL Versions 3.23.5 - 3.23.7. Written
  40371.           using the Tmysql components.
  40372.  
  40373.           You can write queries and show tables, indexes, table syntax,
  40374.           and administrate user, host, and database and so on. This is
  40375.           beta and still has some bugs. You can test the program with
  40376.           all features. Please send bugs and hints to Marco Suess
  40377.           <ms@it-netservice.de>. Original URL
  40378.           <http://www.it-netservice.de/pages/software/index.html>.
  40379.  
  40380.         - netadmin2.zip
  40381.           (http://www.mysql.com/Downloads/Win32/netadmin2.zip) New
  40382.           version of netadmin. See above for details.
  40383.  
  40384.         - Atronic's MySQL client for Windows 2.0.3.0
  40385.           (http://www.mysql.com/Downloads/Win32/ARTADMIN203.EXE).  Home
  40386.           page for this can be found at: `http://www.artronic.hr'.
  40387.  
  40388.         - mysqlfront
  40389.           (http://www.mysql.com/Downloads/Win32/mysqlfront.zip) Home
  40390.           page: `http://www.mysqlfront.de/'.  Win32-Client for
  40391.           accessing and managing dbs, tables, table-data, indexes,
  40392.           import-/export-files. (Freeware).  By Ansgar Becker.
  40393.  
  40394.         - Utility from Artronic to stop MySQL on win9x
  40395.           (http://www.mysql.com/Downloads/Win32/W9xstop.zip).
  40396.  
  40397.         - a light weight GUI client for Windows
  40398.           (http://bardo.hyperlink.cz/mysqlmon).
  40399.  
  40400.         - Dbtools (http://dbtools.vila.bol.com.br/) A tool to manage
  40401.           MySQL databases. Currently only for Windows.  Some features:
  40402.              * Manage servers, databases, tables, columns, indexes, and
  40403.                users
  40404.  
  40405.              * Import wizard to import structure and data from MS
  40406.                Access, MS Excel, Dbase, FoxPro, Paradox, and ODBC
  40407.                Databases.
  40408.  
  40409.              * KMYENG113.zip
  40410.                (http://www.mysql.com/Downloads/Contrib/KMYENG113.zip)
  40411.                An administrator GUI for MySQL. Works only on windows,
  40412.                no source.  Available in English and Japanese. By
  40413.                Mitunobu Kaneko.  Home page: `http://sql.jnts.ne.jp/'
  40414.  
  40415.         - xmysqladmin-1.0.tar.gz
  40416.           (http://www.mysql.com/Downloads/Contrib/xmysqladmin-1.0.tar.gz)
  40417.           An X-based front end to the MySQL database engine.  It allows
  40418.           reloads, status check, process control, myisamchk,
  40419.           grant/revoke privileges, creating databases, dropping
  40420.           databases, create, alter, browse, and drop tables.
  40421.           Originally by Gilbert Therrien, <gilbert@ican.net> but now in
  40422.           public domain and supported by MySQL AB.
  40423.  
  40424.         - xmysql-1.9.tar.gz
  40425.           (http://www.mysql.com/Downloads/Contrib/xmysql-1.9.tar.gz).
  40426.  
  40427.         - xmysql home page (http://web.wt.net/~dblhack) A front end to
  40428.           the MySQL database engine. It allows for simple queries and
  40429.           table maintenance, as well as batch queries. By Rick
  40430.           Mehalick, <dblhack@wt.net>.  Requires xforms 0.88
  40431.           (http://bragg.phys.uwm.edu/xforms) to work.
  40432.  
  40433.         - dbMetrix (http://www.tamos.net/sw/dbMetrix) An open source
  40434.           client for exploring databases and executing SQL. Supports
  40435.           MySQL, Oracle, PostgreSQL, and mSQL.
  40436.  
  40437.         - GtkSQL (http://www.multimania.com/bbrox/GtkSQL) A query tool
  40438.           for MySQL and PostgreSQL.
  40439.  
  40440.         - dbMan (http://dbman.linux.cz/) A query tool written in Perl.
  40441.           Uses DBI and Tk.
  40442.  
  40443.         - Mascon 202 (http://www.mysql.com/Downloads/Win32/Msc201.EXE)
  40444.  
  40445.         - Free Mascon 202
  40446.           (http://www.mysql.com/Downloads/Win32/FrMsc202.EXE) Mascon is
  40447.           a powerful Win32 GUI for the administering MySQL server
  40448.           databases. Mascon's features include visual table design,
  40449.           connections to multiple servers, data and blob editing of
  40450.           tables, security setting, SQL color coding, dump
  40451.           functionality and much more.  Mascon home page
  40452.           (http://www.scibit.com/Products/Software/Utils/Mascon.asp).
  40453.  
  40454.         - DBUI (http://www.virtualbeer.net/dbui/) DBUI is a Gtk
  40455.           graphical database editor.
  40456.  
  40457.         - MacSQL (http://www.rtlabs.com/) GUI for MySQL, ODBC, and JDBC
  40458.           databases for the Mac OS.
  40459.  
  40460.         - JRetriever (http://www.caleb.com.au/) JRetriever is a generic
  40461.           database front-end tool for JDBC compliant databases written
  40462.           with Java 2. JRetriever displays database tables/views in a
  40463.           Windows explorer-like front end. Users can retrieve data
  40464.           either by clicking on the table folder or by composing their
  40465.           own SQL statements with our built-in SQL editor. The tool has
  40466.           been tested with Oracle 8 and MySQL as the back-end
  40467.           databases. It requires JDK 1.3 from JavaSoft.
  40468.  
  40469.         - DataBrowser (http://www.jetools.com/products/databrowser/)
  40470.           The DataBrowser is a cross-database, cross-platform data
  40471.           access tool. It is more user friendly than tools like SQL
  40472.           Plus, psql (command line based tools). It is more flexible
  40473.           than TOAD, ISQL, PGAccess which are GUI's that are limitied
  40474.           to a single platform or database.
  40475.  
  40476.         - SQLC (http://www.intrex.net/amit/software/) The SQL Console
  40477.           is a standalone java application that allows you to connect
  40478.           to a  SQL database system and issue SQL queries and updates.
  40479.           It has an easy-to use graphical user interface. The SQL
  40480.           Console uses JDBC to connect to the database systems and,
  40481.           therefore, with proper JDBC drivers, you can use this utility
  40482.           to connect to some of the most popular database systems.
  40483.  
  40484.         - MySQL MMC
  40485.           (http://www.mysql.com/Downloads/Contrib/mysql_mmc.zip) MySQL
  40486.           MMC is a GUI Management Tool developed using kdevelop with a
  40487.           very good interface completely like Microsoft Enterprise Tool
  40488.           (for SQL Server) or Sybase Central. We can use it to manage
  40489.           server, database, table, index, users and to edit table data
  40490.           in grid or execute Sql by Query Analysis.
  40491.  
  40492.    * Web Clients
  40493.         - mysqladmin-atif-1.0.tar.gz
  40494.           (http://www.mysql.com/Downloads/Contrib/mysqladmin-atif-1.0.tar.gz)
  40495.           WWW MySQL administrator for the `user,' `db' and `host'
  40496.           tables.  By Tim Sailer, modified by Atif Ghaffar
  40497.           <aghaffar@artemedia.ch>.
  40498.  
  40499.         - mysql-webadmin-1.0a8-rz.tar.gz
  40500.           (http://www.mysql.com/Downloads/Contrib/mysql-webadmin-1.0a8-rz.tar.gz)
  40501.           A tool written in PHP-FI to administrate MySQL databases
  40502.           remotely over the web within a Web-Browser. By Peter
  40503.           Kuppelwieser, <peter.kuppelwieser@kantea.it>. Updated by Wim
  40504.           Bonis, <bonis@kiss.de>. Not maintained anymore!
  40505.  
  40506.         - mysqladm.tar.gz
  40507.           (http://www.mysql.com/Downloads/Contrib/mysqladm.tar.gz)
  40508.           MySQL Web Database Administration written in Perl.  By Tim
  40509.           Sailer.
  40510.  
  40511.         - mysqladm-2.tar.gz
  40512.           (http://www.mysql.com/Downloads/Contrib/mysqladm-2.tar.gz)
  40513.           Updated version of `mysqladm.tar.gz', by High Tide.
  40514.  
  40515.         - billowmysql.zip
  40516.           (http://www.mysql.com/Downloads/Contrib/billowmysql.zip)
  40517.           Updated version of `mysqladm.tar.gz', by Ying Gao.  You can
  40518.           get the newest version from the home site
  40519.           (http://civeng.com/sqldemo/).
  40520.  
  40521.         - myadmin-0.4.tar.gz
  40522.           (http://www.mysql.com/Downloads/Contrib/myadmin-0.4.tar.gz).
  40523.  
  40524.         - MyAdmin home page (http://myadmin.cheapnet.net/) A Web-based
  40525.           MySQL administrator by Mike Machado.
  40526.  
  40527.         - phpMyAdmin_2.0.1.tar.gz
  40528.           (http://www.mysql.com/Downloads/Contrib/phpMyAdmin_2.0.1.tar.gz)
  40529.           A set of PHP3-scripts to adminstrate MySQL over the WWW.
  40530.  
  40531.         - phpMyAdmin home page
  40532.           (http://www.phpwizard.net/projects/phpMyAdmin/) A PHP3 tool
  40533.           in the spirit of mysql-webadmin, by Tobias Ratschiller,
  40534.           tobias@dnet.it.
  40535.  
  40536.         - useradm.tar.gz
  40537.           (http://www.mysql.com/Downloads/Contrib/useradm.tar.gz) MySQL
  40538.           administrator in PHP. By Ofni Thomas
  40539.           <othomas@vaidsystems.com>.
  40540.  
  40541.         - MySQLMan (http://gossamer-threads.com/perl/mysqlman/mysql.cgi)
  40542.           Similar functionality as phpmyadmin, but written with Perl
  40543.           and using html templates. By Alex Krohn.
  40544.  
  40545.    * mysql-editor.tar.gz
  40546.      (http://www.mysql.com/Downloads/Contrib/mysql-editor.tar.gz) This
  40547.      cgi scripts in Perl enables you to edit content of Mysql database.
  40548.      By Tomas Zeman.
  40549.  
  40550.    * FutureSQL Web Database Administration Tool
  40551.      (http://worldcommunity.com/opensource/futuresql).  FutureSQL by
  40552.      Peter F. Brown, is a free, open source rapid application
  40553.      development Web database administration tool, written in Perl,
  40554.      using MySQL. It uses `DBI:DBD' and `CGI.pm'.
  40555.  
  40556.      FutureSQL allows one to easily set up config files to view, edit,
  40557.      delete, and otherwise process records from a MySQL database. It
  40558.      uses a data dictionary, configuration files and templates, and
  40559.      allows "pre-processing" and "post-processing" on both fields,
  40560.      records, and operations.
  40561.  
  40562. Web Tools
  40563. =========
  40564.  
  40565.    * mod_mysql_include_1.0.tar.gz
  40566.      (http://www.mysql.com/Downloads/Contrib/mod_mysql_include_1.0.tar.gz)
  40567.      Apache module to include HTML from MySQL queries into your pages,
  40568.      and run update queries.  Originally written to implement a simple
  40569.      fast low-overhead banner-rotation system.  By Sasha Pachev.
  40570.  
  40571.    * htCheck (http://htcheck.sourceforge.net) - URL checker with MySQL
  40572.      backend. Spidered URLs can later be queried using SQL to retrieve
  40573.      various kinds of information, eg. broken links. Written by
  40574.      Gabriele Bartolini.
  40575.  
  40576.    * `http://www.odbsoft.com/cook/sources.htm' This package has various
  40577.      functions for generating html code from a SQL table structure and
  40578.      for generating SQL statements (Select, Insert, Update, Delete)
  40579.      from an html form. You can build a complete forms interface to a
  40580.      SQL database (query, add, update, delete) without any programming!
  40581.      By Marc Beneteau, <marc@odbsoft.com>.
  40582.  
  40583.    * sqlhtml.tar.gz
  40584.      (http://www.mysql.com/Downloads/Contrib/sqlhtml.tar.gz) SQL/HTML
  40585.      is an HTML database manager for MySQL using `DBI' 1.06.
  40586.  
  40587.    * UdmSearch 3.0.23 (stable version)
  40588.      (http://www.mysql.com/Downloads/Contrib/udmsearch-3.0.23.tar.gz).
  40589.  
  40590.    * mnogosearch 3.1.12 (development but recommended version)
  40591.      (http://www.mysql.com/Downloads/Contrib/mnogosearch-3.1.12.tar.gz).
  40592.  
  40593.    * UdmSearch home page (http://search.mnoGo.ru) A SQL-based search
  40594.      engine for Internet. By Alexander I. Barkov <bar@izhcom.ru>.
  40595.  
  40596.    * wmtcl.doc (http://www.mysql.com/Downloads/Contrib/wmtcl.doc).
  40597.  
  40598.    * wmtcl.lex (http://www.mysql.com/Downloads/Contrib/wmtcl.lex) With
  40599.      this you can write HTML files with inclusions of Tcl code. By
  40600.      <vvs@scil.npi.msu.su>.
  40601.  
  40602.    * www-sql-0.5.7.lsm
  40603.      (http://www.mysql.com/Downloads/Contrib/www-sql-0.5.7.lsm).
  40604.  
  40605.    * www-sql-0.5.7.tar.gz
  40606.      (http://www.mysql.com/Downloads/Contrib/www-sql-0.5.7.tar.gz) A
  40607.      CGI program that parses an HTML file containing special tags,
  40608.      parses them, and inserts data from a MySQL database.
  40609.  
  40610.    * genquery.zip (http://www.mysql.com/Downloads/Contrib/genquery.zip)
  40611.      Perl SQL database interface package for html.
  40612.  
  40613.    * cgi++-0.8.tar.gz
  40614.      (http://www.mysql.com/Downloads/Contrib/cgi++-0.8.tar.gz) A
  40615.      macro-processor to simply writing CGI/Database programs in C++ by
  40616.      Sasha Pachev.
  40617.  
  40618.    * WebBoard 1.0
  40619.      (http://www.mysql.com/Downloads/Contrib/webboard-1.0.zip)
  40620.      EU-Industries Internet-Message-Board.
  40621.  
  40622.    * DBIx-TextIndex-0.02.tar.gz
  40623.      (http://www.mysql.com/Downloads/Contrib/DBIx-TextIndex-0.02.tar.gz)
  40624.      Full-text searching with Perl on `BLOB'/`TEXT' columns by Daniel
  40625.      Koch.
  40626.  
  40627. Performance Benchmarking Tools
  40628. ==============================
  40629.  
  40630.    * super-smack
  40631.      (http://www.mysql.com/Downloads/super-smack/super-smack-1.0.tar.gz)
  40632.      Multi-threaded benchmarking tool for MySQL and *PostgreSQL*.
  40633.      Written in C++. Easy to extend to support other databases that
  40634.      have C/C++ client libraries. By Sasha Pachev.
  40635.  
  40636. Authentication Tools
  40637. ====================
  40638.  
  40639.    * ascend-radius-mysql-0.7.2.patch.gz
  40640.      (http://www.mysql.com/Downloads/Contrib/ascend-radius-mysql-0.7.2.patch.gz)
  40641.      This is an authentication and logging patch using MySQL for
  40642.      Ascend-Radius. By <takeshi@SoftAgency.co.jp>.
  40643.  
  40644.    * icradius 0.10
  40645.      (http://www.mysql.com/Downloads/Contrib/icradius-0.10.tar.gz)
  40646.      icradius readme file
  40647.      (http://www.mysql.com/Downloads/Contrib/icradius.README).
  40648.  
  40649.    * checkpassword-0.81-mysql-0.6.6.patch.gz
  40650.      (http://www.mysql.com/Downloads/Contrib/checkpassword-0.81-mysql-0.6.6.patch.gz)
  40651.      MySQL authentication patch for QMAIL and checkpassword. These are
  40652.      useful for management user (mail, pop account) by MySQL.  By
  40653.      <takeshi@SoftAgency.co.jp>.
  40654.  
  40655.    * jradius-diff.gz
  40656.      (http://www.mysql.com/Downloads/Contrib/jradius-diff.gz) MySQL
  40657.      support for Livingston's Radius 2.01. Authentication and
  40658.      Accounting. By Jose de Leon, <jdl@thevision.net>.
  40659.  
  40660.    * mod_auth_mysql-2.20.tar.gz
  40661.      (http://www.mysql.com/Downloads/Contrib/mod_auth_mysql-2.20.tar.gz)
  40662.      Apache authentication module for MySQL. By Zeev Suraski,
  40663.      <bourbon@netvision.net.il>.
  40664.  
  40665.    * mod_log_mysql-1.05.tar.gz
  40666.      (http://www.mysql.com/Downloads/Contrib/mod_log_mysql-1.05.tar.gz)
  40667.      MySQL logging module for Apache. By Zeev Suraski,
  40668.      <bourbon@netvision.net.il>.
  40669.  
  40670.    * mypasswd-2.0.tar.gz
  40671.      (http://www.mysql.com/Downloads/Contrib/mypasswd-2.0.tar.gz) Extra
  40672.      for `mod_auth_mysql'. This is a little tool that allows you to
  40673.      add/change user records storing group and/or password entries in
  40674.      MySQL tables. By Harry Brueckner, <brueckner@respublica.de>.
  40675.  
  40676.    * mysql-passwd.README
  40677.      (http://www.mysql.com/Downloads/Contrib/mysql-passwd.README).
  40678.  
  40679.    * mysql-passwd-1.2.tar.gz
  40680.      (http://www.mysql.com/Downloads/Contrib/mysql-passwd-1.2.tar.gz)
  40681.      Extra for `mod_auth_mysql'. This is a two-part system for use with
  40682.      `mod_auth_mysql'.
  40683.  
  40684.    * pam_mysql.tar.gz
  40685.      (http://www.mysql.com/Downloads/Contrib/pam_mysql.tar.gz) This
  40686.      module authenticates users via `pam', using MySQL.
  40687.  
  40688.    * nsapi_auth_mysql.tar
  40689.      (http://www.mysql.com/Downloads/Contrib/nsapi_auth_mysql.tar)
  40690.      Netscape Web Server API (NSAPI) functions to authenticate (BASIC)
  40691.      users against MySQL tables. By Yuan John Jiang.
  40692.  
  40693.    * qmail-1.03-mysql-0.6.6.patch.gz
  40694.      (http://www.mysql.com/Downloads/Contrib/qmail-1.03-mysql-0.6.6.patch.gz)
  40695.      Patch for qmail to authenticate users from a MySQL table.  By
  40696.      <takeshi@SoftAgency.co.jp>.
  40697.  
  40698.    * proftpd-1.2.0rc2-fix-mysql.patch
  40699.      (http://www.mysql.com/Downloads/Contrib/proftpd-1.2.0rc2-fix-mysql.patch)
  40700.      Patch for proftpd1.2.0rc2. By <takeshi@SoftAgency.co.jp>.
  40701.  
  40702.    * pwcheck_mysql-0.1.tar.gz
  40703.      (http://www.mysql.com/Downloads/Contrib/pwcheck_mysql-0.1.tar.gz)
  40704.      An authentication module for the Cyrus IMAP server. By Aaron
  40705.      Newsome.
  40706.  
  40707.  
  40708. Converters
  40709. ==========
  40710.  
  40711.    * mssql2mysql.txt
  40712.      (http://www.mysql.com/Downloads/Contrib/mssql2mysql.txt) Converter
  40713.      from MS-SQL to MySQL. By Michael Kofler.  mssql2mysql home page
  40714.      (http://www.kofler.cc/mysql/mssql2mysql.html).
  40715.  
  40716.    * dbf2mysql-1.14.tar.gz
  40717.      (http://www.mysql.com/Downloads/Contrib/dbf2mysql-1.14.tar.gz)
  40718.      Convert between `.dbf' files and MySQL tables. By Maarten Boekhold
  40719.      (<boekhold@cindy.et.tudelft.nl>), William Volkman, and Michael
  40720.      Widenius.  This converter includes rudimentary read-only support
  40721.      for MEMO fields.
  40722.  
  40723.    * dbf2mysql-1.13.tgz
  40724.      (http://www.mysql.com/Downloads/Contrib/dbf2mysql-1.13.tgz)
  40725.      Convert between `.dbf' files and MySQL tables. By Maarten
  40726.      Boekhold, <boekhold@cindy.et.tudelft.nl>, and Michael Widenius.
  40727.      This converter can't handle MEMO fields.
  40728.  
  40729.    * dbf2mysql.zip
  40730.      (http://www.mysql.com/Downloads/Contrib/dbf2mysql.zip) Convert
  40731.      between FoxPro `.dbf' files and MySQL tables on Windows.  By
  40732.      Alexander Eltsyn, <ae@nica.ru> or <ae@usa.net>.
  40733.  
  40734.    * dbf2sql.zip (http://www.mysql.com/Downloads/Contrib/dbf2sql.zip)
  40735.      Short and simple prg that can help you transport your data from
  40736.      foxpro table into MySQL table. By Danko Josic.
  40737.  
  40738.    * dump2h-1.20.gz
  40739.      (http://www.mysql.com/Downloads/Contrib/dump2h-1.20.gz) Convert
  40740.      from `mysqldump' output to a C header file. By Harry Brueckner,
  40741.      <brueckner@mail.respublica.de>.
  40742.  
  40743.    * exportsql.txt
  40744.      (http://www.mysql.com/Downloads/Contrib/exportsql.txt) A script
  40745.      that is similar to `access_to_mysql.txt', except that this one is
  40746.      fully configurable, has better type conversion (including
  40747.      detection of `TIMESTAMP' fields), provides warnings and suggestions
  40748.      while converting, quotes *all* special characters in text and
  40749.      binary data, and so on.  It will also convert to `mSQL' v1 and v2,
  40750.      and is free of charge for anyone. See
  40751.      `http://www.cynergi.net/exportsql/' for the latest version. By
  40752.      Pedro Freire, <support@cynergi.net>.  NOTE: Doesn't work with
  40753.      Access2!
  40754.  
  40755.    * access_to_mysql.txt
  40756.      (http://www.mysql.com/Downloads/Contrib/access_to_mysql.txt) Paste
  40757.      this function into an Access module of a database that has the
  40758.      tables you want to export. See also `exportsql'. By Brian Andrews.
  40759.      NOTE: Doesn't work with Access2!
  40760.  
  40761.    * importsql.txt
  40762.      (http://www.mysql.com/Downloads/Contrib/importsql.txt) A script
  40763.      that does the exact reverse of `exportsql.txt'.  That is, it
  40764.      imports data from MySQL into an Access database via ODBC. This is
  40765.      very handy when combined with exportsql, because it lets you use
  40766.      Access for all DB design and administration, and synchronize with
  40767.      your actual MySQL server either way. Free of charge. See
  40768.      `http://www.netdive.com/freebies/importsql/' for any updates.
  40769.      Created by Laurent Bossavit of NetDIVE.  *NOTE:* Doesn't work with
  40770.      Access2!
  40771.  
  40772.    * mdb2sql.bas (http://www.mysql.com/Downloads/Contrib/mdb2sql.bas)
  40773.      Converter from Access97 to MySQL by Moshe Gurvich.
  40774.  
  40775.    * msql2mysqlWrapper 1.0
  40776.      (http://www.mysql.com/Downloads/Contrib/msql2mysqlWrapper-1.0.tgz)
  40777.      A C wrapper from `mSQL' to MySQL. By <alfred@sb.net>
  40778.  
  40779.    * sqlconv.pl (http://www.mysql.com/Downloads/Contrib/sqlconv.pl) A
  40780.      simple script that can be used to copy fields from one MySQL table
  40781.      to another in bulk. Basically, you can run `mysqldump' and pipe it
  40782.      to the `sqlconv.pl' script. The script will parse through the
  40783.      `mysqldump' output and will rearrange the fields so they can be
  40784.      inserted into a new table. An example is when you want to create a
  40785.      new table for a different site you are working on, but the table
  40786.      is just a bit different (that is - fields in different order,
  40787.      etc.).  By Steve Shreeve.
  40788.  
  40789.    * oracledump (http://www.mysql.com/Downloads/Contrib/oracledump)
  40790.      Perl program to convert Oracle databases to MySQL. Has same output
  40791.      format as mysqldump. By Johan Andersson.
  40792.  
  40793.    * excel2mysql.pl
  40794.      (http://www.mysql.com/Downloads/Contrib/excel2mysql.pl) Perl
  40795.      program to import Excel spreadsheets into a MySQL database. By
  40796.      Stephen Hurd <shurd@sk.sympatico.ca>
  40797.  
  40798.    * T2S_100.ZIP (http://www.mysql.com/Downloads/Contrib/T2S_100.ZIP).
  40799.      Windows program to convert text files to MySQL databases. By Asaf
  40800.      Azulay.
  40801.  
  40802.  
  40803. Using MySQL with Other Products
  40804. ===============================
  40805.  
  40806.    * emacs-sql-mode.tar.gz
  40807.      (http://www.mysql.com/Downloads/Contrib/emacs-sql-mode.tar.gz) Raw
  40808.      port of a SQL mode for XEmacs. Supports completion. Original by
  40809.      Peter D. Pezaris <pez@atlantic2.sbi.com> and partial MySQL port by
  40810.      David Axmark.
  40811.  
  40812.    * MyAccess97 1.4
  40813.      (http://www.mysql.com/Downloads/Win32/myaccess97_1_4.zip).
  40814.  
  40815.    * MyAccess2000 1.4
  40816.      (http://www.mysql.com/Downloads/Win32/myaccess2000_1_4.zip).
  40817.  
  40818.      MyAccess is an AddIn for MS Access 97/2000 that allows you to
  40819.      manage MySQL databases from within Access. Main functions are:
  40820.         - Create/Modify Tables
  40821.  
  40822.         - Execute Queries against MySQL
  40823.  
  40824.         - Extract "Create Table-Scripts" from MySQL
  40825.  
  40826.         - Import/Export tables from Access to MySQL and vice versa
  40827.  
  40828.         - Log Changes
  40829.  
  40830.         - Show a "Database Definition Report
  40831.  
  40832.      Written by Hubertus Hiden. MyAccess homepage
  40833.      (http://www.accessmysql.com).
  40834.  
  40835.    * radius-0.3.tar.gz
  40836.      (http://www.mysql.com/Downloads/Contrib/radius-0.3.tar.gz) Patches
  40837.      for `radiusd' to make it support MySQL. By Wim Bonis,
  40838.      <bonis@kiss.de>.
  40839.  
  40840. Useful Tools
  40841. ============
  40842.  
  40843.    * MySQL Backup
  40844.      (http://worldcommunity.com/opensource/utilities/mysql_backup.html).
  40845.  
  40846.      A backup script for MySQL. By Peter F. Brown.
  40847.  
  40848.    * mytop (http://www.mysql.com/Downloads/Contrib/mytop)
  40849.  
  40850.    * mytop home page (http://public.yahoo.com/~jzawodn/mytop/) mytop is
  40851.      a Perl program that allows you to monitor MySQL servers by viewing
  40852.      active threads, queries, and overall server performance numbers.
  40853.      By Jeremy D. Zawodny.
  40854.  
  40855.    * mysql_watchdog.pl
  40856.      (http://www.mysql.com/Downloads/Contrib/mysql_watchdog.pl) Monitor
  40857.      the MySQL daemon for possible lockups. By Yermo Lamers,
  40858.      <yml@yml.com>.
  40859.  
  40860.    * mysqltop.tar.gz
  40861.      (http://www.mysql.com/Downloads/Contrib/mysqltop.tar.gz) Sends a
  40862.      query in a fixed time interval to the server and shows the
  40863.      resulting table. By Thomas Wana.
  40864.  
  40865.    * mysql_structure_dumper.tar.gz
  40866.      (http://www.mysql.com/Downloads/Contrib/mysql_structure_dumper.tar.gz)
  40867.      Prints out the structure of the all tables in a database. By
  40868.      Thomas Wana.
  40869.  
  40870.    * structure_dumper.tgz
  40871.      (http://www.mysql.com/Downloads/Contrib/mysql_structure_dumper.tgz)
  40872.      Prints the structure of every table in a database. By Thomas Wana.
  40873.  
  40874.    * mysqlsync-1.0-alpha.tar.gz
  40875.      (http://www.mysql.com/Downloads/Contrib/mysqlsync).  A Perl script
  40876.      to keep remote copies of a MySQL database in sync with a central
  40877.      master copy. By Mark Jeftovic.  <markjr@easydns.com>.
  40878.  
  40879.    * MySQLTutor
  40880.      (http://www.mysql.com/Downloads/Contrib/MySQLTutor-0.2.tar.gz).
  40881.      MySQLTutor. A MySQL tutorial for beginners.
  40882.  
  40883.    * MySQLDB.zip (http://www.mysql.com/Downloads/Contrib/MySQLDB.zip) A
  40884.      COM library for MySQL by Alok Singh.
  40885.  
  40886.    * MySQLDB-readme.html
  40887.      (http://www.mysql.com/Downloads/Contrib/MySQLDB-readme.html).
  40888.  
  40889.    * mysql_replicate.pl
  40890.      (http://www.mysql.com/Downloads/Contrib/mysql_replicate.pl) Perl
  40891.      program that handles replication.  By <elble@icculus.nsg.nwu.edu>
  40892.  
  40893.    * DBIx-TextIndex-0.02.tar.gz
  40894.      (http://www.mysql.com/Downloads/Contrib/DBIx-TextIndex-0.02.tar.gz)
  40895.      Perl script that uses reverse indexing to handle text searching.
  40896.      By Daniel Koch.
  40897.  
  40898.    * dbcheck (http://www.mysql.com/Downloads/Contrib/dbcheck) Perl
  40899.      script that takes a backup of tables before running isamchk on
  40900.      them.  By Elizabeth.
  40901.  
  40902.    * `http://www.mysql.com/Downloads/Contrib/mybackup'.
  40903.  
  40904.    * mybackup home page (http://www.mswanson.com/mybackup) Wrapper for
  40905.      mysqldump to backup all databases. By Marc Swanson.
  40906.  
  40907.    * mdu.pl.gz (http://www.mysql.com/Downloads/Contrib/mdu.pl.gz)
  40908.      Prints the storage usage of a MySQL database.
  40909.  
  40910. RPMs for Common Tools (Most Are for RedHat 6.1)
  40911. ===============================================
  40912.  
  40913.    * perl-Data-ShowTable-3.3-2.i386.rpm
  40914.      (http://www.mysql.com/Downloads/Contrib/perl-Data-ShowTable-3.3-2.i386.rpm)
  40915.  
  40916.    * perl-Msql-Mysql-modules-1.2210-2.i386.rpm
  40917.      (http://www.mysql.com/Downloads/Contrib/perl-Msql-Mysql-modules-1.2210-2.i386.rpm)
  40918.  
  40919.    * php-pg-3.0.13-1.i386.rpm
  40920.      (http://www.mysql.com/Downloads/Contrib/php-pg-3.0.13-1.i386.rpm)
  40921.  
  40922.    * php-pg-manual-3.0.13-1.i386.rpm
  40923.      (http://www.mysql.com/Downloads/Contrib/php-pg-manual-3.0.13-1.i386.rpm)
  40924.  
  40925.    * php-pg-mysql-3.0.13-1.i386.rpm
  40926.      (http://www.mysql.com/Downloads/Contrib/php-pg-mysql-3.0.13-1.i386.rpm)
  40927.  
  40928.    * phpMyAdmin-2.0.5-1.noarch.rpm
  40929.      (http://www.mysql.com/Downloads/Contrib/phpMyAdmin-2.0.5-1.noarch.rpm)
  40930.  
  40931. Useful Functions
  40932. ================
  40933.  
  40934.    * mysnprintf.c (http://www.mysql.com/Downloads/Contrib/mysnprintf.c)
  40935.      sprintf() function for SQL queries that can escape blobs. By
  40936.      Chunhua Liu.
  40937.  
  40938. Windows programs
  40939. ================
  40940.  
  40941.    * LaunchMySQL.zip
  40942.      (http://www.mysql.com/Downloads/Contrib/LaunchMySQL.zip) The
  40943.      program launches the MySQL server, shuts it down, and display
  40944.      status information. By Bill Thompson
  40945.  
  40946. Uncategorized
  40947. =============
  40948.  
  40949.    * findres.pl (http://www.mysql.com/Downloads/Contrib/findres.pl)
  40950.      Find reserved words in tables. By Nem W Schlecht.
  40951.  
  40952.    * handicap.tar.gz
  40953.      (http://www.mysql.com/Downloads/Contrib/handicap.tar.gz)
  40954.      Performance handicapping system for yachts. Uses PHP. By
  40955.      <rhill@stobyn.ml.org>.
  40956.  
  40957.    * hylalog-1.0.tar.gz
  40958.      (http://www.mysql.com/Downloads/Contrib/hylalog-1.0.tar.gz) Store
  40959.      `hylafax' outgoing faxes in a MySQL database. By Sinisa
  40960.      Milivojevic, <sinisa@mysql.com>.
  40961.  
  40962.    * mrtg-mysql-1.0.tar.gz
  40963.      (http://www.mysql.com/Downloads/Contrib/mrtg-mysql-1.0.tar.gz)
  40964.      MySQL status plotting with MRTG, by Luuk de Boer, <luuk@wxs.nl>.
  40965.  
  40966.    * wuftpd-2.4.2.18-mysql_support.2.tar.gz
  40967.      (http://www.mysql.com/Downloads/Contrib/wuftpd-2.4.2.18-mysql_support.2.tar.gz)
  40968.      Patches to add logging to MySQL for WU-ftpd. By Zeev Suraski,
  40969.      <bourbon@netvision.net.il>.
  40970.  
  40971.    * wu-ftpd-2.6.0-mysql.4.tar.gz
  40972.      (http://www.mysql.com/Downloads/Contrib/wu-ftpd-2.6.0-mysql.4.tar.gz)
  40973.      Patches to add logging to MySQL for WU-ftpd 2.6.0. By
  40974.      <takeshi@SoftAgency.co.jp>, based on Zeev Suraski wuftpd patches.
  40975.  
  40976.    * Old-Versions (http://www.mysql.com/Downloads/Contrib/Old-Versions)
  40977.      Previous versions of things found here that you probably won't be
  40978.      interested in.
  40979.  
  40980. 
  40981. File: mysql.info,  Node: Credits,  Next: News,  Prev: Contrib,  Up: Top
  40982.  
  40983. Credits
  40984. *******
  40985.  
  40986. This appendix lists the developers, contributors, and supporters that
  40987. have helped to make MySQL what it is today.
  40988.  
  40989. * Menu:
  40990.  
  40991. * Developers::                  Developers at MySQL AB
  40992. * Contributors::                Contributors to MySQL
  40993. * Supporters::                  Supporters to MySQL
  40994.  
  40995. 
  40996. File: mysql.info,  Node: Developers,  Next: Contributors,  Prev: Credits,  Up: Credits
  40997.  
  40998. Developers at MySQL AB
  40999. ======================
  41000.  
  41001. These are the developers that are or have been employed by MySQL AB to
  41002. work on MySQL, roughly in the order they started to work with us.
  41003. Following each developer is a small list of the tasks that the
  41004. developer is responsible for, or the accomplishments they have made.
  41005.  
  41006. Michael (Monty) Widenius
  41007.      Has written the following parts of MySQL:
  41008.         * All the main code in `mysqld'.
  41009.  
  41010.         * New functions for the string library.
  41011.  
  41012.         * Most of the `mysys' library.
  41013.  
  41014.         * The `ISAM' and `MyISAM' libraries (B-tree index file handlers
  41015.           with index compression and different record formats).
  41016.  
  41017.         * The `HEAP' library. A memory table system with our superior
  41018.           full dynamic hashing. In use since 1981 and published around
  41019.           1984.
  41020.  
  41021.         * The `replace' program (look into it, it's COOL!).
  41022.  
  41023.         * *MyODBC*, the ODBC driver for Windows95.
  41024.  
  41025.         * Fixing bugs in MIT-pthreads to get it to work for MySQL. And
  41026.           also Unireg, a curses-based application tool with many
  41027.           utilities.
  41028.  
  41029.         * Porting of `mSQL' tools like `msqlperl', `DBD'/`DBI', and
  41030.           `DB2mysql'.
  41031.  
  41032.         * Most of crash-me and the foundation for the MySQL benchmarks.
  41033.  
  41034. David Axmark
  41035.         * Coordinator and initial main writer of the *Reference Manual*,
  41036.           including enhancements to `texi2html'.
  41037.  
  41038.         * Automatic Web site updating from the manual.
  41039.  
  41040.         * Initial Autoconf, Automake, and Libtool support.
  41041.  
  41042.         * The licensing stuff.
  41043.  
  41044.         * Parts of all the text files.  (Nowadays only the `README' is
  41045.           left. The rest ended up in the manual.)
  41046.  
  41047.         * Lots of testing of new features.
  41048.  
  41049.         * Our in-house "free" software lawyer.
  41050.  
  41051.         * Mailing list maintainer (who never has the time to do it
  41052.           right...)
  41053.  
  41054.         * Our original portability code (more than 10 years old now).
  41055.           Nowadays only some parts of `mysys' are left.
  41056.  
  41057.         * Someone for Monty to call in the middle of the night when he
  41058.           just got that new feature to work.
  41059.  
  41060. Jani Tolonen
  41061.         * `mysqlimport'
  41062.  
  41063.         * A lot of extensions to the `mysql' client.
  41064.  
  41065.         * `procedure analyse()'
  41066.  
  41067. Sinisa Milivojevic
  41068.         * Compression (with `zlib') in the client/server protocol.
  41069.  
  41070.         * Perfect hashing for the lexical analyzer phase.
  41071.  
  41072.         * The MySQLGUI client.
  41073.  
  41074.         * Maintainer of mysql++.
  41075.  
  41076. Tonu Samuel
  41077.         * Our security expert.
  41078.  
  41079.         * Vio interface (The foundation for the encrypted client/server
  41080.           protocol).
  41081.  
  41082.         * MySQL Filesystem (A way to use MySQL databases as files and
  41083.           directories).
  41084.  
  41085.         * The CASE Expression.
  41086.  
  41087.         * The MD5() and COALESCE() functions.
  41088.  
  41089.         * `RAID' support for `MyISAM' tables.
  41090.  
  41091. Sasha Pachev
  41092.         * Replication.
  41093.  
  41094.         * `SHOW CREATE TABLE'.
  41095.  
  41096.         * mod_mysql_include
  41097.  
  41098.         * cgi++
  41099.  
  41100.         * mysql-bench
  41101.  
  41102. Matt Wagner
  41103.         * MySQL test suite.
  41104.  
  41105.         * Our webmaster.
  41106.  
  41107. Miguel Solorzano
  41108.         * Winmysqladmin.
  41109.  
  41110. Timothy Smith
  41111.         * Dynamic character support.
  41112.  
  41113.         * Responsible for MySQL configure.
  41114.  
  41115. Sergei Golubchik
  41116.         * Full-text search.
  41117.  
  41118.         * Added keys to the `MERGE' library.
  41119.  
  41120. Jeremy Cole
  41121.         * Proofreading and editing this fine manual.
  41122.  
  41123.         * `ALTER TABLE ... ORDER BY ...'.
  41124.  
  41125.         * `UPDATE ... ORDER BY ...'.
  41126.  
  41127.         * `DELETE ... ORDER BY ...'.
  41128.  
  41129. John Dean
  41130.         * The new MySQL GUI client.
  41131.  
  41132. Indrek Siitan
  41133.         * Designer/programmer of our web interface.
  41134.  
  41135. The following non-developers are also working in/with MySQL AB:
  41136.  
  41137.  
  41138.      Hans Kierkegaard - Responsible for MySQL license handling.
  41139.  
  41140.  
  41141.      Antti Halonen - Sales manager.
  41142.  
  41143.  
  41144.      Jonas Norrman - Handles licensing questions sent to
  41145.      <info@mysql.com>.
  41146.  
  41147.  
  41148.      Erik Granberg - Handles MySQL partners (and a lot of other stuff).
  41149.  
  41150.  
  41151.      Allan Larsson (The BOSS for TCX DataKonsult AB).
  41152.  
  41153. 
  41154. File: mysql.info,  Node: Contributors,  Next: Supporters,  Prev: Developers,  Up: Credits
  41155.  
  41156. Contributors to MySQL
  41157. =====================
  41158.  
  41159. Contributors to the MySQL distribution are listed here, in somewhat
  41160. random order:
  41161.  
  41162. Paul DuBois
  41163.      Help with making the Reference Manual correct and understandable.
  41164.      That includes rewriting Monty's and David's attempts at English
  41165.      into English as other people know it.
  41166.  
  41167. Gianmassimo Vigazzola <qwerg@mbox.vol.it> or <qwerg@tin.it>
  41168.      The initial port to Win32/NT.
  41169.  
  41170. Kim Aldale
  41171.      Helped to rewrite Monty's and David's early attempts at English
  41172.      into English.
  41173.  
  41174. Per Eric Olsson
  41175.      For more or less constructive criticism and real testing of the
  41176.      dynamic record format.
  41177.  
  41178. Irena Pancirov <irena@mail.yacc.it>
  41179.      Win32 port with Borland compiler.  `mysqlshutdown.exe' and
  41180.      `mysqlwatch.exe'
  41181.  
  41182. David J. Hughes
  41183.      For the effort to make a shareware SQL database. We at TcX started
  41184.      with `mSQL', but found that it couldn't satisfy our purposes so
  41185.      instead we wrote a SQL interface to our application builder
  41186.      Unireg.  `mysqladmin' and `mysql' are programs that were largely
  41187.      influenced by their `mSQL' counterparts. We have put a lot of
  41188.      effort into making the MySQL syntax a superset of `mSQL'. Many of
  41189.      the API's ideas are borrowed from `mSQL' to make it easy to port
  41190.      free `mSQL' programs to MySQL. MySQL doesn't contain any code from
  41191.      `mSQL'.  Two files in the distribution (`client/insert_test.c' and
  41192.      `client/select_test.c') are based on the corresponding
  41193.      (non-copyrighted) files in the `mSQL' distribution, but are
  41194.      modified as examples showing the changes necessary to convert code
  41195.      from `mSQL' to MySQL.  (`mSQL' is copyrighted David J. Hughes.)
  41196.  
  41197. Fred Fish
  41198.      For his excellent C debugging and trace library. Monty has made a
  41199.      number of smaller improvements to the library (speed and
  41200.      additional options).
  41201.  
  41202. Richard A. O'Keefe
  41203.      For his public domain string library.
  41204.  
  41205. Henry Spencer
  41206.      For his regex library, used in `WHERE column REGEXP regexp'.
  41207.  
  41208. Free Software Foundation
  41209.      From whom we got an excellent compiler (`gcc'), the `libc' library
  41210.      (from which we have borrowed `strto.c' to get some code working in
  41211.      Linux), and the `readline' library (for the `mysql' client).
  41212.  
  41213. Free Software Foundation & The XEmacs development team
  41214.      For a really great editor/environment used by almost everybody at
  41215.      TcX/MySQL AB/detron.
  41216.  
  41217. Patrick Lynch
  41218.      For helping us acquire `http://www.mysql.com/'.
  41219.  
  41220. Fred Lindberg
  41221.      For setting up qmail to handle the MySQL mailing list and for the
  41222.      incredible help we got in managing the MySQL mailing lists.
  41223.  
  41224. Igor Romanenko <igor@frog.kiev.ua>
  41225.      `mysqldump' (previously `msqldump', but ported and enhanced by
  41226.      Monty).
  41227.  
  41228. Yuri Dario
  41229.      For keeping up and extending the MySQL OS/2 port.
  41230.  
  41231. Tim Bunce, Alligator Descartes
  41232.      For the `DBD' (Perl) interface.
  41233.  
  41234. Tim Bunce
  41235.      Author of `mysqlhotcopy'.
  41236.  
  41237. Andreas Koenig <a.koenig@mind.de>
  41238.      For the Perl interface to MySQL.
  41239.  
  41240. Eugene Chan <eugene@acenet.com.sg>
  41241.      For porting PHP to MySQL.
  41242.  
  41243. Michael J. Miller Jr. <mke@terrapin.turbolift.com>
  41244.      For the first MySQL manual. And a lot of spelling/language fixes
  41245.      for the FAQ (that turned into the MySQL manual a long time ago).
  41246.  
  41247. Yan Cailin
  41248.      First translator of the MySQL Reference Manual into simplified
  41249.      chinese in early 2000 on which the Big5 and HK coded
  41250.      (mysql.hitstar.com (http://mysql.hitstar.com)) versions were
  41251.      based. Personal home page at linuxdb.yeah.net
  41252.      (http://linuxdb.yeah.net).
  41253.  
  41254. Giovanni Maruzzelli <maruzz@matrice.it>
  41255.      For porting iODBC (Unix ODBC).
  41256.  
  41257. Chris Provenzano
  41258.      Portable user level pthreads. From the copyright: This product
  41259.      includes software developed by Chris Provenzano, the University of
  41260.      California, Berkeley, and contributors.  We are currently using
  41261.      version 1_60_beta6 patched by Monty (see
  41262.      `mit-pthreads/Changes-mysql').
  41263.  
  41264. Xavier Leroy <Xavier.Leroy@inria.fr>
  41265.      The author of LinuxThreads (used by MySQL on Linux).
  41266.  
  41267. Zarko Mocnik <zarko.mocnik@dem.si>
  41268.      Sorting for Slovenian language and the `cset.tar.gz' module that
  41269.      makes it easier to add other character sets.
  41270.  
  41271. "TAMITO" <tommy@valley.ne.jp>
  41272.      The `_MB' character set macros and the ujis and sjis character
  41273.      sets.
  41274.  
  41275. Joshua Chamas <joshua@chamas.com>
  41276.      Base for concurrent insert, extended date syntax, debugging on NT,
  41277.      and answering on the MySQL mailing list.
  41278.  
  41279. Yves Carlier <Yves.Carlier@rug.ac.be>
  41280.      `mysqlaccess', a program to show the access rights for a user.
  41281.  
  41282. Rhys Jones <rhys@wales.com> (And GWE Technologies Limited)
  41283.      For the JDBC, a module to extract data from MySQL with a Java
  41284.      client.
  41285.  
  41286. Dr Xiaokun Kelvin ZHU <X.Zhu@brad.ac.uk>
  41287.      Further development of the JDBC driver and other MySQL-related
  41288.      Java tools.
  41289.  
  41290. James Cooper <pixel@organic.com>
  41291.      For setting up a searchable mailing list archive at his site.
  41292.  
  41293. Rick Mehalick <Rick_Mehalick@i-o.com>
  41294.      For `xmysql', a graphical X client for MySQL.
  41295.  
  41296. Doug Sisk <sisk@wix.com>
  41297.      For providing RPM packages of MySQL for RedHat Linux.
  41298.  
  41299. Diemand Alexander V. <axeld@vial.ethz.ch>
  41300.      For providing RPM packages of MySQL for RedHat Linux-Alpha.
  41301.  
  41302. Antoni Pamies Olive <toni@readysoft.es>
  41303.      For providing RPM versions of a lot of MySQL clients for Intel and
  41304.      SPARC.
  41305.  
  41306. Jay Bloodworth <jay@pathways.sde.state.sc.us>
  41307.      For providing RPM versions for MySQL Version 3.21.
  41308.  
  41309. Jochen Wiedmann <wiedmann@neckar-alb.de>
  41310.      For maintaining the Perl `DBD::mysql' module.
  41311.  
  41312. Therrien Gilbert <gilbert@ican.net>, Jean-Marc Pouyot <jmp@scalaire.fr>
  41313.      French error messages.
  41314.  
  41315. Petr snajdr, <snajdr@pvt.net>
  41316.      Czech error messages.
  41317.  
  41318. Jaroslaw Lewandowski <jotel@itnet.com.pl>
  41319.      Polish error messages.
  41320.  
  41321. Miguel Angel Fernandez Roiz
  41322.      Spanish error messages.
  41323.  
  41324. Roy-Magne Mo <rmo@www.hivolda.no>
  41325.      Norwegian error messages and testing of Version 3.21.#.
  41326.  
  41327. Timur I. Bakeyev <root@timur.tatarstan.ru>
  41328.      Russian error messages.
  41329.  
  41330. <brenno@dewinter.com> && Filippo Grassilli <phil@hyppo.com>
  41331.      Italian error messages.
  41332.  
  41333. Dirk Munzinger <dirk@trinity.saar.de>
  41334.      German error messages.
  41335.  
  41336. Billik Stefan <billik@sun.uniag.sk>
  41337.      Slovak error messages.
  41338.  
  41339. Stefan Saroiu <tzoompy@cs.washington.edu>
  41340.      Romanian error messages.
  41341.  
  41342. Peter Feher
  41343.      Hungarian error messages.
  41344.  
  41345. Roberto M. Serqueira
  41346.      Portugise error messages.
  41347.  
  41348. Carsten H. Pedersen
  41349.      Danish error messages
  41350.  
  41351. David Sacerdote <davids@secnet.com>
  41352.      Ideas for secure checking of DNS hostnames.
  41353.  
  41354. Wei-Jou Chen <jou@nematic.ieo.nctu.edu.tw>
  41355.      Some support for Chinese(BIG5) characters.
  41356.  
  41357. Wei He <hewei@mail.ied.ac.cn>
  41358.      A lot of functionality for the Chinese(GBK) character set.
  41359.  
  41360. Zeev Suraski <bourbon@netvision.net.il>
  41361.      `FROM_UNIXTIME()' time formatting, `ENCRYPT()' functions, and
  41362.      `bison' advisor.  Active mailing list member.
  41363.  
  41364. Luuk de Boer <luuk@wxs.nl>
  41365.      Ported (and extended) the benchmark suite to `DBI'/`DBD'. Have
  41366.      been of great help with `crash-me' and running benchmarks. Some new
  41367.      date functions. The mysql_setpermissions script.
  41368.  
  41369. Jay Flaherty <fty@mediapulse.com>
  41370.      Big parts of the Perl `DBI'/`DBD' section in the manual.
  41371.  
  41372. Paul Southworth <pauls@etext.org>, Ray Loyzaga <yar@cs.su.oz.au>
  41373.      Proof-reading of the Reference Manual.
  41374.  
  41375. Alexis Mikhailov <root@medinf.chuvashia.su>
  41376.      User-definable functions (UDFs); `CREATE FUNCTION' and `DROP
  41377.      FUNCTION'.
  41378.  
  41379. Andreas F. Bobak <bobak@relog.ch>
  41380.      The `AGGREGATE' extension to UDF functions.
  41381.  
  41382. Ross Wakelin <R.Wakelin@march.co.uk>
  41383.      Help to set up InstallShield for MySQL-Win32.
  41384.  
  41385. Jethro Wright III <jetman@li.net>
  41386.      The `libmysql.dll' library.
  41387.  
  41388. James Pereria <jpereira@iafrica.com>
  41389.      Mysqlmanager, a Win32 GUI tool for administrating MySQL.
  41390.  
  41391. Curt Sampson <cjs@portal.ca>
  41392.      Porting of MIT-pthreads to NetBSD/Alpha and NetBSD 1.3/i386.
  41393.  
  41394. Antony T. Curtis <antony.curtis@olcs.net>
  41395.      Porting of MySQL to OS/2.
  41396.  
  41397. Martin Ramsch <m.ramsch@computer.org>
  41398.      Examples in the MySQL Tutorial.
  41399.  
  41400. Steve Harvey
  41401.      For making `mysqlaccess' more secure.
  41402.  
  41403. Konark IA-64 Centre of Persistent Systems Private Limited
  41404.      `http://www.pspl.co.in/konark/'.  Help with the Win64 port of the
  41405.      MySQL server.
  41406.  
  41407. Albert Chin-A-Young.
  41408.      Configure updates for Tru64, large file support and better TCP
  41409.      wrappers support.
  41410.  
  41411. John Birrell
  41412.      Emulation of pthread_mutex() for OS/2.
  41413.  
  41414. Other contributors, bugfinders, and testers: James H. Thompson, Maurizio
  41415. Menghini, Wojciech Tryc, Luca Berra, Zarko Mocnik, Wim Bonis, Elmar
  41416. Haneke, <jehamby@lightside>, <psmith@BayNetworks.com>,
  41417. <duane@connect.com.au>, Ted Deppner <ted@psyber.com>, Mike Simons,
  41418. Jaakko Hyvatti.
  41419.  
  41420. And lots of bug report/patches from the folks on the mailing list.
  41421.  
  41422. A big tribute goes to those that help us answer questions on the
  41423. `mysql@lists.mysql.com' mailing list:
  41424.  
  41425. Daniel Koch <dkoch@amcity.com>
  41426.      Irix setup.
  41427.  
  41428. Luuk de Boer <luuk@wxs.nl>
  41429.      Benchmark questions.
  41430.  
  41431. Tim Sailer <tps@users.buoy.com>
  41432.      `DBD-mysql' questions.
  41433.  
  41434. Boyd Lynn Gerber <gerberb@zenez.com>
  41435.      SCO-related questions.
  41436.  
  41437. Richard Mehalick <RM186061@shellus.com>
  41438.      `xmysql'-related questions and basic installation questions.
  41439.  
  41440. Zeev Suraski <bourbon@netvision.net.il>
  41441.      Apache module configuration questions (log & auth), PHP-related
  41442.      questions, SQL syntax-related questions and other general
  41443.      questions.
  41444.  
  41445. Francesc Guasch <frankie@citel.upc.es>
  41446.      General questions.
  41447.  
  41448. Jonathan J Smith <jsmith@wtp.net>
  41449.      Questions pertaining to OS-specifics with Linux, SQL syntax, and
  41450.      other things that might need some work.
  41451.  
  41452. David Sklar <sklar@student.net>
  41453.      Using MySQL from PHP and Perl.
  41454.  
  41455. Alistair MacDonald <A.MacDonald@uel.ac.uk>
  41456.      Not yet specified, but is flexible and can handle Linux and maybe
  41457.      HP-UX.  Will try to get user to use `mysqlbug'.
  41458.  
  41459. John Lyon <jlyon@imag.net>
  41460.      Questions about installing MySQL on Linux systems, using either
  41461.      `.rpm' files or compiling from source.
  41462.  
  41463. Lorvid Ltd. <lorvid@WOLFENET.com>
  41464.      Simple billing/license/support/copyright issues.
  41465.  
  41466. Patrick Sherrill <patrick@coconet.com>
  41467.      ODBC and VisualC++ interface questions.
  41468.  
  41469. Randy Harmon <rjharmon@uptimecomputers.com>
  41470.      `DBD', Linux, some SQL syntax questions.
  41471.  
  41472. 
  41473. File: mysql.info,  Node: Supporters,  Prev: Contributors,  Up: Credits
  41474.  
  41475. Supporters to MySQL
  41476. ===================
  41477.  
  41478. The following companies has helped us finance development of MySQL by
  41479. either paying us for developing a new feature, developed a MySQL
  41480. feature themselves or by giving us hardware for MySQL development.
  41481.  
  41482. VA Linux / Andover.net
  41483.      Funded replication.
  41484.  
  41485. NuSphere
  41486.      Editing of the MySQL manual.
  41487.  
  41488. Stork Design studio
  41489.      The MySQL web site in use between 1998-2000.
  41490.  
  41491. Intel
  41492.      Contributed to development on Windows and Linux platforms.
  41493.  
  41494. Compaq
  41495.      Contributed to Development on Linux/Alpha.
  41496.  
  41497. SWSoft
  41498.      Development on the embedded `mysqld' version.
  41499.  
  41500. FutureQuest
  41501.      `--skip-show-variables'
  41502.  
  41503. 
  41504. File: mysql.info,  Node: News,  Next: Porting,  Prev: Credits,  Up: Top
  41505.  
  41506. MySQL change history
  41507. ********************
  41508.  
  41509. This appendix lists the changes from version to version in the MySQL
  41510. source code.
  41511.  
  41512. Note that we tend to update the manual at the same time we make changes
  41513. to MySQL.  If you find a version listed below that you can't find on the
  41514. MySQL download page (http://www.mysql.com/downloads/), this means that
  41515. the version has not yet been released!
  41516.  
  41517. * Menu:
  41518.  
  41519. * News-4.0.x::                  Changes in release 4.0.x (Development; Alpha)
  41520. * News-3.23.x::                 Changes in release 3.23.x (Stable)
  41521. * News-3.22.x::                 Changes in release 3.22.x (Older; Still supported)
  41522. * News-3.21.x::                 Changes in release 3.21.x
  41523. * News-3.20.x::                 Changes in release 3.20.x
  41524. * News-3.19.x::                 Changes in release 3.19.x
  41525.  
  41526. 
  41527. File: mysql.info,  Node: News-4.0.x,  Next: News-3.23.x,  Prev: News,  Up: News
  41528.  
  41529. Changes in release 4.0.x (Development; Alpha)
  41530. =============================================
  41531.  
  41532. We have now started to work on MySQL 4.0.  We will update this section
  41533. as we add new features, so that others can follow our development.
  41534.  
  41535. Our TODO section contains what we plan to have in 4.0. *Note TODO MySQL
  41536. 4.0::.
  41537.  
  41538. * Menu:
  41539.  
  41540. * News-4.0.0::                  Changes in release 4.0.0
  41541.  
  41542. 
  41543. File: mysql.info,  Node: News-4.0.0,  Prev: News-4.0.x,  Up: News-4.0.x
  41544.  
  41545. Changes in release 4.0.0
  41546. ------------------------
  41547.  
  41548.    * Multi-table `DELETE'.
  41549.  
  41550.    * Don't support old client protocols prior to MySQL 3.21 any more.
  41551.  
  41552.    * Don't include the old C API functions `mysql_drop_db',
  41553.      `mysql_create_db' and `mysql_connect', unless compiled with
  41554.      `USE_OLD_FUNCTIONS'.
  41555.  
  41556.    * Renamed `safe_mysqld' to `mysqld_safe'.
  41557.  
  41558.    * Allow `IN' as a synonym for `FROM' in `SHOW' commands.
  41559.  
  41560.    * `SHOW INDEXES' is now a synonym for `SHOW INDEX'.
  41561.  
  41562.    * Added support for symbolic links to `MyISAM' tables. Symlink
  41563.      handling is now enabled by default for Windows.
  41564.  
  41565.    * `LOAD DATA FROM MASTER' "auto-magically" sets up a slave.
  41566.  
  41567.    * A new `HANDLER' interface to `MyISAM' tables.
  41568.  
  41569.    * `COUNT(DISTINCT)' is about 30% faster.
  41570.  
  41571.    * `FULLTEXT' index creation now is much faster.
  41572.  
  41573.    * Searching on packed (`CHAR'/`VARCHAR') keys now is much faster.
  41574.  
  41575.    * Added `SQL_CALC_FOUND_ROWS' and `FOUND_ROWS()'. This makes it
  41576.      possible to know how many rows a query would have returned without
  41577.      a `LIMIT' clause.
  41578.  
  41579.    * Changed output format of `SHOW OPEN TABLES'.
  41580.  
  41581.    * Allow `SELECT expression LIMIT ...'.
  41582.  
  41583.    * Added `IDENTITY' as a synonym for `AUTO_INCREMENT' (like Sybase).
  41584.  
  41585.    * Added `ORDER BY' syntax to `UPDATE' and `DELETE'.
  41586.  
  41587.    * Optimized queries of type: `SELECT DISTINCT * from table_name
  41588.      ORDER by key_part1 LIMIT #'
  41589.  
  41590. 
  41591. File: mysql.info,  Node: News-3.23.x,  Next: News-3.22.x,  Prev: News-4.0.x,  Up: News
  41592.  
  41593. Changes in release 3.23.x  (Stable)
  41594. ===================================
  41595.  
  41596. The 3.23 release has several major features that are not present in
  41597. previous versions.  We have added three new table types:
  41598.  
  41599. *MyISAM*
  41600.      A new ISAM library which is tuned for SQL and supports large files.
  41601.  
  41602. *BerkeleyDB* or *BDB*
  41603.      Uses the Berkeley DB library from Sleepycat Software to implement
  41604.      transaction-safe tables.
  41605.  
  41606. *InnoDB*
  41607.      A transaction-safe table handler that supports row level locking,
  41608.      and many Oracle-like features.
  41609.  
  41610. Note that only MyISAM is available in the standard binary distribution.
  41611.  
  41612. The 3.23 release also includes support for database replication between
  41613. a master and many slaves, full-text indexing, and much more.
  41614.  
  41615. All new features are being developed in the 4.0 version.  Only bug
  41616. fixes and minor enhancements to existing features will be added to 3.23.
  41617.  
  41618. The replication code and BerkeleyDB code is still not as tested and as
  41619. the rest of the code, so we will probably need to do a couple of future
  41620. releases of 3.23 with small fixes for this part of the code. As long as
  41621. you don't use these features, you should be quite safe with MySQL 3.23!
  41622.  
  41623. Note that the above doesn't mean that replication or Berkeley DB don't
  41624. work; We have done a lot of testing of all code, including replication
  41625. and BDB without finding any problems.  It only means that not as many
  41626. users use this code as the rest of the code and because of this we are
  41627. not yet 100% confident in this code.
  41628.  
  41629. * Menu:
  41630.  
  41631. * News-3.23.52::                Changes in release 3.23.52
  41632. * News-3.23.51::                Changes in release 3.23.51
  41633. * News-3.23.50::                Changes in release 3.23.50
  41634. * News-3.23.49::                Changes in release 3.23.49
  41635. * News-3.23.48::                Changes in release 3.23.48
  41636. * News-3.23.47::                Changes in release 3.23.47
  41637. * News-3.23.46::                Changes in release 3.23.46
  41638. * News-3.23.45::                Changes in release 3.23.45
  41639. * News-3.23.44::                Changes in release 3.23.44
  41640. * News-3.23.43::                Changes in release 3.23.43
  41641. * News-3.23.42::                Changes in release 3.23.42
  41642. * News-3.23.41::                Changes in release 3.23.41
  41643. * News-3.23.40::                Changes in release 3.23.40
  41644. * News-3.23.39::                Changes in release 3.23.39
  41645. * News-3.23.38::                Changes in release 3.23.38
  41646. * News-3.23.37::                Changes in release 3.23.37
  41647. * News-3.23.36::                Changes in release 3.23.36
  41648. * News-3.23.35::                Changes in release 3.23.35
  41649. * News-3.23.34a::               Changes in release 3.23.34a
  41650. * News-3.23.34::                Changes in release 3.23.34
  41651. * News-3.23.33::                Changes in release 3.23.33
  41652. * News-3.23.32::                Changes in release 3.23.32
  41653. * News-3.23.31::                Changes in release 3.23.31
  41654. * News-3.23.30::                Changes in release 3.23.30
  41655. * News-3.23.29::                Changes in release 3.23.29
  41656. * News-3.23.28::                Changes in release 3.23.28
  41657. * News-3.23.27::                Changes in release 3.23.27
  41658. * News-3.23.26::                Changes in release 3.23.26
  41659. * News-3.23.25::                Changes in release 3.23.25
  41660. * News-3.23.24::                Changes in release 3.23.24
  41661. * News-3.23.23::                Changes in release 3.23.23
  41662. * News-3.23.22::                Changes in release 3.23.22
  41663. * News-3.23.21::                Changes in release 3.23.21
  41664. * News-3.23.20::                Changes in release 3.23.20
  41665. * News-3.23.19::                Changes in release 3.23.19
  41666. * News-3.23.18::                Changes in release 3.23.18
  41667. * News-3.23.17::                Changes in release 3.23.17
  41668. * News-3.23.16::                Changes in release 3.23.16
  41669. * News-3.23.15::                Changes in release 3.23.15
  41670. * News-3.23.14::                Changes in release 3.23.14
  41671. * News-3.23.13::                Changes in release 3.23.13
  41672. * News-3.23.12::                Changes in release 3.23.12
  41673. * News-3.23.11::                Changes in release 3.23.11
  41674. * News-3.23.10::                Changes in release 3.23.10
  41675. * News-3.23.9::                 Changes in release 3.23.9
  41676. * News-3.23.8::                 Changes in release 3.23.8
  41677. * News-3.23.7::                 Changes in release 3.23.7
  41678. * News-3.23.6::                 Changes in release 3.23.6
  41679. * News-3.23.5::                 Changes in release 3.23.5
  41680. * News-3.23.4::                 Changes in release 3.23.4
  41681. * News-3.23.3::                 Changes in release 3.23.3
  41682. * News-3.23.2::                 Changes in release 3.23.2
  41683. * News-3.23.1::                 Changes in release 3.23.1
  41684. * News-3.23.0::                 Changes in release 3.23.0
  41685.  
  41686. 
  41687. File: mysql.info,  Node: News-3.23.52,  Next: News-3.23.51,  Prev: News-3.23.x,  Up: News-3.23.x
  41688.  
  41689. Changes in release 3.23.52
  41690. --------------------------
  41691.  
  41692.    * Fixed problem with `UNSIGNED BIGINT' on AIX.
  41693.  
  41694.    * Fixed security bug when having an empty databasename in the
  41695.      `user.db' table.
  41696.  
  41697.    * Changed initialisation of `RND()' to make it less predicatable.
  41698.  
  41699.    * Fixed problem with `GROUP BY' on result with expression that
  41700.      created a `BLOB' field.
  41701.  
  41702.    * Fixed problem with privilege tables when downgrading from 4.0.2 to
  41703.      3.23.
  41704.  
  41705.    * Fixed thread bug in `SLAVE START', `SLAVE STOP' and automatic
  41706.      repair of MyISAM tables that could cause table cache to be
  41707.      corrupted.
  41708.  
  41709.    * Fixed possible thread related key-cache-corruption problem with
  41710.      `OPTIMIZE TABLE' and `REPAIR TABLE'.
  41711.  
  41712.    * Added name of 'administrator command' logs.
  41713.  
  41714.    * Fixed bug with creating an auto-increment value on second part of a
  41715.      `UNIQUE()' key where first part could contain NULL values.
  41716.  
  41717.    * Don't write slave-timeout reconnects to the error log.
  41718.  
  41719.    * Fixed bug with slave net read timeouting
  41720.  
  41721.    * Fixed a core-dump bug with `MERGE' tables and `MAX()' function.
  41722.  
  41723.    * Fixed bug in `ALTER TABLE' with BDB tables.
  41724.  
  41725.    * Fixed bug when logging `LOAD DATA INFILE' to binary log with no
  41726.      active database.
  41727.  
  41728.    * Fixed a bug in range optimiser (causing crashes).
  41729.  
  41730.    * Fixed possible problem in replication when doing `DROP DATABASE'
  41731.      on a database with InnoDB tables.
  41732.  
  41733.    * Fixed that `mysql_info()' returns 0 for 'Duplicates' when using
  41734.      `INSERT DELAYED IGNORE'.
  41735.  
  41736.    * Added `-DHAVE_BROKEN_REALPATH' to the Mac OS X (darwin) compile
  41737.      options in `configure.in' to fix a failure under high load.
  41738.  
  41739. 
  41740. File: mysql.info,  Node: News-3.23.51,  Next: News-3.23.50,  Prev: News-3.23.52,  Up: News-3.23.x
  41741.  
  41742. Changes in release 3.23.51
  41743. --------------------------
  41744.  
  41745.    * Cleaned up `NULL' handling for default values in `DESCRIBE
  41746.      table_name'.
  41747.  
  41748.    * Fixed `truncate()' to round up negative values to the nearest
  41749.      integer.
  41750.  
  41751.    * Remove end space from `enum' values. (This fixed a problem with
  41752.      `SHOW CREATE TABLE').
  41753.  
  41754.    * Fixed bug in `CONCAT_WS()' that cut the result.
  41755.  
  41756.    * Changed name of variables `Com_show_master_stat' to
  41757.      `Com_show_master_status' and `Com_show_slave_stat' to
  41758.      `Com_show_slave_status'.
  41759.  
  41760.    * Changed handling of `gethostbyname()' to make the client library
  41761.      threadsafe even if `gethostbyname_r' doesn't exists.
  41762.  
  41763.    * Fixed core-dump problem when giving a wrong password string to
  41764.      `GRANT'.
  41765.  
  41766.    * Fixed bug in `DROP DATABASE' with symlinked directory.
  41767.  
  41768.    * Fixed optimization problem with `DATETIME' and value outside
  41769.      `DATETIME' range.
  41770.  
  41771.    * Removed Sleepycat's BDB doc files from the source tree, as they're
  41772.      not needed (MySQL covers BDB in its own documentation).
  41773.  
  41774.    * Fixed mit-pthreads to compile with glibc 2.2 (needed for `make
  41775.      dist').
  41776.  
  41777.    * Fixed the `FLOAT(X+1,X)' is not converted to `FLOAT(X+2,X)'.
  41778.      (This also affected `DECIMAL', `DOUBLE' and `REAL' types)
  41779.  
  41780.    * Fixed the result from `IF()' is case in-sensitive if the 2 and
  41781.      third arguments are case sensitive.
  41782.  
  41783.    * Fixed core dump problem on OSF in `gethostbyname_r'.
  41784.  
  41785.    * Fixed that underflowed decimal fields is not zero filled.
  41786.  
  41787.    * If we get an overflow when inserting `'+11111'' for `decimal(5,0)
  41788.      unsigned' columns, we will just drop the sign.
  41789.  
  41790.    * Fixed optimization bug with
  41791.      `ISNULL(expression_which_cannot_be_null)' and
  41792.      `ISNULL(constant_expression)'.
  41793.  
  41794.    * Fixed host lookup bug in the glibc library that we used with the
  41795.      3.23.50 Linux-x86 binaries.
  41796.  
  41797. 
  41798. File: mysql.info,  Node: News-3.23.50,  Next: News-3.23.49,  Prev: News-3.23.51,  Up: News-3.23.x
  41799.  
  41800. Changes in release 3.23.50
  41801. --------------------------
  41802.  
  41803.    * Fixed problem with `crash-me' and gcc 3.0.4.
  41804.  
  41805.    * Fixed that `@@unknown_variable' doesn't hang server.
  41806.  
  41807.    * Added `@@VERSION' as a synonym for `VERSION()'.
  41808.  
  41809.    * `SHOW VARIABLES LIKE 'xxx'' is now case insensitive.
  41810.  
  41811.    * Fixed timeout for `GET_LOCK()' on HPUX with DCE threads.
  41812.  
  41813.    * Fixed memory allocation bug in the glibc library used to build
  41814.      Linux binaries, which caused mysqld to die in 'free()'.
  41815.  
  41816.    * Fixed `SIGINT' and `SIGQUIT' problems in `mysql'.
  41817.  
  41818.    * Fixed bug in character table converts when used with big ( > 64K)
  41819.      strings.
  41820.  
  41821.    * `InnoDB' now retains foreign key constraints through `ALTER TABLE'
  41822.      and `CREATE/DROP INDEX'.
  41823.  
  41824.    * `InnoDB' now allows foreign key constraints to be added through the
  41825.      `ALTER TABLE' syntax.
  41826.  
  41827.    * `InnoDB' tables can now be set to automatically grow in size
  41828.      (autoextend).
  41829.  
  41830.    * Fixed some buffer overflow problems when reading startup
  41831.      parameters.
  41832.  
  41833.    * Because of problems on shutdown we have now disabled named pipes on
  41834.      windows by default.  One can enable named pipes by starting mysqld
  41835.      with `--enable-named-pipe'.
  41836.  
  41837.    * Fixed bug when using `WHERE key_column = 'J' or key_column='j''.
  41838.  
  41839.    * Fixed core-dump bug when using `--log-bin' with `LOAD DATA INFILE'
  41840.      without an active database.
  41841.  
  41842.    * Fixed bug in `RENAME TABLE' when used with
  41843.      `lower_case_table_names=1' (default on Windows).
  41844.  
  41845.    * Fixed unlikely core-dump bug when using `DROP TABLE' on a table
  41846.      that was in use by a thread that also used queries on only
  41847.      temporary tables.
  41848.  
  41849.    * Fixed problem with `SHOW CREATE TABLE' and `PRIMARY KEY' when using
  41850.      32 indexes.
  41851.  
  41852.    * Fixed that one can use `SET PASSWORD' for the anonymous user.
  41853.  
  41854.    * Fixed core-dump bug when reading client groups from option files
  41855.      using `mysql_options()'.
  41856.  
  41857.    * Memory leak (16 bytes per every *corrupted* table) closed.
  41858.  
  41859.    * Fixed binary builds to use `--enable-local-infile'.
  41860.  
  41861.    * Update source to work with new `bison' version.
  41862.  
  41863.    * Updated shell scripts to new agree with new POSIX standard.
  41864.  
  41865.    * Fixed bug where `DATE_FORMAT()' returned empty string when used
  41866.      with `GROUP BY'.
  41867.  
  41868. 
  41869. File: mysql.info,  Node: News-3.23.49,  Next: News-3.23.48,  Prev: News-3.23.50,  Up: News-3.23.x
  41870.  
  41871. Changes in release 3.23.49
  41872. --------------------------
  41873.  
  41874.    * Don't give warning for statement that is only a comment;  This is
  41875.      needed for `mysqldump --disable-keys' to work.
  41876.  
  41877.    * Fixed unlikely caching bug when doing a join without keys. In this
  41878.      case the last used column for a table always returned `NULL'.
  41879.  
  41880.    * Added options to make `LOAD DATA LOCAL INFILE' more secure.
  41881.  
  41882.    * MySQL binary release 3.23.48 for Linux contained a new glibc
  41883.      library, which has serious problems under high load and RedHat
  41884.      7.2.  The 3.23.49 binary release doesn't have this problem.
  41885.  
  41886.    * Fixed shutdown problem on NT.
  41887.  
  41888. 
  41889. File: mysql.info,  Node: News-3.23.48,  Next: News-3.23.47,  Prev: News-3.23.49,  Up: News-3.23.x
  41890.  
  41891. Changes in release 3.23.48
  41892. --------------------------
  41893.  
  41894.    * Changed to use `autoconf' 2.52 (from `autoconf' 2.13)
  41895.  
  41896.    * Fixed bug in complicated join with `const' tables.
  41897.  
  41898.    * Added internal safety checks for InnoDB.
  41899.  
  41900.    * Some InnoDB variables was always shown in `SHOW VARIABLES' as
  41901.      `OFF' on high-byte-first systems (like sparc).
  41902.  
  41903.    * Fixed problem with one thread using an InnoDB table and another
  41904.      thread doing an `ALTER TABLE' on the same table. Before that,
  41905.      mysqld could crash with an assertion failure in row0row.c, line
  41906.      474.
  41907.  
  41908.    * Tuned the InnoDB SQL optimizer to favor more often index searches
  41909.      over table scans.
  41910.  
  41911.    * Fixed a performance problem with InnoDB tables when several large
  41912.      SELECT queries are run concurrently on a multiprocessor Linux
  41913.      computer.  Large CPU-bound SELECT queries will now also generally
  41914.      run faster on all platforms.
  41915.  
  41916.    * If MySQL binlogging is used, InnoDB now prints after crash
  41917.      recovery the latest MySQL binlog name and the offset InnoDB was
  41918.      able to recover to. This is useful, for example, when
  41919.      resynchronizing a master and a slave database in replication.
  41920.  
  41921.    * Added better error messages to help in installation problems of
  41922.      InnoDB tables.
  41923.  
  41924.    * One can now recover also MySQL temporary tables which have become
  41925.      orphaned inside the InnoDB tablespace.
  41926.  
  41927.    * InnoDB now prevents a `FOREIGN KEY' declaration where the
  41928.      signedness is not the same in the referencing and referenced
  41929.      integer columns.
  41930.  
  41931.    * Calling `SHOW CREATE TABLE' or `SHOW TABLE STATUS' could cause
  41932.      memory corruption and make mysqld to crash.  Especially at risk was
  41933.      `mysqldump', because it calls frequently `SHOW CREATE TABLE'.
  41934.  
  41935.    * If inserts to several tables containing an auto-inc column were
  41936.      wrapped inside one `LOCK TABLES', InnoDB asserted in lock0lock.c.
  41937.  
  41938.    * In 3.23.47 we allowed several `NULLS' in a `UNIQUE' secondary
  41939.      index for an InnoDB table.  But `CHECK TABLE' was not relaxed: it
  41940.      reports the table as corrupt.  `CHECK TABLE' no longer complains in
  41941.      this situation.
  41942.  
  41943.    * `SHOW GRANTS' now shows `REFERENCES' instead of `REFERENCE'.
  41944.  
  41945. 
  41946. File: mysql.info,  Node: News-3.23.47,  Next: News-3.23.46,  Prev: News-3.23.48,  Up: News-3.23.x
  41947.  
  41948. Changes in release 3.23.47
  41949. --------------------------
  41950.  
  41951.    * Fixed in when using the following construct: `SELECT ... WHERE
  41952.      key=@var_name OR $key=@var_name2'
  41953.  
  41954.    * Restrict InnoDB keys to 500 bytes.
  41955.  
  41956.    * InnoDB now supports `NULL' in keys.
  41957.  
  41958.    * Fixed shutdown problem on HPUX. (Introduced in 3.23.46)
  41959.  
  41960.    * Fixed core-dump bug in replication when using SELECT
  41961.      RELEASE_LOCK();
  41962.  
  41963.    * Added new command: `DO expression,[expression]'
  41964.  
  41965.    * Added `slave-skip-errors' option
  41966.  
  41967.    * Added statistics variables for all MySQL commands. (`SHOW STATUS'
  41968.      is now much longer).
  41969.  
  41970.    * Fixed default values for InnoDB tables.
  41971.  
  41972.    * Fixed that `GROUP BY expr DESC' works.
  41973.  
  41974.    * Fixed bug when using `t1 LEFT JOIN t2 ON t2.key=constant'.
  41975.  
  41976.    * `mysql_config' now also work with binary (relocated) distributions.
  41977.  
  41978. 
  41979. File: mysql.info,  Node: News-3.23.46,  Next: News-3.23.45,  Prev: News-3.23.47,  Up: News-3.23.x
  41980.  
  41981. Changes in release 3.23.46
  41982. --------------------------
  41983.  
  41984.    * Fixed problem with aliased temporary tables replication
  41985.  
  41986.    * InnoDB and BDB tables will now use index when doing an `ORDER BY'
  41987.      on the whole table.
  41988.  
  41989.    * Fixed bug where one got an empty set instead of a DEADLOCK error
  41990.      when using BDB tables.
  41991.  
  41992.    * One can now kill `ANALYZE',`REPAIR' and `OPTIMIZE TABLE' when the
  41993.      thread is waiting to get a lock on the table.
  41994.  
  41995.    * Fixed race condition in `ANALYZE TABLE'.
  41996.  
  41997.    * Fixed bug when joining with caching (unlikely to happen).
  41998.  
  41999.    * Fixed race condition when using the binary log and `INSERT DELAYED'
  42000.      which could cause the binary log to have rows that was not yet
  42001.      written to MyISAM tables.
  42002.  
  42003.    * Changed caching of binary log to make replication slightly faster.
  42004.  
  42005.    * Fixed bug in replication on Mac OS X.
  42006.  
  42007. 
  42008. File: mysql.info,  Node: News-3.23.45,  Next: News-3.23.44,  Prev: News-3.23.46,  Up: News-3.23.x
  42009.  
  42010. Changes in release 3.23.45
  42011. --------------------------
  42012.  
  42013.    * `(UPDATE|DELETE) ...WHERE MATCH' bugfix
  42014.  
  42015.    * shutdown should now work on Darwin (Mac OS X).
  42016.  
  42017.    * Fixed core-dump when repairing corrupted packed MyISAM files.
  42018.  
  42019.    * `--core-file' now works on Solaris.
  42020.  
  42021.    * Fix a bug which could cause InnoDB to complain if it cannot find
  42022.      free blocks from the buffer cache during recovery.
  42023.  
  42024.    * Fixed bug in InnoDB insert buffer B-tree handling that could cause
  42025.      crashes.
  42026.  
  42027.    * Fixed bug in InnoDB lock timeout handling.
  42028.  
  42029.    * Fixed core dump bug in `ALTER TABLE' on a `TEMPORARY' InnoDB table.
  42030.  
  42031.    * Fixed bug in `OPTIMIZE TABLE' that reset index cardinality if it
  42032.      was up to date.
  42033.  
  42034.    * Fixed problem with `t1 LEFT_JOIN t2 ... WHERE t2.date_column IS
  42035.      NULL' when date_column was declared as `NOT NULL'.
  42036.  
  42037.    * Fixed bug with BDB tables and keys on `BLOB''s.
  42038.  
  42039.    * Fixed bug in `MERGE' tables on OS with 32 bit file pointers.
  42040.  
  42041.    * Fixed bug in `TIME_TO_SEC()' when using negative values.
  42042.  
  42043. 
  42044. File: mysql.info,  Node: News-3.23.44,  Next: News-3.23.43,  Prev: News-3.23.45,  Up: News-3.23.x
  42045.  
  42046. Changes in release 3.23.44
  42047. --------------------------
  42048.  
  42049.    * Fixed `Rows_examined' count in slow query log.
  42050.  
  42051.    * Fixed bug when using a reference to a `AVG()' column in `HAVING'.
  42052.  
  42053.    * Fixed that date functions that require correct dates, like
  42054.      `DAYOFYEAR(column)' will return `NULL' for `0000-00-00' dates.
  42055.  
  42056.    * Fixed bug in const-propagation when comparing columns of different
  42057.      types. (`SELECT * FROM date_col="2001-01-01" and
  42058.      date_col=time_col')
  42059.  
  42060.    * Fixed bug that caused error message `Can't write, because of unique
  42061.      constraint' with some `GROUP BY' queries.
  42062.  
  42063.    * Fixed problem with sjis character strings used within quoted table
  42064.      names.
  42065.  
  42066.    * Fixed coredump when using `CREATE ... FULLTEXT' keys with other
  42067.      table handlers than MyISAM.
  42068.  
  42069.    * Don't use `signal()' on windows because this appears to not be 100
  42070.      % reliable.
  42071.  
  42072.    * Fixed bug when doing `WHERE column_name=NULL' on an indexed column
  42073.      that had `NULL' values.
  42074.  
  42075.    * Fixed bug when doing `LEFT JOIN ...  ON (column_name = constant)
  42076.      WHERE column_name = constant'.
  42077.  
  42078.    * When using replications, aborted queries that contained `%' could
  42079.      cause a core dump.
  42080.  
  42081.    * `TCP_NODELAY' was not used on some systems. (Speed problem).
  42082.  
  42083.    * Applied portability fixes for OS/2 (Patch by Yuri Dario).
  42084.  
  42085. The following changes are for `InnoDB' tables:
  42086.  
  42087.    * Add missing `InnoDB' variables to `SHOW VARIABLES'.
  42088.  
  42089.    * Foreign keys checking is now done for `InnoDB' tables.
  42090.  
  42091.    * `DROP DATABASE' now works also for `InnoDB' tables.
  42092.  
  42093.    * `InnoDB' now supports data files and raw disk partitions bigger
  42094.      than 4 GB on those operating systems which have big files.
  42095.  
  42096.    * `InnoDB' calculates better table cardinality estimates for the
  42097.      MySQL optimizer.
  42098.  
  42099.    * Accent characters in the default character set latin1 are ordered
  42100.      according to the MySQL ordering.
  42101.  
  42102.      NOTE: if you are using latin1 and have inserted characters whose
  42103.      code is > 127 to an indexed CHAR column, you should run CHECK
  42104.      TABLE on your table when you upgrade to 3.23.44, and drop and
  42105.      reimport the table if CHECK TABLE reports an error!
  42106.  
  42107.    * A new `my.cnf' parameter `innodb_thread_concurrency' helps in
  42108.      performance tuning in heavily concurrent environments.
  42109.  
  42110.    * A new `my.cnf' parameter `innodb_fast_shutdown' speeds up server
  42111.      shutdown.
  42112.  
  42113.    * A new `my.cnf' parameter `innodb_force_recovery' helps to save
  42114.      your data in case the disk image of the database becomes corrupt.
  42115.  
  42116.    * `innodb_monitor' has been improved and a new
  42117.      `innodb_table_monitor' added.
  42118.  
  42119.    * Increased maximum key length from 500 to 7000 bytes.
  42120.  
  42121.    * Fixed a bug in replication of auto-inc columns with multiline
  42122.      inserts.
  42123.  
  42124.    * Fixed a bug when the case of letters changes in an update of an
  42125.      indexed secondary column.
  42126.  
  42127.    * Fixed a hang when there are > 24 data files.
  42128.  
  42129.    * Fixed a crash when `MAX(col)' is selected from an empty table, and
  42130.      col is a not the first column in a multi-column index.
  42131.  
  42132.    * Fixed a bug in purge which could cause crashes.
  42133.  
  42134. 
  42135. File: mysql.info,  Node: News-3.23.43,  Next: News-3.23.42,  Prev: News-3.23.44,  Up: News-3.23.x
  42136.  
  42137. Changes in release 3.23.43
  42138. --------------------------
  42139.  
  42140.    * Fixed a bug in `INSERT DELAYED' and `FLUSH TABLES' introduced in
  42141.      3.23.42.
  42142.  
  42143.    * Fixed unlikely bug, which returned not matching rows, in SELECT
  42144.      with many tables and multi-column indexes and 'range' type.
  42145.  
  42146.    * Fixed a unlikely core-dump bug when doing `EXPLAIN SELECT' when
  42147.      using many tables and `ORDER BY'.
  42148.  
  42149.    * Fixed bug in `LOAD DATA FROM MASTER' when using table with
  42150.      `CHECKSUM=1'.
  42151.  
  42152.    * Added unique error message when one gets a DEADLOCK during a
  42153.      transaction with BDB tables.
  42154.  
  42155.    * Fixed problem with `BDB' tables and `UNIQUE' columns defined as
  42156.      `NULL'.
  42157.  
  42158.    * Fixed problem with `myisampack' when using pre-space filled CHAR
  42159.      columns.
  42160.  
  42161.    * Applied patch from Yuri Dario for OS2.
  42162.  
  42163.    * Fixed bug in `--safe-user-create'
  42164.  
  42165. 
  42166. File: mysql.info,  Node: News-3.23.42,  Next: News-3.23.41,  Prev: News-3.23.43,  Up: News-3.23.x
  42167.  
  42168. Changes in release 3.23.42
  42169. --------------------------
  42170.  
  42171.    * Fixed problem when using `LOCK TABLES' and `BDB' tables.
  42172.  
  42173.    * Fixed problem with `REPAIR TABLE' on MyISAM tables with row lengths
  42174.      between 65517 - 65520 bytes
  42175.  
  42176.    * Fixed rare hang when doing `mysqladmin shutdown' when there was a
  42177.      lot of activity in other threads.
  42178.  
  42179.    * Fixed problem with `INSERT DELAYED' where delay thread could be
  42180.      hanging on `upgrading locks' without any apparent reasons.
  42181.  
  42182.    * Fixed problem with `myisampack' and `BLOB'.
  42183.  
  42184.    * Fixes problem when one edited `.MRG' tables by hand.  (Patch from
  42185.      Benjamin Pflugmann).
  42186.  
  42187.    * Enforce that all tables in a `MERGE' table come from the same
  42188.      database.
  42189.  
  42190.    * Fixed bug with `LOAD DATA INFILE' and transactional tables.
  42191.  
  42192.    * Fix bug when using `INSERT DELAYED' with wrong column definition.
  42193.  
  42194.    * Fixed coredump during `REPAIR' of some particularly broken tables.
  42195.  
  42196.    * Fixed bug in `InnoDB' and `AUTO_INCREMENT' columns.
  42197.  
  42198.    * Fixed bug in `InnoDB' and `RENAME TABLE' columns.
  42199.  
  42200.    * Fixed critical bug in `InnoDB' and `BLOB' columns.  If one has
  42201.      used `BLOB' columns larger than 8000 bytes in an `InnoDB' table,
  42202.      one must dump the table with `mysqldump', drop it and restore it
  42203.      from the dump.
  42204.  
  42205.    * Applied large patch for OS/2 from Yuri Dario.
  42206.  
  42207.    * Fixed problem with `InnoDB' when one could get the error `Can't
  42208.      execute the given command...' even when one didn't have an active
  42209.      transaction.
  42210.  
  42211.    * Applied some minor fixes that concern Gemini.
  42212.  
  42213.    * Use real arithmetic operations even in integer context if not all
  42214.      arguments are integers. (Fixes uncommon bug in some integer
  42215.      contexts).
  42216.  
  42217.    * Don't force everything to lower cases on Windows. (To fix problem
  42218.      with Windows and `ALTER TABLE').  Now `--lower_case_names' also
  42219.      works on Unix.
  42220.  
  42221.    * Fixed that automatic rollback that is done when thread end doesn't
  42222.      lock other threads.
  42223.  
  42224. 
  42225. File: mysql.info,  Node: News-3.23.41,  Next: News-3.23.40,  Prev: News-3.23.42,  Up: News-3.23.x
  42226.  
  42227. Changes in release 3.23.41
  42228. --------------------------
  42229.  
  42230.    * Added option `--sql-mode=option[,option[,option]]'.  *Note
  42231.      Command-line options::.
  42232.  
  42233.    * Fixed possible problem with `shutdown' on Solaris where the `.pid'
  42234.      file wasn't deleted.
  42235.  
  42236.    * InnoDB now supports < 4 GB rows. The former limit was 8000 bytes.
  42237.  
  42238.    * The `doublewrite' file flush method is used in `InnoDB'.  It
  42239.      reduces the need for Unix fsync calls to a fraction and improves
  42240.      performance on most Unix flavors.
  42241.  
  42242.    * You can now use the `InnoDB' Monitor to print a lot of `InnoDB'
  42243.      state information, including locks, to the standard output; useful
  42244.      in performance tuning.
  42245.  
  42246.    * Several bugs which could cause hangs in `InnoDB' have been fixed.
  42247.  
  42248.    * Split `record_buffer' to `record_buffer' and `record_rnd_buffer'.
  42249.      To make things compatible to previous MySQL versions, if
  42250.      `record_rnd_buffer' is not set, then it takes the value of
  42251.      `record_buffer'.
  42252.  
  42253.    * Fixed optimizing bug in `ORDER BY' where some `ORDER BY' parts
  42254.      where wrongly removed.
  42255.  
  42256.    * Fixed overflow bug with `ALTER TABLE' and `MERGE' tables.
  42257.  
  42258.    * Added prototypes for `my_thread_init()' and `my_thread_end()' to
  42259.      `mysql_com.h'
  42260.  
  42261.    * Added option `--safe-user-create' to `mysqld'.
  42262.  
  42263.    * Fixed bug in `SELECT DISTINCT ... HAVING' that casued error message
  42264.      `Can't find record in '#...'
  42265.  
  42266. 
  42267. File: mysql.info,  Node: News-3.23.40,  Next: News-3.23.39,  Prev: News-3.23.41,  Up: News-3.23.x
  42268.  
  42269. Changes in release 3.23.40
  42270. --------------------------
  42271.  
  42272.    * Fixed problem with `--low-priority-updates' and `INSERT''s.
  42273.  
  42274.    * Fixed bug in slave thread when under some rare circumstances it
  42275.      could get 22 bytes ahead on the offset in the master.
  42276.  
  42277.    * Added `slave_wait_timeout' for replication.
  42278.  
  42279.    * Fixed problem with `UPDATE' and `BDB' tables.
  42280.  
  42281.    * Fixed hard bug in `BDB' tables when using key parts.
  42282.  
  42283.    * Fixed problem when using the `GRANT FILE ON database.* ...';
  42284.      Previously we added the `DROP' privilege for the database.
  42285.  
  42286.    * Fixed `DELETE FROM table_name ... LIMIT 0' and `UPDATE FROM
  42287.      table_name ... LIMIT 0' acted as though the `LIMIT' clause was not
  42288.      present (they deleted or updated all selected rows).
  42289.  
  42290.    * `CHECK TABLE' now checks if an `AUTO_INCREMENT' column contains
  42291.      the value 0.
  42292.  
  42293.    * Sending a `SIGHUP' to `mysqld' will now only flush the logs, not
  42294.      reset the replication.
  42295.  
  42296.    * Fixed parser to allow floats of type `1.0e1' (no sign after `e').
  42297.  
  42298.    * Option `--force' to `myisamchk' now also updates states.
  42299.  
  42300.    * Added option `--warnings' to `mysqld'. Now `mysqld' only prints
  42301.      the error `Aborted connection' if this option is used.
  42302.  
  42303.    * Fixed problem with `SHOW CREATE TABLE' when you didn't have a
  42304.      `PRIMARY KEY'.
  42305.  
  42306.    * Properly fixed the rename of `innodb_unix_file_flush_method' to
  42307.      `innodb_flush_method'.
  42308.  
  42309.    * Fixed bug when converting `UNSIGNED BIGINT' to `DOUBLE'. This
  42310.      caused a problem when doing comparisons with `BIGINT' values
  42311.      outside of the signed range.
  42312.  
  42313.    * Fixed bug in `BDB' tables when querying empty tables.
  42314.  
  42315.    * Fixed a bug when using `COUNT(DISTINCT)' with `LEFT JOIN' and
  42316.      there wasn't any matching rows.
  42317.  
  42318.    * Removed all documentation referring to the `GEMINI' table type.
  42319.      `GEMINI' is not released under an Open Source license.
  42320.  
  42321. 
  42322. File: mysql.info,  Node: News-3.23.39,  Next: News-3.23.38,  Prev: News-3.23.40,  Up: News-3.23.x
  42323.  
  42324. Changes in release 3.23.39
  42325. --------------------------
  42326.  
  42327.    * The `AUTO_INCREMENT' sequence wasn't reset when dropping and
  42328.      adding an `AUTO_INCREMENT' column.
  42329.  
  42330.    * `CREATE ... SELECT' now creates non-unique indexes delayed.
  42331.  
  42332.    * Fixed problem where `LOCK TABLES table_name READ' followed by
  42333.      `FLUSH TABLES' put an exclusive lock on the table.
  42334.  
  42335.    * `REAL' @variables with was represented with 2 digits when
  42336.      converted to strings.
  42337.  
  42338.    * Fixed problem that client 'hung' when `LOAD TABLE FROM MASTER'
  42339.      failed.
  42340.  
  42341.    * Running `myisamchk --fast --force' will no longer repair tables
  42342.      that only had the open count wrong.
  42343.  
  42344.    * Added functions to handle symbolic links to make life easier in
  42345.      4.0.
  42346.  
  42347.    * We are now using the `-lcma' thread library on HP-UX 10.20 so that
  42348.      MySQL will be more stable on HP-UX.
  42349.  
  42350.    * Fixed problem with `IF()' and number of decimals in the result.
  42351.  
  42352.    * Fixed date-part extraction functions to work with dates where day
  42353.      and/or month is 0.
  42354.  
  42355.    * Extended argument length in option files from 256 to 512 chars.
  42356.  
  42357.    * Fixed problem with shutdown when `INSERT DELAYED' was waiting for
  42358.      a `LOCK TABLE'.
  42359.  
  42360.    * Fixed coredump bug in `InnoDB' when tablespace was full.
  42361.  
  42362.    * Fixed problem with `MERGE' tables and big tables (> 4G) when using
  42363.      `ORDER BY'.
  42364.  
  42365. 
  42366. File: mysql.info,  Node: News-3.23.38,  Next: News-3.23.37,  Prev: News-3.23.39,  Up: News-3.23.x
  42367.  
  42368. Changes in release 3.23.38
  42369. --------------------------
  42370.  
  42371.    * Fixed a bug when `SELECT' from `MERGE' table sometimes results in
  42372.      incorrectly ordered rows.
  42373.  
  42374.    * Fixed a bug in `REPLACE()' when using the ujis character set.
  42375.  
  42376.    * Applied Sleepycat BDB patches 3.2.9.1 and 3.2.9.2.
  42377.  
  42378.    * Added option `--skip-stack-trace' to `mysqld'.
  42379.  
  42380.    * `CREATE TEMPORARY' now works with `InnoDB' tables.
  42381.  
  42382.    * `InnoDB' now promotes sub keys to whole keys.
  42383.  
  42384.    * Added option `CONCURRENT' to `LOAD DATA'.
  42385.  
  42386.    * Better error message when slave `max_allowed_packet' is too low to
  42387.      read a very long log event from the master.
  42388.  
  42389.    * Fixed bug when too many rows where removed when using `SELECT
  42390.      DISTINCT ... HAVING'.
  42391.  
  42392.    * `SHOW CREATE TABLE' now returns `TEMPORARY' for temporary tables.
  42393.  
  42394.    * Added `Rows_examined' to slow query log.
  42395.  
  42396.    * Fixed problems with function returning empty string when using
  42397.      together with a group functions and a `WHERE' that didn't match
  42398.      any rows.
  42399.  
  42400.    * New program `mysqlcheck'.
  42401.  
  42402.    * Added database name to output for administrative commands like
  42403.      `CHECK', `REPAIR', `OPTIMIZE'.
  42404.  
  42405.    * Lots of portability fixes for `InnoDB'.
  42406.  
  42407.    * Changed optimizer so that queries like `SELECT * FROM
  42408.      table_name,table_name2 ... ORDER BY key_part1 LIMIT #' will use
  42409.      index on `key_part1' instead of `filesort'.
  42410.  
  42411.    * Fixed bug when doing `LOCK TABLE to_table WRITE,...; INSERT INTO
  42412.      to_table... SELECT ...' when `to_table' was empty.
  42413.  
  42414.    * Fixed bug with `LOCK TABLE' and BDB tables.
  42415.  
  42416. 
  42417. File: mysql.info,  Node: News-3.23.37,  Next: News-3.23.36,  Prev: News-3.23.38,  Up: News-3.23.x
  42418.  
  42419. Changes in release 3.23.37
  42420. --------------------------
  42421.  
  42422.    * Fixed a bug when using `MATCH' in `HAVING' clause.
  42423.  
  42424.    * Fixed a bug when using `HEAP' tables with `LIKE'.
  42425.  
  42426.    * Added `--mysql-version' to `safe_mysqld'
  42427.  
  42428.    * Changed `INNOBASE' to `InnoDB' (because the `INNOBASE' name was
  42429.      already used). All `configure' options and `mysqld' start options
  42430.      are now using `innodb' instead of `innobase'. This means that you
  42431.      have to change any configuration files where you have used
  42432.      `innobase' options before upgrading to this version!
  42433.  
  42434.    * Fixed bug when using indexes on `CHAR(255) NULL' columns.
  42435.  
  42436.    * Slave thread will now be started even if `master-host' is not set,
  42437.      as long as `server-id' is set and valid `master.info' is present
  42438.  
  42439.    * Partial updates (terminated with kill) are now logged with a
  42440.      special error code to the binary log. Slave will refuse to execute
  42441.      them if the error code indicates the update was terminated
  42442.      abnormally, and will have to be recovered with `SET
  42443.      SQL_SLAVE_SKIP_COUNTER=1; SLAVE START' after a manual sanity
  42444.      check/correction of data integrity.
  42445.  
  42446.    * Fixed bug that erroneously logged a drop of internal temporary
  42447.      table on thread termination to the binary log - bug affected
  42448.      replication.
  42449.  
  42450.    * Fixed a bug in `REGEXP()' on 64-bit machines.
  42451.  
  42452.    * `UPDATE' and `DELETE' with `WHERE unique_key_part IS NULL' didn't
  42453.      update/delete all rows.
  42454.  
  42455.    * Disabled `INSERT DELAYED' for tables that support transactions.
  42456.  
  42457.    * Fixed bug when using date functions on `TEXT'/`BLOB' column with
  42458.      wrong date format.
  42459.  
  42460.    * UDFs now also work on Windows. (Patch by Ralph Mason)
  42461.  
  42462.    * Fixed bug in `ALTER TABLE' and `LOAD DATA INFILE' that disabled
  42463.      key-sorting. These commands should now be faster in most cases.
  42464.  
  42465.    * Fixed performance bug where reopened tables (tables that had been
  42466.      waiting for `FLUSH' or `REPAIR') would not use indexes for the
  42467.      next query.
  42468.  
  42469.    * Fixed problem with `ALTER TABLE' to Innobase tables on FreeBSD.
  42470.  
  42471.    * Added `mysqld' variables `myisam_max_sort_file_size' and
  42472.      `myisam_max_extra_sort_file_size'.
  42473.  
  42474.    * Initialize signals early to avoid problem with signals in Innobase.
  42475.  
  42476.    * Applied patch for the `tis620' character set to make comparisons
  42477.      case-independent and to fix a bug in `LIKE' for this character set.
  42478.      *NOTE*: All tables that uses the `tis620' character set must be
  42479.      fixed with  `myisamchk -r' or `REPAIR TABLE' !
  42480.  
  42481.    * Added `--skip-safemalloc' option to `mysqld'.
  42482.  
  42483. 
  42484. File: mysql.info,  Node: News-3.23.36,  Next: News-3.23.35,  Prev: News-3.23.37,  Up: News-3.23.x
  42485.  
  42486. Changes in release 3.23.36
  42487. --------------------------
  42488.  
  42489.    * Fixed a bug that allowed you to use database names containing a `.'
  42490.      character.  This fixes a serious security issue when `mysqld' is
  42491.      run as root.
  42492.  
  42493.    * Fixed bug when thread creation failed (could happen when doing a
  42494.      LOT of connections in a short time).
  42495.  
  42496.    * Fixed some problems with `FLUSH TABLES' and `TEMPORARY' tables.
  42497.      (Problem with freeing the key cache and error `Can't reopen
  42498.      table...').
  42499.  
  42500.    * Fixed a problem in Innobase with other character sets than `latin1'
  42501.      and another problem when using many columns.
  42502.  
  42503.    * Fixed bug that caused a core dump when using a very complex query
  42504.      involving `DISTINCT' and summary functions.
  42505.  
  42506.    * Added `SET TRANSACTION ISOLATION LEVEL ...'
  42507.  
  42508.    * Added `SELECT ... FOR UPDATE'.
  42509.  
  42510.    * Fixed bug where the number of affected rows was not returned when
  42511.      `MySQL' was compiled without transaction support.
  42512.  
  42513.    * Fixed a bug in `UPDATE' where keys weren't always used to find the
  42514.      rows to be updated.
  42515.  
  42516.    * Fixed a bug in `CONCAT_WS()' where it returned wrong results.
  42517.  
  42518.    * Changed `CREATE ... INSERT' and `INSERT ... SELECT' to not allow
  42519.      concurrent inserts as this could make the binary log hard to
  42520.      repeat.  (Concurrent inserts are enabled if you are not using the
  42521.      binary or update log).
  42522.  
  42523.    * Changed some macros to be able to use fast mutex with glibc 2.2.
  42524.  
  42525. 
  42526. File: mysql.info,  Node: News-3.23.35,  Next: News-3.23.34a,  Prev: News-3.23.36,  Up: News-3.23.x
  42527.  
  42528. Changes in release 3.23.35
  42529. --------------------------
  42530.  
  42531.    * Fixed newly introduced bug in `ORDER BY'.
  42532.  
  42533.    * Fixed wrong define `CLIENT_TRANSACTIONS'.
  42534.  
  42535.    * Fixed bug in `SHOW VARIABLES' when using `INNOBASE' tables.
  42536.  
  42537.    * Setting and using user variables in `SELECT DISTINCT' didn't work.
  42538.  
  42539.    * Tuned `SHOW ANALYZE' for small tables.
  42540.  
  42541.    * Fixed handling of arguments in the benchmark script
  42542.      `run-all-tests'.
  42543.  
  42544. 
  42545. File: mysql.info,  Node: News-3.23.34a,  Next: News-3.23.34,  Prev: News-3.23.35,  Up: News-3.23.x
  42546.  
  42547. Changes in release 3.23.34a
  42548. ---------------------------
  42549.  
  42550.    * Added extra files to the distribution to allow `INNOBASE' support
  42551.      to be compiled.
  42552.  
  42553. 
  42554. File: mysql.info,  Node: News-3.23.34,  Next: News-3.23.33,  Prev: News-3.23.34a,  Up: News-3.23.x
  42555.  
  42556. Changes in release 3.23.34
  42557. --------------------------
  42558.  
  42559.    * Added the `INNOBASE' table handler and the `BDB' table handler to
  42560.      the MySQL source distribution.
  42561.  
  42562.    * Updated the documentation about `GEMINI' tables.
  42563.  
  42564.    * Fixed a bug in `INSERT DELAYED' that caused threads to hang when
  42565.      inserting `NULL' into an `AUTO_INCREMENT' column.
  42566.  
  42567.    * Fixed a bug in `CHECK TABLE' / `REPAIR TABLE' that could cause a
  42568.      thread to hang.
  42569.  
  42570.    * `REPLACE' will not replace a row that conflicts with an
  42571.      `auto_increment' generated key.
  42572.  
  42573.    * `mysqld' now only sets `CLIENT_TRANSACTIONS' in
  42574.      `mysql->server_capabilities' if the server supports a
  42575.      transaction-safe handler.
  42576.  
  42577.    * Fixed `LOAD DATA INFILE' to allow numeric values to be read into
  42578.      `ENUM' and `SET' columns.
  42579.  
  42580.    * Improved error diagnostic for slave thread exit.
  42581.  
  42582.    * Fixed bug in `ALTER TABLE ... ORDER BY'.
  42583.  
  42584.    * Added option `max_user_connections' to `mysqld'.
  42585.  
  42586.    * Limit query length for replication by `max_allowed_packet', not the
  42587.      arbitrary limit of 4 MB.
  42588.  
  42589.    * Allow space around `=' in argument to `--set-variable'.
  42590.  
  42591.    * Fixed problem in automatic repair that could leave some threads in
  42592.      state `Waiting for table'.
  42593.  
  42594.    * `SHOW CREATE TABLE' now dumps the `UNION()' for `MERGE' tables.
  42595.  
  42596.    * `ALTER TABLE' now remembers the old `UNION()' definition.
  42597.  
  42598.    * Fixed bug when replicating timestamps.
  42599.  
  42600.    * Fixed bug in bidirectional replication.
  42601.  
  42602.    * Fixed bug in the `BDB' table handler that occurred when using an
  42603.      index on multi-part key where a key part may be `NULL'.
  42604.  
  42605.    * Fixed `MAX()' optimization on sub-key for `BDB' tables.
  42606.  
  42607.    * Fixed problem where garbage results were returned when using `BDB'
  42608.      tables and `BLOB' or `TEXT' fields when joining many tables.
  42609.  
  42610.    * Fixed a problem with `BDB' tables and `TEXT' columns.
  42611.  
  42612.    * Fixed bug when using a `BLOB' key where a const row wasn't found.
  42613.  
  42614.    * Fixed that `mysqlbinlog' writes the timestamp value for each query.
  42615.      This ensures that one gets same values for date functions like
  42616.      `NOW()' when using `mysqlbinlog' to pipe the queries to another
  42617.      server.
  42618.  
  42619.    * Allow one to use `--skip-gemini', `--skip-bdb' and
  42620.      `--skip-innobase' to `mysqld' even if these databases are not
  42621.      compiled in `mysqld'.
  42622.  
  42623.    * One can now do `GROUP BY ... DESC'.
  42624.  
  42625.    * Fixed a deadlock in the `SET' code, when one ran `SET @foo=bar',
  42626.      where `bar' is a column reference, an error was not properly
  42627.      generated.
  42628.  
  42629. 
  42630. File: mysql.info,  Node: News-3.23.33,  Next: News-3.23.32,  Prev: News-3.23.34,  Up: News-3.23.x
  42631.  
  42632. Changes in release 3.23.33
  42633. --------------------------
  42634.  
  42635.    * Fixed that DNS lookups are not using the same mutex as the hostname
  42636.      cache.  This will enable known hosts to be quickly resolved even
  42637.      if a DNS lookup takes a long time.
  42638.  
  42639.    * Added `--character-sets-dir' to `myisampack'.
  42640.  
  42641.    * Removed warnings when running `REPAIR TABLE ... EXTENDED'.
  42642.  
  42643.    * Fixed a bug that caused a core dump when using `GROUP BY' on an
  42644.      alias, where the alias was the same as an existing column name.
  42645.  
  42646.    * Added `SEQUENCE()' as an example UDF function.
  42647.  
  42648.    * Changed `mysql_install_db' to use `BINARY' for `CHAR' columns in
  42649.      the privilege tables.
  42650.  
  42651.    * Changed `TRUNCATE table_name' to `TRUNCATE TABLE table_name' to
  42652.      use the same syntax as Oracle.  Until 4.0 we will also allow
  42653.      `TRUNCATE table_name' to not crash old code.
  42654.  
  42655.    * Fixed 'no found rows' bug in `MyISAM' tables when a `BLOB' was
  42656.      first part of a multi-part key.
  42657.  
  42658.    * Fixed bug where `CASE' didn't work with `GROUP BY'.
  42659.  
  42660.    * Added option `--sort-recover' to `myisamchk'.
  42661.  
  42662.    * `myisamchk -S' and `OPTIMIZE TABLE' now work on Windows.
  42663.  
  42664.    * Fixed bug when using `DISTINCT' on results from functions that
  42665.      referred to a group function, like:
  42666.           SELECT a, DISTINCT SEC_TO_TIME(sum(a)) from table_name GROUP BY a, b;
  42667.  
  42668.    * Fixed buffer overrun in `libmysqlclient' library.  Fixed bug in
  42669.      handling `STOP' event after `ROTATE' event in replication.
  42670.  
  42671.    * Fixed another buffer overrun in `DROP DATABASE'.
  42672.  
  42673.    * Added `Table_locks_immediate' and `Table_locks_waited' status
  42674.      variables.
  42675.  
  42676.    * Fixed bug in replication that broke slave server start with
  42677.      existing `master.info'. This fixes a bug introduced in 3.23.32.
  42678.  
  42679.    * Added `SET SQL_SLAVE_SKIP_COUNTER=n' command to recover from
  42680.      replication glitches without a full database copy.
  42681.  
  42682.    * Added `max_binlog_size' variable; the binary log will be rotated
  42683.      automatically when the size crosses the limit.
  42684.  
  42685.    * Added `Last_error', `Last_errno', and `Slave_skip_counter' to
  42686.      `SHOW SLAVE STATUS'.
  42687.  
  42688.    * Fixed bug in `MASTER_POS_WAIT()' function.
  42689.  
  42690.    * Execute coredump handler on `SIGILL', and `SIGBUS' in addition to
  42691.      `SIGSEGV'.
  42692.  
  42693.    * On x86 Linux, print the current query and thread (connection) id,
  42694.      if available, in the coredump handler.
  42695.  
  42696.    * Fixed several timing bugs in the test suite.
  42697.  
  42698.    * Extended `mysqltest' to take care of the timing issues in the test
  42699.      suite.
  42700.  
  42701.    * `ALTER TABLE' can now be used to change the definition for a
  42702.      `MERGE' table.
  42703.  
  42704.    * Fixed creation of `MERGE' tables on Windows.
  42705.  
  42706.    * Portability fixes for OpenBSD and OS2.
  42707.  
  42708.    * Added `--temp-pool' option to `mysqld'.  Using this option will
  42709.      cause most temporary files created to use a small set of names,
  42710.      rather than a unique name for each new file.  This is to work
  42711.      around a problem in the Linux kernel dealing with creating a bunch
  42712.      of new files with different names.  With the old behavior, Linux
  42713.      seems to "leak" memory, as it's being allocated to the directory
  42714.      entry cache instead of the disk cache.
  42715.  
  42716. 
  42717. File: mysql.info,  Node: News-3.23.32,  Next: News-3.23.31,  Prev: News-3.23.33,  Up: News-3.23.x
  42718.  
  42719. Changes in release 3.23.32
  42720. --------------------------
  42721.  
  42722.    * Changed code to get around compiler bug in Compaq C++ on OSF1,
  42723.      that broke `BACKUP', `RESTORE', `CHECK', `REPAIR', and `ANALYZE
  42724.      TABLE'.
  42725.  
  42726.    * Added option `FULL' to `SHOW COLUMNS'. Now we show the privilege
  42727.      list for the columns only if this option is given.
  42728.  
  42729.    * Fixed bug in `SHOW LOGS' when there weren't any BDB logs.
  42730.  
  42731.    * Fixed a timing problem in replication that could delay sending an
  42732.      update to the client until a new update was done.
  42733.  
  42734.    * Don't convert field names when using `mysql_list_fields()'.  This
  42735.      is to keep this code compatible with `SHOW FIELDS'.
  42736.  
  42737.    * `MERGE' tables didn't work on Windows.
  42738.  
  42739.    * Fixed problem with `SET PASSWORD=...' on Windows.
  42740.  
  42741.    * Added missing `my_config.h' to RPM distribution.
  42742.  
  42743.    * `TRIM("foo" from "foo")' didn't return an empty string.
  42744.  
  42745.    * Added `--with-version-suffix' to `configure'.
  42746.  
  42747.    * Fixed coredump when client aborted connection without
  42748.      `mysql_close()'.
  42749.  
  42750.    * Fixed a bug in `RESTORE TABLE' when trying to restore from a
  42751.      non-existent directory.
  42752.  
  42753.    * Fixed a bug which caused a core dump on the slave when replicating
  42754.      `SET PASSWORD'.
  42755.  
  42756.    * Added `MASTER_POS_WAIT()'.
  42757.  
  42758. 
  42759. File: mysql.info,  Node: News-3.23.31,  Next: News-3.23.30,  Prev: News-3.23.32,  Up: News-3.23.x
  42760.  
  42761. Changes in release 3.23.31
  42762. --------------------------
  42763.  
  42764.    * The test suite now tests all reachable BDB interface code.  During
  42765.      testing we found and fixed many errors in the interface code.
  42766.  
  42767.    * Using `HAVING' on an empty table could produce one result row when
  42768.      it shouldn't.
  42769.  
  42770.    * Fixed that the MySQL RPM is not dependent on Perl5 anymore.
  42771.  
  42772.    * Fixed some problems with `HEAP' tables on Windows.
  42773.  
  42774.    * `SHOW TABLE STATUS' didn't show correct average row length for
  42775.      tables larger than 4G.
  42776.  
  42777.    * `CHECK TABLE ... EXTENDED' didn't check row links for fixed size
  42778.      tables.
  42779.  
  42780.    * Added option `MEDIUM' to `CHECK TABLE'.
  42781.  
  42782.    * Fixed problem when using `DECIMAL()' keys on negative numbers.
  42783.  
  42784.    * `HOUR()' (and some other `TIME' functions) on a `CHAR' column
  42785.      always returned `NULL'.
  42786.  
  42787.    * Fixed security bug in something (please upgrade if you are using a
  42788.      earlier MySQL 3.23 version).
  42789.  
  42790.    * Fixed buffer overflow bug when writing a certain error message.
  42791.  
  42792.    * Added usage of `setrlimit()' on Linux to get `-O
  42793.      --open-files-limit=#' to work on Linux.
  42794.  
  42795.    * Added new `mysqld' variable: `bdb_version'.
  42796.  
  42797.    * Fixed bug when using expression of type:
  42798.           SELECT ... FROM t1 LEFT JOIN t2 ON (t1.a=t2.a) WHERE t1.a=t2.a
  42799.      In this case the test in the `WHERE' clause was wrongly optimized
  42800.      away.
  42801.  
  42802.    * Fixed bug in `MyISAM' when deleting keys with possible `NULL'
  42803.      values, but the first key-column was not a prefix-compressed text
  42804.      column.
  42805.  
  42806.    * Fixed `mysql.server' to read the `mysql.server' option section
  42807.      instead of `mysql_server'.
  42808.  
  42809.    * Fixed `safe_mysqld' and `mysql.server' to also read the `server'
  42810.      option section.
  42811.  
  42812.    * Added `Threads_created' status variable to `mysqld'.
  42813.  
  42814. 
  42815. File: mysql.info,  Node: News-3.23.30,  Next: News-3.23.29,  Prev: News-3.23.31,  Up: News-3.23.x
  42816.  
  42817. Changes in release 3.23.30
  42818. --------------------------
  42819.  
  42820.    * Added `SHOW OPEN TABLES' command.
  42821.  
  42822.    * Fixed that `myisamdump' works against old `mysqld' servers.
  42823.  
  42824.    * Fixed `myisamchk -k#' so that it works again.
  42825.  
  42826.    * Fixed a problem with replication when the binary log file went
  42827.      over 2G on 32-bit systems.
  42828.  
  42829.    * `LOCK TABLES' will now automatically start a new transaction.
  42830.  
  42831.    * Changed `BDB' tables to not use internal subtransactions and reuse
  42832.      open files to get more speed.
  42833.  
  42834.    * Added option `--mysqld=#' to `safe_mysqld'.
  42835.  
  42836.    * Allow hex constants in the `--fields-*-by' and
  42837.      `--lines-terminated-by' options to `mysqldump' and `mysqlimport'.
  42838.      By Paul DuBois.
  42839.  
  42840.    * Added option `--safe-show-database' to `mysqld'.
  42841.  
  42842.    * Added `have_bdb', `have_gemini', `have_innobase', `have_raid' and
  42843.      `have_ssl' to `SHOW VARIABLES' to make it easy to test for
  42844.      supported extensions.
  42845.  
  42846.    * Added option `--open-files-limit' to `mysqld'.
  42847.  
  42848.    * Changed option `--open-files' to `--open-files-limit' in
  42849.      `safe_mysqld'.
  42850.  
  42851.    * Fixed a bug where some rows were not found with `HEAP' tables that
  42852.      had many keys.
  42853.  
  42854.    * Fixed that `--bdb-no-sync' works.
  42855.  
  42856.    * Changed `--bdb-recover' to `--bdb-no-recover' as recover should be
  42857.      on by default.
  42858.  
  42859.    * Changed the default number of BDB locks to 10000.
  42860.  
  42861.    * Fixed a bug from 3.23.29 when allocating the shared structure
  42862.      needed for BDB tables.
  42863.  
  42864.    * Changed `mysqld_multi.sh' to use configure variables. Patch by
  42865.      Christopher McCrory.
  42866.  
  42867.    * Added fixing of include files for Solaris 2.8.
  42868.  
  42869.    * Fixed bug with `--skip-networking' on Debian Linux.
  42870.  
  42871.    * Fixed problem that some temporary files where reported as having
  42872.      the name `UNOPENED' in error messages.
  42873.  
  42874.    * Fixed bug when running two simultaneous `SHOW LOGS' queries.
  42875.  
  42876. 
  42877. File: mysql.info,  Node: News-3.23.29,  Next: News-3.23.28,  Prev: News-3.23.30,  Up: News-3.23.x
  42878.  
  42879. Changes in release 3.23.29
  42880. --------------------------
  42881.  
  42882.    * Configure updates for Tru64, large file support, and better TCP
  42883.      wrapper support. By Albert Chin-A-Young.
  42884.  
  42885.    * Fixed bug in `<=>' operator.
  42886.  
  42887.    * Fixed bug in `REPLACE' with BDB tables.
  42888.  
  42889.    * `LPAD()' and `RPAD()' will shorten the result string if it's longer
  42890.      than the length argument.
  42891.  
  42892.    * Added `SHOW LOGS' command.
  42893.  
  42894.    * Remove not used BDB logs on shutdown.
  42895.  
  42896.    * When creating a table, put `PRIMARY' keys first, followed by
  42897.      `UNIQUE' keys.
  42898.  
  42899.    * Fixed a bug in `UPDATE' involving multi-part keys where one
  42900.      specified all key parts both in the update and the `WHERE' part. In
  42901.      this case MySQL could try to update a record that didn't match the
  42902.      whole `WHERE' part.
  42903.  
  42904.    * Changed drop table to first drop the tables and then the `.frm'
  42905.      file.
  42906.  
  42907.    * Fixed a bug in the hostname cache which caused `mysqld' to report
  42908.      the hostname as `''' in some error messages.
  42909.  
  42910.    * Fixed a bug with `HEAP' type tables; the variable
  42911.      `max_heap_table_size' wasn't used. Now either `MAX_ROWS' or
  42912.      `max_heap_table_size' can be used to limit the size of a `HEAP'
  42913.      type table.
  42914.  
  42915.    * Changed the default server-id to 1 for masters and 2 for slaves to
  42916.      make it easier to use the binary log.
  42917.  
  42918.    * Renamed variable `bdb_lock_max' to `bdb_max_lock'.
  42919.  
  42920.    * Added support for `auto_increment' on sub-fields for BDB tables.
  42921.  
  42922.    * Added `ANALYZE' of BDB tables.
  42923.  
  42924.    * In BDB tables, we now store the number of rows; This helps to
  42925.      optimize queries when we need an approximation of the number of
  42926.      rows.
  42927.  
  42928.    * If we get an error in a multi-row statement, we now only rollback
  42929.      the last statement, not the entire transaction.
  42930.  
  42931.    * If you do a `ROLLBACK' when you have updated a non-transactional
  42932.      table you will get an error as a warning.
  42933.  
  42934.    * Added option `--bdb-shared-data' to `mysqld'.
  42935.  
  42936.    * Added status variable `Slave_open_temp_tables'.
  42937.  
  42938.    * Added variables `binlog_cache_size' and `max_binlog_cache_size' to
  42939.      `mysqld'.
  42940.  
  42941.    * `DROP TABLE', `RENAME TABLE', `CREATE INDEX' and `DROP INDEX' are
  42942.      now transaction endpoints.
  42943.  
  42944.    * If you do a `DROP DATABASE' on a symbolic linked database, both
  42945.      the link and the original database is deleted.
  42946.  
  42947.    * Fixed that `DROP DATABASE' works on OS/2.
  42948.  
  42949.    * Fixed bug when doing a `SELECT DISTINCT ... table1 LEFT JOIN
  42950.      table2 ...' when table2 was empty.
  42951.  
  42952.    * Added `--abort-slave-event-count' and
  42953.      `--disconnect-slave-event-count' options to `mysqld' for debugging
  42954.      and testing of replication.
  42955.  
  42956.    * Fixed replication of temporary tables. Handles everything except
  42957.      slave server restart.
  42958.  
  42959.    * `SHOW KEYS' now shows whether or not key is `FULLTEXT'.
  42960.  
  42961.    * New script `mysqld_multi'. *Note `mysqld_multi': mysqld_multi.
  42962.  
  42963.    * Added new script, `mysql-multi.server.sh'.  Thanks to Tim Bunce
  42964.      <Tim.Bunce@ig.co.uk> for modifying `mysql.server' to easily handle
  42965.      hosts running many `mysqld' processes.
  42966.  
  42967.    * `safe_mysqld', `mysql.server', and `mysql_install_db' have been
  42968.      modified to use `mysql_print_defaults' instead of various hacks to
  42969.      read the `my.cnf' files.  In addition, the handling of various
  42970.      paths has been made more consistent with how `mysqld' handles them
  42971.      by default.
  42972.  
  42973.    * Automatically remove Berkeley DB transaction logs that no longer
  42974.      are in use.
  42975.  
  42976.    * Fixed bug with several `FULLTEXT' indexes in one table.
  42977.  
  42978.    * Added a warning if number of rows changes on `REPAIR'/`OPTIMIZE'.
  42979.  
  42980.    * Applied patches for OS/2 by `Yuri Dario'.
  42981.  
  42982.    * `FLUSH TABLES table_name' didn't always flush the index tree to
  42983.      disk properly.
  42984.  
  42985.    * `--bootstrap' is now run in a separate thread. This fixes a problem
  42986.      that caused `mysql_install_db' to core dump on some Linux machines.
  42987.  
  42988.    * Changed `mi_create()' to use less stack space.
  42989.  
  42990.    * Fixed bug with optimizer trying to over-optimize `MATCH' when used
  42991.      with `UNIQUE' key.
  42992.  
  42993.    * Changed `crash-me' and the MySQL benchmarks to also work with
  42994.      FrontBase.
  42995.  
  42996.    * Allow `RESTRICT' and `CASCADE' after `DROP TABLE' to make porting
  42997.      easier.
  42998.  
  42999.    * Reset status variable which could cause problem if one used
  43000.      `--slow-log'.
  43001.  
  43002.    * Added variable `connect_timeout' to `mysql' and `mysqladmin'.
  43003.  
  43004.    * Added `connect_timeout' as an alias for `timeout' for option files
  43005.      read by `mysql_options()'.
  43006.  
  43007. 
  43008. File: mysql.info,  Node: News-3.23.28,  Next: News-3.23.27,  Prev: News-3.23.29,  Up: News-3.23.x
  43009.  
  43010. Changes in release 3.23.28
  43011. --------------------------
  43012.  
  43013.    * Added new options `--pager[=...]', `--no-pager', `--tee=...' and
  43014.      `--no-tee' to the `mysql' client.  The new corresponding
  43015.      interactive commands are `pager', `nopager', `tee' and `notee'.
  43016.      *Note `mysql': mysql, `mysql --help' and the interactive help for
  43017.      more information.
  43018.  
  43019.    * Fixed crash when automatic repair of `MyISAM' table failed.
  43020.  
  43021.    * Fixed a major performance bug in the table locking code when one
  43022.      constantly had a LOT of `SELECT', `UPDATE' and `INSERT' statements
  43023.      running. The symptom was that the `UPDATE' and `INSERT' queries
  43024.      were locked for a long time while new `SELECT' statements were
  43025.      executed before the updates.
  43026.  
  43027.    * When reading `options_files' with `mysql_options()' the
  43028.      `return-found-rows' option was ignored.
  43029.  
  43030.    * One can now specify `interactive-timeout' in the option file that
  43031.      is read by `mysql_options()'. This makes it possible to force
  43032.      programs that run for a long time (like `mysqlhotcopy') to use
  43033.      `interactive_timeout' instead of `wait_timeout'.
  43034.  
  43035.    * Added to the slow query log the time and the user name for each
  43036.      logged query. If you are using `--log-long-format' then also
  43037.      queries that do not use an index are logged, even if the query
  43038.      takes less than `long_query_time' seconds.
  43039.  
  43040.    * Fixed a problem in `LEFT JOIN' which caused all columns in a
  43041.      reference table to be `NULL'.
  43042.  
  43043.    * Fixed a problem when using `NATURAL JOIN' without keys.
  43044.  
  43045.    * Fixed a bug when using a multi-part keys where the first part was
  43046.      of type `TEXT' or `BLOB'.
  43047.  
  43048.    * `DROP' of temporary tables wasn't stored in the update/binary log.
  43049.  
  43050.    * Fixed a bug where `SELECT DISTINCT * ... LIMIT #' only returned
  43051.      one row.
  43052.  
  43053.    * Fixed a bug in the assembler code in `strstr()' for sparc and
  43054.      cleaned up the `global.h' header file to avoid a problem with bad
  43055.      aliasing with the compiler submitted with RedHat 7.0. (Reported by
  43056.      Trond Eivind Glomsr°d)
  43057.  
  43058.    * The option `--skip-networking' now works properly on NT.
  43059.  
  43060.    * Fixed a long outstanding bug in the `ISAM' tables when a row with
  43061.      a length of more than 65K was shortened by a single byte.
  43062.  
  43063.    * Fixed a bug in `MyISAM' when running multiple updating processes on
  43064.      the same table.
  43065.  
  43066.    * Allow one to use `FLUSH TABLE tablename'.
  43067.  
  43068.    * Added `--replicate-ignore-table', `--replicate-do-table',
  43069.      `--replicate-wild-ignore-table', `--replicate-wild-do-table'.
  43070.  
  43071.    * Changed all log files to use our own `IO_CACHE' mechanism instead
  43072.      of `FILE' to avoid OS problems when there are many files open.
  43073.  
  43074.    * Added options `--open-files' and `--timezone' to `safe_mysqld'.
  43075.  
  43076.    * Fixed a fatal bug in `CREATE TEMPORARY TABLE ... SELECT ...'.
  43077.  
  43078.    * Fixed a problem with `CREATE TABLE ... SELECT NULL'.
  43079.  
  43080.    * Added variables `large_file_support',`net_read_timeout',
  43081.      `net_write_timeout' and `query_buffer_size' to `SHOW VARIABLES'.
  43082.  
  43083.    * Added status variables `created_tmp_files' and `sort_merge_passes'
  43084.      to `SHOW STATUS'.
  43085.  
  43086.    * Fixed a bug where we didn't allow an index name after the `FOREIGN
  43087.      KEY' definition.
  43088.  
  43089.    * Added `TRUNCATE table_name' as a synonym for `DELETE FROM
  43090.      table_name'.
  43091.  
  43092.    * Fixed a bug in a BDB key compare function when comparing part keys.
  43093.  
  43094.    * Added variable `bdb_lock_max' to `mysqld'.
  43095.  
  43096.    * Added more tests to the benchmark suite.
  43097.  
  43098.    * Fixed an overflow bug in the client code when using overly long
  43099.      database names.
  43100.  
  43101.    * `mysql_connect()' now aborts on Linux if the server doesn't answer
  43102.      in `timeout' seconds.
  43103.  
  43104.    * `SLAVE START' did not work if you started with
  43105.      `--skip-slave-start' and had not explicitly run `CHANGE MASTER TO'.
  43106.  
  43107.    * Fixed the output of `SHOW MASTER STATUS' to be consistent with
  43108.      `SHOW SLAVE STATUS'. (It now has no directory in the log name.)
  43109.  
  43110.    * Added `PURGE MASTER LOGS TO'.
  43111.  
  43112.    * Added `SHOW MASTER LOGS'.
  43113.  
  43114.    * Added `--safemalloc-mem-limit' option to `mysqld' to simulate
  43115.      memory shortage when compiled `--with-debug=full'.
  43116.  
  43117.    * Fixed several coredumps in out-of-memory conditions.
  43118.  
  43119.    * `SHOW SLAVE STATUS' was using an uninitialized mutex if the slave
  43120.      had not been started yet.
  43121.  
  43122.    * Fixed bug in `ELT()' and `MAKE_SET()' when the query used a
  43123.      temporary table.
  43124.  
  43125.    * `CHANGE MASTER TO' without specifying `MASTER_LOG_POS' would set
  43126.      it to 0 instead of 4 and hit the magic number in the master binlog.
  43127.  
  43128.    * `ALTER TABLE ... ORDER BY ...' syntax added.  This will create the
  43129.      new table with the rows in a specific order.
  43130.  
  43131. 
  43132. File: mysql.info,  Node: News-3.23.27,  Next: News-3.23.26,  Prev: News-3.23.28,  Up: News-3.23.x
  43133.  
  43134. Changes in release 3.23.27
  43135. --------------------------
  43136.  
  43137.    * Fixed a bug where the automatic repair of MyISAM tables sometimes
  43138.      failed when the data file was corrupt.
  43139.  
  43140.    * Fixed a bug in `SHOW CREATE' when using `AUTO_INCREMENT' columns.
  43141.  
  43142.    * Changed BDB tables to use new compare function in Berkeley DB
  43143.      3.2.3.
  43144.  
  43145.    * You can now use Unix sockets with `mit-pthreads'.
  43146.  
  43147.    * Added the latin5 (turkish) character set.
  43148.  
  43149.    * Small portability fixes.
  43150.  
  43151. 
  43152. File: mysql.info,  Node: News-3.23.26,  Next: News-3.23.25,  Prev: News-3.23.27,  Up: News-3.23.x
  43153.  
  43154. Changes in release 3.23.26
  43155. --------------------------
  43156.  
  43157.    * Fixed `<>' to work properly with `NULL'.
  43158.  
  43159.    * Fixed a problem with `SUBSTRING_INDEX()' and `REPLACE()'.  (Patch
  43160.      by Alexander Igonitchev)
  43161.  
  43162.    * Fix `CREATE TEMPORARY TABLE IF NOT EXISTS' not to give an error if
  43163.      the table exists.
  43164.  
  43165.    * If you don't create a `PRIMARY KEY' in a BDB table, a hidden
  43166.      `PRIMARY KEY' will be created.
  43167.  
  43168.    * Added read-only-key optimization to BDB tables.
  43169.  
  43170.    * `LEFT JOIN' in some cases preferred a full table scan when there
  43171.      was no `WHERE' clause.
  43172.  
  43173.    * When using `--log-slow-queries', don't count the time waiting for
  43174.      a lock.
  43175.  
  43176.    * Fixed bug in lock code on Windows which could cause the key cache
  43177.      to report that the key file was crashed even if it was okay.
  43178.  
  43179.    * Automatic repair of `MyISAM' tables if you start `mysqld' with
  43180.      `--myisam-recover'.
  43181.  
  43182.    * Removed the `TYPE=' keyword from `CHECK' and `REPAIR'. Allow
  43183.      `CHECK' options to be combined. (You can still use `TYPE=' but
  43184.      this usage is deprecated.)
  43185.  
  43186.    * Fixed mutex bug in the binary replication log - long update
  43187.      queries could be read only in part by the slave if it did it at
  43188.      the wrong time, which was not fatal, but resulted in a
  43189.      performance-degrading reconnect and a scary message in the error
  43190.      log.
  43191.  
  43192.    * Changed the format of the binary log - added magic number, server
  43193.      version, binlog version. Added server id and query error code for
  43194.      each query event.
  43195.  
  43196.    * Replication thread from the slave now will kill all the stale
  43197.      threads from the same server.
  43198.  
  43199.    * Long replication user names were not being handled properly.
  43200.  
  43201.    * Added `--replicate-rewrite-db' option to `mysqld'.
  43202.  
  43203.    * Added `--skip-slave-start' option to `mysqld'.
  43204.  
  43205.    * Updates that generated an error code (such as `INSERT INTO
  43206.      foo(some_key) values (1),(1)') erroneously terminated the slave
  43207.      thread.
  43208.  
  43209.    * Added optimization of queries where `DISTINCT' is only used on
  43210.      columns from some of the tables.
  43211.  
  43212.    * Allow floating-point numbers where there is no sign after the
  43213.      exponent (like 1e1).
  43214.  
  43215.    * `SHOW GRANTS' didn't always show all column grants.
  43216.  
  43217.    * Added `--default-extra-file=#' to all MySQL clients.
  43218.  
  43219.    * Columns referenced in `INSERT' statements now are initialized
  43220.      properly.
  43221.  
  43222.    * `UPDATE' didn't always work when used with a range on a timestamp
  43223.      that was part of the key that was used to find rows.
  43224.  
  43225.    * Fixed a bug in `FULLTEXT' index when inserting a `NULL' column.
  43226.  
  43227.    * Changed to use `mkstemp()' instead of `tempnam()'. Based on a
  43228.      patch from John Jones.
  43229.  
  43230. 
  43231. File: mysql.info,  Node: News-3.23.25,  Next: News-3.23.24,  Prev: News-3.23.26,  Up: News-3.23.x
  43232.  
  43233. Changes in release 3.23.25
  43234. --------------------------
  43235.  
  43236.    * Fixed that `databasename' works as second argument to
  43237.      `mysqlhotcopy'.
  43238.  
  43239.    * `UMASK' and `UMASK_DIR' can now be specified in octal.
  43240.  
  43241.    * Added `RIGHT JOIN'. This makes `RIGHT' a reserved word.
  43242.  
  43243.    * Added `@@IDENTITY' as a synonym for `LAST_INSERT_ID()'.  (This is
  43244.      for Visual Basic compatibility.)
  43245.  
  43246.    * Fixed a bug in `myisamchk' and `REPAIR' when using `FULLTEXT'
  43247.      index.
  43248.  
  43249.    * `LOAD DATA INFILE' now works with FIFOs.  (Patch by Toni L.
  43250.      Harbaugh-Blackford.)
  43251.  
  43252.    * `FLUSH LOGS' broke replication if you specified a log name with an
  43253.      explicit extension as the value of the `log-bin' option.
  43254.  
  43255.    * Fixed a bug in `MyISAM' with packed multi-part keys.
  43256.  
  43257.    * Fixed crash when using `CHECK TABLE' on Windows.
  43258.  
  43259.    * Fixed a bug where `FULLTEXT' index always used the koi8_ukr
  43260.      character set.
  43261.  
  43262.    * Fixed privilege checking for `CHECK TABLE'.
  43263.  
  43264.    * The `MyISAM' repair/reindex code didn't use the `--tempdir' option
  43265.      for its temporary files.
  43266.  
  43267.    * Added `BACKUP TABLE/RESTORE TABLE'.
  43268.  
  43269.    * Fixed coredump on `CHANGE MASTER TO' when the slave did not have
  43270.      the master to start with.
  43271.  
  43272.    * Fixed incorrect `Time' in the processlist for `Connect' of the
  43273.      slave thread.
  43274.  
  43275.    * The slave now logs when it connects to the master.
  43276.  
  43277.    * Fixed a core dump bug when doing `FLUSH MASTER' if you didn't
  43278.      specify a filename argument to `--log-bin'.
  43279.  
  43280.    * Added missing `ha_berkeley.x' files to the MySQL Windows
  43281.  
  43282.    * Fixed some mutex bugs in the log code that could cause thread
  43283.      blocks if new log files couldn't be created.
  43284.  
  43285.    * Added lock time and number of selected processed rows to slow
  43286.      query log.
  43287.  
  43288.    * Added `--memlock' option to `mysqld' to lock `mysqld' in memory on
  43289.      systems with the `mlockall()' call (like in Solaris).
  43290.  
  43291.    * `HEAP' tables didn't use keys properly. (Bug from 3.23.23.)
  43292.  
  43293.    * Added better support for `MERGE' tables (keys, mapping, creation,
  43294.      documentation...). *Note MERGE::.
  43295.  
  43296.    * Fixed bug in `mysqldump' from 3.23 which caused some `CHAR' columns
  43297.      not to be quoted.
  43298.  
  43299.    * Merged `analyze', `check', `optimize' and repair code.
  43300.  
  43301.    * `OPTIMIZE TABLE' is now mapped to `REPAIR' with statistics and
  43302.      sorting of the index tree.  This means that for the moment it only
  43303.      works on `MyISAM' tables.
  43304.  
  43305.    * Added a pre-alloced block to root_malloc to get fewer mallocs.
  43306.  
  43307.    * Added a lot of new statistics variables.
  43308.  
  43309.    * Fixed `ORDER BY' bug with BDB tables.
  43310.  
  43311.    * Removed warning that `mysqld' couldn't remove the `.pid' file
  43312.      under Windows.
  43313.  
  43314.    * Changed `--log-isam' to log *MyISAM* tables instead of isam tables.
  43315.  
  43316.    * Fixed `CHECK TABLE' to work on Windows.
  43317.  
  43318.    * Added file mutexes to make `pwrite()' safe on Windows.
  43319.  
  43320. 
  43321. File: mysql.info,  Node: News-3.23.24,  Next: News-3.23.23,  Prev: News-3.23.25,  Up: News-3.23.x
  43322.  
  43323. Changes in release 3.23.24
  43324. --------------------------
  43325.  
  43326.    * Added `mysqld' variable `created_tmp_disk_tables'.
  43327.  
  43328.    * To make it possible to reliably dump and restore tables with
  43329.      `TIMESTAMP(X)' columns, MySQL now reports columns with `X' other
  43330.      than 14 or 8 to be strings.
  43331.  
  43332.    * Changed sort order for latin1 as it was before MySQL Version
  43333.      3.23.23.  Any table with `CHAR' columns that may have characters
  43334.      with ASCII values greater than 128 that was created or modified
  43335.      with 3.23.22 must be repaired!
  43336.  
  43337.    * Fixed small memory leak introduced from 3.23.22 when creating a
  43338.      temporary table.
  43339.  
  43340.    * Fixed problem with BDB tables and reading on a unique (not
  43341.      primary) key.
  43342.  
  43343.    * Restored the win1251 character set (it's now only marked
  43344.      deprecated).
  43345.  
  43346. 
  43347. File: mysql.info,  Node: News-3.23.23,  Next: News-3.23.22,  Prev: News-3.23.24,  Up: News-3.23.x
  43348.  
  43349. Changes in release 3.23.23
  43350. --------------------------
  43351.  
  43352.    * Changed sort order for 'German';  All tables created with 'German'
  43353.      sortorder must be repaired with `REPAIR TABLE' or `myisamchk'
  43354.      before use!
  43355.  
  43356.    * Added option `--core-file' to `mysqld' to get a core file on Linux
  43357.      if `mysqld' dies on the SIGSEGV signal.
  43358.  
  43359.    * MySQL client `mysql' now starts with option `--no-named-commands'
  43360.      (`-g') by default. This option can be disabled with
  43361.      `--enable-named-commands' (`-G'). This may cause incompatibility
  43362.      problems in some cases, for example, in SQL scripts that use named
  43363.      commands without a semicolon, etc. !  Long format commands still
  43364.      work from the first line.
  43365.  
  43366.    * Fixed a problem when using many pending `DROP TABLE' statements at
  43367.      the same time.
  43368.  
  43369.    * Optimizer didn't use keys properly when using `LEFT JOIN' on an
  43370.      empty table.
  43371.  
  43372.    * Added shorter help text when invoking `mysqld' with incorrect
  43373.      options.
  43374.  
  43375.    * Fixed non-fatal `free()' bug in `mysqlimport'.
  43376.  
  43377.    * Fixed bug in `MyISAM' index handling of `DECIMAL'/`NUMERIC' keys.
  43378.  
  43379.    * Fixed a bug in concurrent insert in `MyISAM' tables; In some
  43380.      contexts, usage of `MIN(key_part)' or `MAX(key_part)' returned an
  43381.      empty set.
  43382.  
  43383.    * Updated `mysqlhotcopy' to use the new `FLUSH TABLES table_list'
  43384.      syntax. Only tables which are being backed up are flushed now.
  43385.  
  43386.    * Changed behavior of `--enable-thread-safe-client' so that both
  43387.      non-threaded (`-lmysqlclient') and threaded (`-lmysqlclient_r')
  43388.      libraries are built.  Users who linked against a threaded
  43389.      `-lmysqlclient' will need to link against `libmysqlclient_r' now.
  43390.  
  43391.    * Added atomic `RENAME' command.
  43392.  
  43393.    * Don't count entries with `NULL' in `COUNT(DISTINCT ...)'.
  43394.  
  43395.    * Changed `ALTER TABLE', `LOAD DATA INFILE' on empty tables and
  43396.      `INSERT ... SELECT ...' on empty tables to create non-unique
  43397.      indexes in a separate batch with sorting. This will make the above
  43398.      calls much faster when you have many indexes.
  43399.  
  43400.    * `ALTER TABLE' now logs the first used insert_id correctly.
  43401.  
  43402.    * Fixed crash when adding a default value to a `BLOB' column.
  43403.  
  43404.    * Fixed a bug with `DATE_ADD/DATE_SUB' where it returned a datetime
  43405.      instead of a date.
  43406.  
  43407.    * Fixed a problem with the thread cache which made some threads show
  43408.      up as `***DEAD***' in `SHOW PROCESSLIST'.
  43409.  
  43410.    * Fixed a lock in our thr_rwlock code, which could make selects that
  43411.      run at the same time as concurrent inserts crash. This only
  43412.      affects systems that don't have the `pthread_rwlock_rdlock' code.
  43413.  
  43414.    * When deleting rows with a non-unique key in a HEAP table, all rows
  43415.      weren't always deleted.
  43416.  
  43417.    * Fixed bug in range optimizer for HEAP tables for searches on a
  43418.      part index.
  43419.  
  43420.    * Fixed that `SELECT' on part keys works with BDB tables.
  43421.  
  43422.    * Fixed `INSERT INTO bdb_table ... SELECT' to work with BDB tables.
  43423.  
  43424.    * `CHECK TABLE' now updates key statistics for the table.
  43425.  
  43426.    * `ANALYZE TABLE' will now only update tables that have been changed
  43427.      since thee last `ANALYZE'. Note that this is a new feature and
  43428.      tables will not be marked to be analyzed until they are updated in
  43429.      any way with 3.23.23 or newer.  For older tables, you have to do
  43430.      `CHECK TABLE' to update the key distribution.
  43431.  
  43432.    * Fixed some minor privilege problems with `CHECK', `ANALYZE',
  43433.      `REPAIR' and `SHOW CREATE' commands.
  43434.  
  43435.    * Added `CHANGE MASTER TO' command.
  43436.  
  43437.    * Added `FAST', `QUICK' `EXTENDED' check types to `CHECK TABLES'.
  43438.  
  43439.    * Changed `myisamchk' so that `--fast' and `--check-changed-tables'
  43440.      are also honored with `--sort-index' and `--analyze'.
  43441.  
  43442.    * Fixed fatal bug in `LOAD TABLE FROM MASTER' that did not lock the
  43443.      table during index re-build.
  43444.  
  43445.    * `LOAD DATA INFILE' broke replication if the database was excluded
  43446.      from replication.
  43447.  
  43448.    * More variables in `SHOW SLAVE STATUS' and `SHOW MASTER STATUS'.
  43449.  
  43450.    * `SLAVE STOP' now will not return until the slave thread actually
  43451.      exits.
  43452.  
  43453.    * Full text search via the `MATCH' function and `FULLTEXT' index
  43454.      type.  (For MyISAM files).  This makes `FULLTEXT' a reserved word.
  43455.  
  43456. 
  43457. File: mysql.info,  Node: News-3.23.22,  Next: News-3.23.21,  Prev: News-3.23.23,  Up: News-3.23.x
  43458.  
  43459. Changes in release 3.23.22
  43460. --------------------------
  43461.  
  43462.    * Fixed that `lex_hash.h' is created properly for each MySQL
  43463.      distribution.
  43464.  
  43465.    * Fixed that `MASTER' and `COLLECTION' are not reserved words.
  43466.  
  43467.    * The log generated by `--slow-query-log' didn't contain the whole
  43468.      queries.
  43469.  
  43470.    * Fixed that open transactions in BDB tables are rolled back if the
  43471.      connection is closed unexpectedly.
  43472.  
  43473.    * Added workaround for a bug in `gcc' 2.96 (intel) and `gcc' 2.9
  43474.      (Ia64) in `gen_lex_hash.c'.
  43475.  
  43476.    * Fixed memory leak in the client library when using `host=' in the
  43477.      `my.cnf' file.
  43478.  
  43479.    * Optimized functions that manipulate the hours/minutes/seconds.
  43480.  
  43481.    * Fixed bug when comparing the result of `DATE_ADD()'/`DATE_SUB()'
  43482.      against a number.
  43483.  
  43484.    * Changed the meaning of `-F, --fast' for `myisamchk'. Added option
  43485.      `-C, --check-only-changed' to `myisamchk'.
  43486.  
  43487.    * Added `ANALYZE table_name' to update key statistics for tables.
  43488.  
  43489.    * Changed binary items `0x...' to be regarded as integers by default.
  43490.  
  43491.    * Fix for SCO and `SHOW PROCESSLIST'.
  43492.  
  43493.    * Added `auto-rehash' on reconnect for the `mysql' client.
  43494.  
  43495.    * Fixed a newly introduced bug in `MyISAM', where the index file
  43496.      couldn't get bigger than 64M.
  43497.  
  43498.    * Added `SHOW MASTER STATUS' and `SHOW SLAVE STATUS'.
  43499.  
  43500. 
  43501. File: mysql.info,  Node: News-3.23.21,  Next: News-3.23.20,  Prev: News-3.23.22,  Up: News-3.23.x
  43502.  
  43503. Changes in release 3.23.21
  43504. --------------------------
  43505.  
  43506.    * Added `mysql_character_set_name(MYSQL *mysql)' function to the
  43507.      MySQL C API.
  43508.  
  43509.    * Made the update log `ASCII 0' safe.
  43510.  
  43511.    * Added the `mysql_config' script.
  43512.  
  43513.    * Fixed problem when using `<' or `>' with a char column that was
  43514.      only partly indexed.
  43515.  
  43516.    * One would get a core dump if the log file was not readable by the
  43517.      MySQL user.
  43518.  
  43519.    * Changed `mysqladmin' to use the `CREATE DATABASE'/`DROP DATABASE'
  43520.      commands instead of the old deprecated API calls.
  43521.  
  43522.    * Fixed `chown' warning in `safe_mysqld'.
  43523.  
  43524.    * Fixed a bug in `ORDER BY' that was introduced in 3.23.19.
  43525.  
  43526.    * Only optimize the `DELETE FROM tbl_name' to do a drop+create of
  43527.      the table if we are in `AUTOCOMMIT' mode.  (Needed for BDB tables).
  43528.  
  43529.    * Added extra checks to avoid index corruption when the
  43530.      `ISAM'/`MyISAM' index files gets full during an `INSERT'/`UPDATE'.
  43531.  
  43532.    * `myisamchk' didn't correctly update row checksum when used with
  43533.      `-ro' (This only gave an warning in subsequent runs).
  43534.  
  43535.    * Fixed bug in `REPAIR TABLE' so that it works with tables without
  43536.      indexes.
  43537.  
  43538.    * Fixed buffer overrun in `DROP DATABASE'
  43539.  
  43540.    * `LOAD TABLE FROM MASTER' is sufficiently bug-free to announce it as
  43541.      a feature.
  43542.  
  43543.    * `MATCH' and `AGAINST' are now reserved words.
  43544.  
  43545. 
  43546. File: mysql.info,  Node: News-3.23.20,  Next: News-3.23.19,  Prev: News-3.23.21,  Up: News-3.23.x
  43547.  
  43548. Changes in release 3.23.20
  43549. --------------------------
  43550.  
  43551.    * Fixed bug in 3.23.19; `DELETE FROM tbl_name' removed the .frm file.
  43552.  
  43553.    * Added `SHOW CREATE TABLE'.
  43554.  
  43555. 
  43556. File: mysql.info,  Node: News-3.23.19,  Next: News-3.23.18,  Prev: News-3.23.20,  Up: News-3.23.x
  43557.  
  43558. Changes in release 3.23.19
  43559. --------------------------
  43560.  
  43561.    * Changed copyright for all files to GPL for the server code and
  43562.      utilities and LGPL for the client libraries.
  43563.  
  43564.    * Fixed bug where all rows matching weren't updated on a `MyISAM'
  43565.      table when doing update based on key on a table with many keys and
  43566.      some key changed values.
  43567.  
  43568.    * The Linux MySQL RPM's and binaries are now statically linked with
  43569.      a linuxthread version that has faster mutex handling when used with
  43570.      MySQL.
  43571.  
  43572.    * `ORDER BY' can now uses `REF' keys to find subset the rows that
  43573.      needs to be sorted.
  43574.  
  43575.    * Changed name of `print_defaults' to `my_print_defaults' to avoid
  43576.      name confusion.
  43577.  
  43578.    * Fixed `NULLIF()' to work according to ANSI SQL99.
  43579.  
  43580.    * Added `net_read_timeout' and `net_write_timeout' as startup
  43581.      parameters to `mysqld'.
  43582.  
  43583.    * Fixed bug that destroyed index when doing `myisamchk
  43584.      --sort-records' on a table with prefix compressed index.
  43585.  
  43586.    * Added pack_isam and myisampack to the standard MySQL distribution.
  43587.  
  43588.    * Added the syntax `BEGIN WORK' (the same as `BEGIN').
  43589.  
  43590.    * Fixed core dump bug when using `ORDER BY' on a `CONV()' expression.
  43591.  
  43592.    * Added `LOAD TABLE FROM MASTER'
  43593.  
  43594.    * Added `FLUSH MASTER' and `FLUSH SLAVE'
  43595.  
  43596.    * Fixed big/little endian problem in the replication
  43597.  
  43598. 
  43599. File: mysql.info,  Node: News-3.23.18,  Next: News-3.23.17,  Prev: News-3.23.19,  Up: News-3.23.x
  43600.  
  43601. Changes in release 3.23.18
  43602. --------------------------
  43603.  
  43604.    * Fixed a problem from 3.23.17 when choosing character set on the
  43605.      client side.
  43606.  
  43607.    * Added `FLUSH TABLES WITH READ LOCK' to make a global lock suitable
  43608.      to make a copy of MySQL data files.
  43609.  
  43610.    * `CREATE TABLE ... SELECT ... PROCEDURE' now works.
  43611.  
  43612.    * Internal temporary tables will now uses compressed index when using
  43613.      `GROUP BY' on `VARCHAR/CHAR' columns.
  43614.  
  43615.    * Fixed a problem when locking the same table with both a `READ' and
  43616.      a `WRITE' lock.
  43617.  
  43618.    * Fixed problem with myisamchk and `RAID' tables.
  43619.  
  43620. 
  43621. File: mysql.info,  Node: News-3.23.17,  Next: News-3.23.16,  Prev: News-3.23.18,  Up: News-3.23.x
  43622.  
  43623. Changes in release 3.23.17
  43624. --------------------------
  43625.  
  43626.    * Fixed a bug in `find_in_set()' when the first argument was `NULL'.
  43627.  
  43628.    * Added table locks to Berkeley DB.
  43629.  
  43630.    * Fixed a bug with `LEFT JOIN' and `ORDER BY' where the first table
  43631.      had only one matching row.
  43632.  
  43633.    * Added 4 sample `my.cnf' example files in the `support-files'
  43634.      directory.
  43635.  
  43636.    * Fixed `duplicated key' problem when doing big `GROUP BY''s.  (This
  43637.      bug was probably introduced in 3.23.15).
  43638.  
  43639.    * Changed syntax for `INNER JOIN' to match ANSI SQL.
  43640.  
  43641.    * Added `NATURAL JOIN' syntax.
  43642.  
  43643.    * A lot of fixes in the `BDB' interface.
  43644.  
  43645.    * Added handling of `--no-defaults' and `--defaults-file' to
  43646.      `safe_mysqld.sh' and `mysql_install_db.sh'.
  43647.  
  43648.    * Fixed bug in reading compressed tables with many threads.
  43649.  
  43650.    * Fixed that `USE INDEX' works with `PRIMARY' keys.
  43651.  
  43652.    * Added `BEGIN' statement to start a transaction in `AUTOCOMMIT'
  43653.      mode.
  43654.  
  43655.    * Added symbolic links support for Windows.
  43656.  
  43657.    * Changed protocol to let client know if the server is in AUTOCOMMIT
  43658.      mode and if there is a pending transaction.  If there is a pending
  43659.      transaction the client library will give an error before
  43660.      reconnecting to the server to let the client know that the server
  43661.      did a rollback.  The protocol is still backward compatible with
  43662.      old clients
  43663.  
  43664.    * `KILL' now works on a thread that is locked on a 'write' to a dead
  43665.      client.
  43666.  
  43667.    * Fixed memory leak in the replication slave thread.
  43668.  
  43669.    * Added new option `log-slave-updates' to allow daisy-chaining the
  43670.      slaves.
  43671.  
  43672.    * Fixed compile error on FreeBSD and other systems where `pthread_t'
  43673.      is not the same as `int'.
  43674.  
  43675.    * Fixed master shutdown aborting the slave thread.
  43676.  
  43677.    * Fixed a race condition in `INSERT DELAYED' code when doing `ALTER
  43678.      TABLE'.
  43679.  
  43680.    * Added deadlock detection sanity checks to `INSERT DELAYED'
  43681.  
  43682. 
  43683. File: mysql.info,  Node: News-3.23.16,  Next: News-3.23.15,  Prev: News-3.23.17,  Up: News-3.23.x
  43684.  
  43685. Changes in release 3.23.16
  43686. --------------------------
  43687.  
  43688.    * Added option `TYPE=QUICK' to `CHECK' and `REPAIR'.
  43689.  
  43690.    * Fixed bug in `REPAIR TABLE' when the table was in use by other
  43691.      threads.
  43692.  
  43693.    * Added a thread cache to make it possible to debug MySQL with `gdb'
  43694.      when one does a lot of reconnects. This will also improve systems
  43695.      where you can't use persistent connections.
  43696.  
  43697.    * Lots of fixes in the Berkeley DB interface.
  43698.  
  43699.    * `UPDATE IGNORE' will not abort if an update results in a
  43700.      `DUPLICATE_KEY' error.
  43701.  
  43702.    * Put `CREATE TEMPORARY TABLE' commands in the update log.
  43703.  
  43704.    * Fixed bug in handling of masked IP numbers in the privilege tables.
  43705.  
  43706.    * Fixed bug with `delayed_key_writes' tables and `CHECK TABLE'.
  43707.  
  43708.    * Added `replicate-do-db' and `replicate-ignore-db' options to
  43709.      restrict which databases get replicated
  43710.  
  43711.    * Added `SQL_LOG_BIN' option
  43712.  
  43713. 
  43714. File: mysql.info,  Node: News-3.23.15,  Next: News-3.23.14,  Prev: News-3.23.16,  Up: News-3.23.x
  43715.  
  43716. Changes in release 3.23.15
  43717. --------------------------
  43718.  
  43719.    * To start `mysqld' as `root', you must now use the `--user=root'
  43720.      option.
  43721.  
  43722.    * Added interface to Berkeley DB. (This is not yet functional;  Play
  43723.      with it at your own risk!)
  43724.  
  43725.    * Replication between master and slaves.
  43726.  
  43727.    * Fixed bug that other threads could steal a lock when a thread had
  43728.      a lock on a table and did a `FLUSH TABLES' command.
  43729.  
  43730.    * Added the `slow_launch_time' variable and the `Slow_launch_threads'
  43731.      status variable to `mysqld'.  These can be examined with
  43732.      `mysqladmin variables' and `mysqladmin extended-status'.
  43733.  
  43734.    * Added functions `INET_NTOA()' and `INET_ATON()'.
  43735.  
  43736.    * The default type of `IF()' now depends on the second and third
  43737.      arguments and not only on the second argument.
  43738.  
  43739.    * Fixed case when `myisamchk' could go into a loop when trying to
  43740.      repair a crashed table.
  43741.  
  43742.    * Don't write `INSERT DELAYED' to update log if `SQL_LOG_UPDATE=0'.
  43743.  
  43744.    * Fixed problem with `REPLACE' on `HEAP' tables.
  43745.  
  43746.    * Added possible character sets and time zone to `SHOW VARIABLES'.
  43747.  
  43748.    * Fixed bug in locking code that could result it locking problems
  43749.      with concurrent inserts under high load.
  43750.  
  43751.    * Fixed a problem with `DELETE' of many rows on a table with
  43752.      compressed keys where MySQL scanned the index to find the rows.
  43753.  
  43754.    * Fixed problem with `CHECK' on table with deleted keyblocks.
  43755.  
  43756.    * Fixed a bug in reconnect (at the client side) where it didn't free
  43757.      memory properly in some contexts.
  43758.  
  43759.    * Fixed problems in update log when using `LAST_INSERT_ID()' to
  43760.      update a table with an auto_increment key.
  43761.  
  43762.    * Added function `NULLIF()'.
  43763.  
  43764.    * Fixed bug when using `LOAD DATA INFILE' on a table with
  43765.      `BLOB/TEXT' columns.
  43766.  
  43767.    * Optimised MyISAM to be faster when inserting keys in sorted order.
  43768.  
  43769.    * `EXPLAIN SELECT ...' now also prints out whether MySQL needs to
  43770.      create a temporary table or use file sorting when resolving the
  43771.      `SELECT'.
  43772.  
  43773.    * Added optimization to skip `ORDER BY' parts where the part is a
  43774.      constant expression in the `WHERE' part.  Indexes can now be used
  43775.      even if the `ORDER BY' doesn't match the index exactly, as long as
  43776.      all the not used index parts and all the extra `ORDER BY' columns
  43777.      are constants in the `WHERE' clause.  *Note MySQL indexes::.
  43778.  
  43779.    * `UPDATE' and `DELETE' on a whole unique key in the `WHERE' part,
  43780.      is now faster than before.
  43781.  
  43782.    * Changed `RAID_CHUNKSIZE' to be in 1024 byte increments.
  43783.  
  43784.    * Fixed coredump in LOAD_FILE(NULL).
  43785.  
  43786. 
  43787. File: mysql.info,  Node: News-3.23.14,  Next: News-3.23.13,  Prev: News-3.23.15,  Up: News-3.23.x
  43788.  
  43789. Changes in release 3.23.14
  43790. --------------------------
  43791.  
  43792.    * Fixed a bug in `CONCAT()' where one of the arguments was a function
  43793.      that returned a modified argument.
  43794.  
  43795.    * Fixed a critical bug in `myisamchk', where it updated the header in
  43796.      the index file when one only checked the table.  This confused the
  43797.      `mysqld' daemon if it updated the same table at the same time. Now
  43798.      the status in the index file is only updated if one uses
  43799.      `--update-state'.  With older `myisamchk' versions you should use
  43800.      `--read-only' when only checking tables, if there is the slightest
  43801.      chance that the `mysqld' server is working on the table at the
  43802.      same time!
  43803.  
  43804.    * Fixed that `DROP TABLE' is logged in the update log.
  43805.  
  43806.    * Fixed problem when searching on `DECIMAL()' key field where the
  43807.      column data contained leading zeros.
  43808.  
  43809.    * Fix bug in `myisamchk' when the auto_increment isn't the first key.
  43810.  
  43811.    * Allow `DATETIME' in ISO8601 format: 2000-03-12T12:00:00
  43812.  
  43813.    * Dynamic character sets.  A `mysqld' binary can now handle many
  43814.      different character sets (you can choose which when starting
  43815.      `mysqld').
  43816.  
  43817.    * Added command `REPAIR TABLE'.
  43818.  
  43819.    * Added C API function `mysql_thread_safe()'.
  43820.  
  43821.    * Added the `UMASK_DIR' environment variable.
  43822.  
  43823.    * Added function `CONNECTION_ID()'.
  43824.  
  43825.    * When using `=' on `BLOB' or `VARCHAR BINARY' keys, where only a
  43826.      part of the column was indexed, the whole column of the result row
  43827.      wasn't compared.
  43828.  
  43829.    * Fix for sjis character set and `ORDER BY'.
  43830.  
  43831.    * When running in ANSI mode, don't allow columns to be used that
  43832.      aren't in the `GROUP BY' part.
  43833.  
  43834. 
  43835. File: mysql.info,  Node: News-3.23.13,  Next: News-3.23.12,  Prev: News-3.23.14,  Up: News-3.23.x
  43836.  
  43837. Changes in release 3.23.13
  43838. --------------------------
  43839.  
  43840.    * Fixed problem when doing locks on the same table more than 2 times
  43841.      in the same `LOCK TABLE' command; This fixed the problem one got
  43842.      when running the test-ATIS test with `--fast' or
  43843.      `--check-only-changed'.
  43844.  
  43845.    * Added option `SQL_BUFFER_RESULT' to `SELECT'.
  43846.  
  43847.    * Removed end space from double/float numbers in results from
  43848.      temporary tables.  Added `CHECK TABLE' command.
  43849.  
  43850.    * Added changes for MyISAM in 3.23.12 that didn't get into the source
  43851.      distribution because of CVS problems.
  43852.  
  43853.    * Fixed bug so that `mysqladmin shutdown' will wait for the local
  43854.      server to close down.
  43855.  
  43856.    * Fixed a possible endless loop when calculating timestamp.
  43857.  
  43858.    * Added `print_defaults' to the `.rpm' files. Removed `mysqlbug'
  43859.      from the client `.rpm' file.
  43860.  
  43861. 
  43862. File: mysql.info,  Node: News-3.23.12,  Next: News-3.23.11,  Prev: News-3.23.13,  Up: News-3.23.x
  43863.  
  43864. Changes in release 3.23.12
  43865. --------------------------
  43866.  
  43867.    * Fixed bug in `MyISAM' involving `REPLACE ... SELECT ...' which
  43868.      could give a corrupted table.
  43869.  
  43870.    * Fixed bug in `myisamchk' where it wrongly reset the auto_increment
  43871.      value.
  43872.  
  43873.    * LOTS of patches for Linux Alpha. MySQL now appears to be relatively
  43874.      stable on Alpha.
  43875.  
  43876.    * Changed `DISTINCT' on `HEAP' temporary tables to use hashed keys
  43877.      to quickly find duplicated rows. This mostly concerns queries of
  43878.      type `SELECT DISTINCT ... GROUP BY ...'.  This fixes a problem
  43879.      where not all duplicates were removed in queries of the above
  43880.      type.  In addition, the new code is MUCH faster.
  43881.  
  43882.    * Added patches to make MySQL compile on Mac OS X.
  43883.  
  43884.    * Added option `IF NOT EXISTS' to `CREATE DATABASE'.
  43885.  
  43886.    * Added options `--all-databases' and `--databases' to `mysqldump'
  43887.      to allow dumping of many databases at the same time.
  43888.  
  43889.    * Fixed bug in compressed `DECIMAL()' index in `MyISAM' tables.
  43890.  
  43891.    * Fixed bug when storing 0 into a timestamp.
  43892.  
  43893.    * When doing `mysqladmin shutdown' on a local connection,
  43894.      `mysqladmin' now waits until the pidfile is gone before
  43895.      terminating.
  43896.  
  43897.    * Fixed core dump with some `COUNT(DISTINCT ...)' queries.
  43898.  
  43899.    * Fixed that `myisamchk' works properly with RAID:ed tables.
  43900.  
  43901.    * Fixed problem with `LEFT JOIN' and `key_field IS NULL'.
  43902.  
  43903.    * Fixed bug in `net_clear()' which could give the error `Aborted
  43904.      connection' in the MySQL clients.
  43905.  
  43906.    * Added options `USE INDEX (key_list)' and `IGNORE INDEX (key_list)'
  43907.      as join parameters in `SELECT'.
  43908.  
  43909.    * `DELETE' and `RENAME' should now work on `RAID' tables.
  43910.  
  43911. 
  43912. File: mysql.info,  Node: News-3.23.11,  Next: News-3.23.10,  Prev: News-3.23.12,  Up: News-3.23.x
  43913.  
  43914. Changes in release 3.23.11
  43915. --------------------------
  43916.  
  43917.    * Allow the `ALTER TABLE tbl_name ADD (field_list)' syntax.
  43918.  
  43919.    * Fixed problem with optimizer that could sometimes use wrong keys.
  43920.  
  43921.    * Fixed that `GRANT/REVOKE ALL PRIVILEGES' doesn't affect `GRANT
  43922.      OPTION'.
  43923.  
  43924.    * Removed extra `)' from the output of `SHOW GRANTS'
  43925.  
  43926.    * Fixed problem when storing numbers in timestamps.
  43927.  
  43928.    * Fix problem with timezones that have half hour offsets.
  43929.  
  43930.    * Allow the syntax `UNIQUE INDEX' in `CREATE' statements.
  43931.  
  43932.    * `mysqlhotcopy' - fast on-line hot-backup utility for local MySQL
  43933.      databases. By Tim Bunce.
  43934.  
  43935.    * New more secure `mysqlaccess'. Thanks to Steve Harvey for this.
  43936.  
  43937.    * Added options `--i-am-a-dummy' and `--safe-updates' to `mysql'.
  43938.  
  43939.    * Added variables `select_limit' and `max_join_size' to `mysql'.
  43940.  
  43941.    * Added sql variables: `SQL_MAX_JOIN_SIZE' and `SQL_SAFE_UPDATES'.
  43942.  
  43943.    * Added `READ LOCAL' lock that doesn't lock the table for concurrent
  43944.      inserts. (This is used by `mysqldump').
  43945.  
  43946.    * Changed that `LOCK TABLES ... READ' doesn't anymore allow
  43947.      concurrent inserts.
  43948.  
  43949.    * Added option `--skip-delay-key-write' to `mysqld'.
  43950.  
  43951.    * Fixed security problem in the protocol regarding password checking.
  43952.  
  43953.    * `_rowid' can now be used as an alias for an integer type unique
  43954.      indexed column.
  43955.  
  43956.    * Added back blocking of `SIGPIPE' when compiling with
  43957.      `--thread-safe-clients' to make things safe for old clients.
  43958.  
  43959. 
  43960. File: mysql.info,  Node: News-3.23.10,  Next: News-3.23.9,  Prev: News-3.23.11,  Up: News-3.23.x
  43961.  
  43962. Changes in release 3.23.10
  43963. --------------------------
  43964.  
  43965.    * Fixed bug in 3.23.9 where memory wasn't properly freed when doing
  43966.      `LOCK TABLES'.
  43967.  
  43968. 
  43969. File: mysql.info,  Node: News-3.23.9,  Next: News-3.23.8,  Prev: News-3.23.10,  Up: News-3.23.x
  43970.  
  43971. Changes in release 3.23.9
  43972. -------------------------
  43973.  
  43974.    * Fixed problem that affected queries that did arithmetic on group
  43975.      functions.
  43976.  
  43977.    * Fixed problem with timestamps and `INSERT DELAYED'.
  43978.  
  43979.    * Fixed that `date_column BETWEEN const_date AND const_date' works.
  43980.  
  43981.    * Fixed problem when only changing a 0 to `NULL' in a table with
  43982.      `BLOB/TEXT' columns.
  43983.  
  43984.    * Fixed bug in range optimizer when using many key parts and or on
  43985.      the middle key parts:  `WHERE K1=1 and K3=2 and (K2=2 and K4=4 or
  43986.      K2=3 and K4=5)'
  43987.  
  43988.    * Added command `source' to `mysql' to allow reading of batch files
  43989.      inside the `mysql' client.  Original patch by Matthew Vanecek.
  43990.  
  43991.    * Fixed critical problem with the `WITH GRANT OPTION' option.
  43992.  
  43993.    * Don't give an unnecessary `GRANT' error when using tables from many
  43994.      databases in the same query.
  43995.  
  43996.    * Added VIO wrapper (needed for SSL support ; By Andrei Errapart and
  43997.      T⌡nu Samuel).
  43998.  
  43999.    * Fixed optimizer problem on `SELECT' when using many overlapping
  44000.      indexes.  MySQL should now be able to choose keys even better when
  44001.      there is many keys to choose from.
  44002.  
  44003.    * Changed optimizer to prefer a range key instead of a ref key when
  44004.      the range key can uses more columns than the ref key (which only
  44005.      can use columns with =).  For example, the following type of
  44006.      queries should now be faster: `SELECT * from key_part_1=const and
  44007.      key_part_2 > const2'
  44008.  
  44009.    * Fixed bug that a change of all `VARCHAR' columns to `CHAR' columns
  44010.      didn't change row type from dynamic to fixed.
  44011.  
  44012.    * Disabled floating-point exceptions for FreeBSD to fix core dump
  44013.      when doing `SELECT floor(pow(2,63))'.
  44014.  
  44015.    * Changed `mysqld' startup option `--delay-key-write' to
  44016.      `--delay-key-write-for-all-tables'
  44017.  
  44018.    * Added `read-next-on-key' to `HEAP' tables.  This should fix all
  44019.      problems with `HEAP' tables when using not `UNIQUE' keys.
  44020.  
  44021.    * Added print of default arguments options to all clients.
  44022.  
  44023.    * Added `--log-slow-queries' to `mysqld' to log all queries that
  44024.      take a long time to a separate log file with a time of how long
  44025.      the query took.
  44026.  
  44027.    * Fixed core dump when doing `WHERE key_column=RAND(...)'
  44028.  
  44029.    * Fixed optimization bug in `SELECT ... LEFT JOIN ... key_column IS
  44030.      NULL', when `key_column' could contain `NULL' values.
  44031.  
  44032.    * Fixed problem with 8-bit characters as separators in `LOAD DATA
  44033.      INFILE'.
  44034.  
  44035. 
  44036. File: mysql.info,  Node: News-3.23.8,  Next: News-3.23.7,  Prev: News-3.23.9,  Up: News-3.23.x
  44037.  
  44038. Changes in release 3.23.8
  44039. -------------------------
  44040.  
  44041.    * Fixed problem when handling indexfiles larger than 8G.
  44042.  
  44043.    * Added latest patches to mit-pthreads for NetBSD.
  44044.  
  44045.    * Fixed problem with timezones that are < GMT -11.
  44046.  
  44047.    * Fixed a bug when deleting packed keys in `NISAM'.
  44048.  
  44049.    * Fixed problem with `ISAM' when doing some `ORDER BY ... DESC'
  44050.      queries.
  44051.  
  44052.    * Fixed bug when doing a join on a text key which didn't cover the
  44053.      whole key.
  44054.  
  44055.    * Option `--delay-key-write' didn't enable delayed key writing.
  44056.  
  44057.    * Fixed update of `TEXT' column which only involved case changes.
  44058.  
  44059.    * Fixed that `INSERT DELAYED' doesn't update timestamps that are
  44060.      given.
  44061.  
  44062.    * Added function `YEARWEEK()' and options `x', `X', `v' and `V' to
  44063.      `DATE_FORMAT()'.
  44064.  
  44065.    * Fixed problem with `MAX(indexed_column)' and HEAP tables.
  44066.  
  44067.    * Fixed problem with `BLOB NULL' keys and `LIKE' "prefix%".
  44068.  
  44069.    * Fixed problem with `MyISAM' and fixed-length rows < 5 bytes.
  44070.  
  44071.    * Fixed problem that could cause MySQL to touch freed memory when
  44072.      doing very complicated `GROUP BY' queries.
  44073.  
  44074.    * Fixed core dump if you got a crashed table where an `ENUM' field
  44075.      value was too big.
  44076.  
  44077. 
  44078. File: mysql.info,  Node: News-3.23.7,  Next: News-3.23.6,  Prev: News-3.23.8,  Up: News-3.23.x
  44079.  
  44080. Changes in release 3.23.7
  44081. -------------------------
  44082.  
  44083.    * Fixed workaround under Linux to avoid problems with
  44084.      `pthread_mutex_timedwait', which is used with `INSERT DELAYED'.
  44085.      *Note Linux::.
  44086.  
  44087.    * Fixed that one will get a 'disk full' error message if one gets
  44088.      disk full when doing sorting (instead of waiting until we got more
  44089.      disk space).
  44090.  
  44091.    * Fixed a bug in `MyISAM' with keys > 250 characters.
  44092.  
  44093.    * In `MyISAM' one can now do an `INSERT' at the same time as other
  44094.      threads are reading from the table.
  44095.  
  44096.    * Added variable `max_write_lock_count' to `mysqld' to force a
  44097.      `READ' lock after a certain number of `WRITE' locks.
  44098.  
  44099.    * Inverted flag `delayed_key_write' on `show variables'.
  44100.  
  44101.    * Renamed variable `concurrency' to `thread_concurrency'.
  44102.  
  44103.    * The following functions are now multi-byte-safe:
  44104.      `LOCATE(substr,str)', `POSITION(substr IN str)',
  44105.      `LOCATE(substr,str,pos)', `INSTR(str,substr)', `LEFT(str,len)',
  44106.      `RIGHT(str,len)', `SUBSTRING(str,pos,len)', `SUBSTRING(str FROM
  44107.      pos FOR len)', `MID(str,pos,len)', `SUBSTRING(str,pos)',
  44108.      `SUBSTRING(str FROM pos)', `SUBSTRING_INDEX(str,delim,count)',
  44109.      `RTRIM(str)', `TRIM([[BOTH | TRAILING] [remstr] FROM] str)',
  44110.      `REPLACE(str,from_str,to_str)', `REVERSE(str)',
  44111.      `INSERT(str,pos,len,newstr)', `LCASE(str)', `LOWER(str)',
  44112.      `UCASE(str)' and `UPPER(str)';  Patch by Wei He.
  44113.  
  44114.    * Fix core dump when releasing a lock from a non-existent table.
  44115.  
  44116.    * Remove locks on tables before starting to remove duplicates.
  44117.  
  44118.    * Added option `FULL' to `SHOW PROCESSLIST'.
  44119.  
  44120.    * Added option `--verbose' to `mysqladmin'.
  44121.  
  44122.    * Fixed problem when automatically converting HEAP to MyISAM.
  44123.  
  44124.    * Fixed bug in HEAP tables when doing insert + delete + insert +
  44125.      scan the table.
  44126.  
  44127.    * Fixed bugs on Alpha with `REPLACE()' and `LOAD DATA INFILE'.
  44128.  
  44129.    * Added `mysqld' variable `interactive_timeout'.
  44130.  
  44131.    * Changed the argument to `mysql_data_seek()' from `ulong' to
  44132.      `ulonglong'.
  44133.  
  44134. 
  44135. File: mysql.info,  Node: News-3.23.6,  Next: News-3.23.5,  Prev: News-3.23.7,  Up: News-3.23.x
  44136.  
  44137. Changes in release 3.23.6
  44138. -------------------------
  44139.  
  44140.    * Added `mysqld' option `-O lower_case_table_names={0|1}' to allow
  44141.      users to force table names to lowercase.
  44142.  
  44143.    * Added `SELECT ... INTO DUMPFILE'.
  44144.  
  44145.    * Added `mysqld' option `--ansi' to make some functions `ANSI SQL'
  44146.      compatible.
  44147.  
  44148.    * Temporary tables now starts with `#sql'.
  44149.  
  44150.    * Added quoting of identifiers with ``' (`"' in `--ansi' mode).
  44151.  
  44152.    * Changed to use snprintf() when printing floats to avoid some buffer
  44153.      overflows on FreeBSD.
  44154.  
  44155.    * Made `[floor()' overflow safe on FreeBSD.
  44156.  
  44157.    * Added option `--quote-names' to `mysqldump'
  44158.  
  44159.    * Fixed bug that one could make a part of a `PRIMARY KEY NOT NULL'.
  44160.  
  44161.    * Fixed `encrypt()' to be thread safe and not reuse buffer.
  44162.  
  44163.    * Added `mysql_odbc_escape_string()' function to support big5
  44164.      characters in MyODBC.
  44165.  
  44166.    * Rewrote the table handler to use classes.  This introduces a lot
  44167.      of new code, but will make table handling faster and better.
  44168.  
  44169.    * Added patch by Sasha for user-defined variables.
  44170.  
  44171.    * Changed that `FLOAT' and `DOUBLE' (without any length modifiers)
  44172.      are not anymore fixed decimal point numbers.
  44173.  
  44174.    * Changed the meaning of `FLOAT(X)': Now this is the same as `FLOAT'
  44175.      if X <= 24 and a `DOUBLE' if 24 < X <= 53.
  44176.  
  44177.    * `DECIMAL(X)' is now an alias for `DECIMAL(X,0)' and `DECIMAL' is
  44178.      now an alias for `DECIMAL(10,0)'.  The same goes for `NUMERIC'.
  44179.  
  44180.    * Added option `ROW_FORMAT={default | dynamic | static |
  44181.      compressed}' to `CREATE_TABLE'.
  44182.  
  44183.    * `DELETE FROM table_name' didn't work on temporary tables.
  44184.  
  44185.    * Changed function `CHAR_LENGTH()' to be multi-byte character safe.
  44186.  
  44187.    * Added function `ORD(string)'.
  44188.  
  44189. 
  44190. File: mysql.info,  Node: News-3.23.5,  Next: News-3.23.4,  Prev: News-3.23.6,  Up: News-3.23.x
  44191.  
  44192. Changes in release 3.23.5
  44193. -------------------------
  44194.  
  44195.    * Fixed some Y2K problems in the new date handling in 3.23.
  44196.  
  44197.    * Fixed problem with `SELECT DISTINCT ... ORDER BY RAND()'.
  44198.  
  44199.    * Added patches by Sergei A. Golubchik for text searching on the
  44200.      MyISAM level.
  44201.  
  44202.    * Fixed cache overflow problem when using full joins without keys.
  44203.  
  44204.    * Fixed some configure issues.
  44205.  
  44206.    * Some small changes to make parsing faster.
  44207.  
  44208.    * `ALTER TABLE' + adding a column after the last field didn't work.
  44209.  
  44210.    * Fixed problem when using an auto_increment column in two keys
  44211.  
  44212.    * One can now with MyISAM have the auto_increment part as a sub part:
  44213.      `CREATE TABLE foo (a int not null auto_increment, b char(5),
  44214.      primary key (b,a))'
  44215.  
  44216.    * Fixed bug in MyISAM with packed char keys that could be `NULL'.
  44217.  
  44218.    * `AS' on fieldname with `CREATE TABLE table_name SELECT ...' didn't
  44219.      work.
  44220.  
  44221.    * Allow use of `NATIONAL' and `NCHAR' when defining character
  44222.      columns.  This is the same as not using `BINARY'.
  44223.  
  44224.    * Don't allow `NULL' columns in a `PRIMARY KEY' (only in `UNIQUE'
  44225.      keys).
  44226.  
  44227.    * Clear `LAST_INSERT_ID' if one uses this in ODBC: `WHERE
  44228.      auto_increment_column IS NULL'.  This seems to fix some problems
  44229.      with Access.
  44230.  
  44231.    * `SET SQL_AUTO_IS_NULL=0|1' now turns on/off the handling of
  44232.      searching after the last inserted row with `WHERE
  44233.      auto_increment_column IS NULL'.
  44234.  
  44235.    * Added new `mysqld' variable `concurrency' for Solaris.
  44236.  
  44237.    * Added option `--relative' to `mysqladmin' to make
  44238.      `extended-status' more useful to monitor changes.
  44239.  
  44240.    * Fixed bug when using `COUNT(DISTINCT ...)' on an empty table.
  44241.  
  44242.    * Added support for the Chinese character set GBK.
  44243.  
  44244.    * Fixed problem with `LOAD DATA INFILE' and `BLOB' columns.
  44245.  
  44246.    * Added bit operator `~' (negation).
  44247.  
  44248.    * Fixed problem with `UDF' functions.
  44249.  
  44250. 
  44251. File: mysql.info,  Node: News-3.23.4,  Next: News-3.23.3,  Prev: News-3.23.5,  Up: News-3.23.x
  44252.  
  44253. Changes in release 3.23.4
  44254. -------------------------
  44255.  
  44256.    * Inserting a `DATETIME' into a `TIME' column will not anymore try
  44257.      to store 'days' in it.
  44258.  
  44259.    * Fixed problem with storage of float/double on little endian
  44260.      machines.  (This affected `SUM()'.)
  44261.  
  44262.    * Added connect timeout on TCP/IP connections.
  44263.  
  44264.    * Fixed problem with `LIKE' "%" on an index that may have `NULL'
  44265.      values.
  44266.  
  44267.    * `REVOKE ALL PRIVILEGES' didn't revoke all privileges.
  44268.  
  44269.    * Allow creation of temporary tables with same name as the original
  44270.      table.
  44271.  
  44272.    * When granting a user a grant option for a database, he couldn't
  44273.      grant privileges to other users.
  44274.  
  44275.    * New command: `SHOW GRANTS FOR user' (by Sinisa).
  44276.  
  44277.    * New `date_add' syntax:  `date/datetime + INTERVAL # interval_type'.
  44278.      By Joshua Chamas.
  44279.  
  44280.    * Fixed privilege check for `LOAD DATA REPLACE'.
  44281.  
  44282.    * Automatic fixing of broken include files on Solaris 2.7
  44283.  
  44284.    * Some configure issues to fix problems with big file system
  44285.      detection.
  44286.  
  44287.    * `REGEXP' is now case insensitive if you use non-binary strings.
  44288.  
  44289. 
  44290. File: mysql.info,  Node: News-3.23.3,  Next: News-3.23.2,  Prev: News-3.23.4,  Up: News-3.23.x
  44291.  
  44292. Changes in release 3.23.3
  44293. -------------------------
  44294.  
  44295.    * Added patches for MIT-pthreads on NetBSD.
  44296.  
  44297.    * Fixed range bug in MyISAM.
  44298.  
  44299.    * `ASC' is now the default again for `ORDER BY'.
  44300.  
  44301.    * Added `LIMIT' to `UPDATE'.
  44302.  
  44303.    * New client function: `mysql_change_user()'.
  44304.  
  44305.    * Added character set to `SHOW VARIABLES'.
  44306.  
  44307.    * Added support of `--[whitespace]' comments.
  44308.  
  44309.    * Allow `INSERT into tbl_name VALUES ()', that is, you may now
  44310.      specify an empty value list to insert a row in which each column
  44311.      is set to its default value.
  44312.  
  44313.    * Changed `SUBSTRING(text FROM pos)' to conform to ANSI SQL. (Before
  44314.      this construct returned the rightmost 'pos' characters).
  44315.  
  44316.    * `SUM()' with `GROUP BY' returned 0 on some systems.
  44317.  
  44318.    * Changed output for `SHOW TABLE STATUS'.
  44319.  
  44320.    * Added `DELAY_KEY_WRITE' option to `CREATE TABLE'.
  44321.  
  44322.    * Allow `AUTO_INCREMENT' on any key part.
  44323.  
  44324.    * Fixed problem with `YEAR(NOW())' and `YEAR(CURDATE())'.
  44325.  
  44326.    * Added `CASE' construct.
  44327.  
  44328.    * New function `COALESCE()'.
  44329.  
  44330. 
  44331. File: mysql.info,  Node: News-3.23.2,  Next: News-3.23.1,  Prev: News-3.23.3,  Up: News-3.23.x
  44332.  
  44333. Changes in release 3.23.2
  44334. -------------------------
  44335.  
  44336.    * Fixed range optimizer bug: `SELECT * FROM table_name WHERE
  44337.      key_part1 >= const AND (key_part2 = const OR key_part2 = const)'.
  44338.      The bug was that some rows could be duplicated in the result.
  44339.  
  44340.    * Running `myisamchk' without `-a' updated the index distribution
  44341.      wrong.
  44342.  
  44343.    * `SET SQL_LOW_PRIORITY_UPDATES=1' gave parse error before.
  44344.  
  44345.    * You can now update indexes columns that are used in the `WHERE'
  44346.      clause.  `UPDATE tbl_name SET KEY=KEY+1 WHERE KEY > 100'
  44347.  
  44348.    * Date handling should now be a bit faster.
  44349.  
  44350.    * Added handling of fuzzy dates (dates where day or month is 0):
  44351.      (Like: 1999-01-00)
  44352.  
  44353.    * Fixed optimization of `SELECT ... WHERE key_part1=const1 AND
  44354.      key_part_2=const2 AND key_part1=const4 AND key_part2=const4' ;
  44355.      Indextype should be `range' instead of `ref'.
  44356.  
  44357.    * Fixed `egcs' 1.1.2 optimizer bug (when using `BLOB's) on Linux
  44358.      Alpha.
  44359.  
  44360.    * Fixed problem with `LOCK TABLES' combined with `DELETE FROM table'.
  44361.  
  44362.    * MyISAM tables now allow keys on `NULL' and `BLOB/TEXT' columns.
  44363.  
  44364.    * The following join is now much faster: `SELECT ... FROM t1 LEFT
  44365.      JOIN t2 ON ... WHERE t2.not_null_column IS NULL'.
  44366.  
  44367.    * `ORDER BY' and `GROUP BY' can be done on functions.
  44368.  
  44369.    * Changed handling of 'const_item' to allow handling of `ORDER BY
  44370.      RAND()'.
  44371.  
  44372.    * Indexes are now used for `WHERE key_column = function'.
  44373.  
  44374.    * Indexes are now used for `WHERE key_column = column_name' even if
  44375.      the columns are not identically packed.
  44376.  
  44377.    * Indexes are now used for `WHERE column_name IS NULL'.
  44378.  
  44379.    * Changed heap tables to be stored in low_byte_first order (to make
  44380.      it easy to convert to MyISAM tables)
  44381.  
  44382.    * Automatic change of HEAP temporary tables to MyISAM tables in case
  44383.      of 'table is full' errors.
  44384.  
  44385.    * Added option `--init-file=file_name' to `mysqld'.
  44386.  
  44387.    * `COUNT(DISTINCT value, [value, ...])'
  44388.  
  44389.    * `CREATE TEMPORARY TABLE' now creates a temporary table, in its own
  44390.      namespace, that is automatically deleted if connection is dropped.
  44391.  
  44392.    * New reserved words (required for `CASE'):  `CASE, THEN, WHEN, ELSE
  44393.      and END'.
  44394.  
  44395.    * New functions `EXPORT_SET()' and `MD5()'.
  44396.  
  44397.    * Support for the GB2312 Chinese character set.
  44398.  
  44399. 
  44400. File: mysql.info,  Node: News-3.23.1,  Next: News-3.23.0,  Prev: News-3.23.2,  Up: News-3.23.x
  44401.  
  44402. Changes in release 3.23.1
  44403. -------------------------
  44404.  
  44405.    * Fixed some compilation problems.
  44406.  
  44407. 
  44408. File: mysql.info,  Node: News-3.23.0,  Prev: News-3.23.1,  Up: News-3.23.x
  44409.  
  44410. Changes in release 3.23.0
  44411. -------------------------
  44412.  
  44413.    * A new table handler library (`MyISAM') with a lot of new features.
  44414.      *Note MyISAM::.
  44415.  
  44416.    * You can create in-memory `HEAP' tables which are extremely fast for
  44417.      lookups.
  44418.  
  44419.    * Support for big files (63 bit) on OSes that support big files.
  44420.  
  44421.    * New function `LOAD_FILE(filename)' to get the contents of a file
  44422.      as a string value.
  44423.  
  44424.    * New operator `<=>' which will act as `=' but will return TRUE if
  44425.      both arguments are `NULL'.  This is useful for comparing changes
  44426.      between tables.
  44427.  
  44428.    * Added the ODBC 3.0 `EXTRACT(interval FROM datetime)' function.
  44429.  
  44430.    * Columns defined as `FLOAT(X)' is not rounded on storage and may be
  44431.      in scientific notation (1.0 E+10) when retrieved.
  44432.  
  44433.    * `REPLACE' is now faster than before.
  44434.  
  44435.    * Changed `LIKE' character comparison to behave as `='; This means
  44436.      that `'e' LIKE 'e''' (if the line doesn't display correctly, the
  44437.      latter 'e' means a French 'e' with a dot above) is now true.
  44438.  
  44439.    * `SHOW TABLE STATUS' returns a lot of information about the tables.
  44440.  
  44441.    * Added `LIKE' to the `SHOW STATUS' command.
  44442.  
  44443.    * Added privilege column to `SHOW COLUMNS'.
  44444.  
  44445.    * Added columns `packed' and `comment' to `SHOW INDEX'.
  44446.  
  44447.    * Added comments to tables (with `CREATE TABLE ... COMMENT "xxx"').
  44448.  
  44449.    * Added `UNIQUE', as in `CREATE TABLE table_name (col int not null
  44450.      UNIQUE)'
  44451.  
  44452.    * New create syntax: `CREATE TABLE table_name SELECT ...'
  44453.  
  44454.    * New create syntax: `CREATE TABLE IF NOT EXISTS ...'
  44455.  
  44456.    * Allow creation of `CHAR(0)' columns.
  44457.  
  44458.    * `DATE_FORMAT()' now requires `%' before any format character.
  44459.  
  44460.    * `DELAYED' is now a reserved word (sorry about that :( ).
  44461.  
  44462.    * An example procedure is added: `analyse', file: `sql_analyse.c'.
  44463.      This will describe the data in your query.  Try the following:
  44464.           SELECT ... FROM ... WHERE ... PROCEDURE ANALYSE([max elements,[max memory]])
  44465.  
  44466.      This procedure is extremely useful when you want to check the data
  44467.      in your table!
  44468.  
  44469.    * `BINARY' cast to force a string to be compared case sensitively.
  44470.  
  44471.    * Added option `--skip-show-database' to `mysqld'.
  44472.  
  44473.    * Check if a row has changed in an `UPDATE' now also works with
  44474.      `BLOB'/`TEXT' columns.
  44475.  
  44476.    * Added the `INNER' join syntax.  *NOTE*:  This made `INNER' a
  44477.      reserved word!
  44478.  
  44479.    * Added support for netmasks to the hostname in the MySQL tables.
  44480.      You can specify a netmask using the `IP/NETMASK' syntax.
  44481.  
  44482.    * If you compare a `NOT NULL DATE/DATETIME' column with `IS NULL',
  44483.      this is changed to a compare against `0' to satisfy some ODBC
  44484.      applications.  (By <shreeve@uci.edu>).
  44485.  
  44486.    * `NULL IN (...)' now returns `NULL' instead of `0'.  This will
  44487.      ensure that `null_column NOT IN (...)' doesn't match `NULL' values.
  44488.  
  44489.    * Fix storage of floating-point values in `TIME' columns.
  44490.  
  44491.    * Changed parsing of `TIME' strings to be more strict.  Now the
  44492.      fractional second part is detected (and currently skipped). The
  44493.      following formats are supported:
  44494.     `[[DAYS] [H]H:]MM:]SS[.fraction]'
  44495.  
  44496.     `[[[[[H]H]H]H]MM]SS[.fraction]'
  44497.    * Detect (and ignore) second fraction part from `DATETIME'.
  44498.  
  44499.    * Added the `LOW_PRIORITY' attribute to `LOAD DATA INFILE'.
  44500.  
  44501.    * The default index name now uses the same case as the used column
  44502.      name.
  44503.  
  44504.    * Changed default number of connections to 100.
  44505.  
  44506.    * Use bigger buffers when using `LOAD DATA INFILE'.
  44507.  
  44508.    * `DECIMAL(x,y)' now works according to ANSI SQL.
  44509.  
  44510.    * Added aggregate UDF functions. Thanks to Andreas F. Bobak
  44511.      <bobak@relog.ch> for this!
  44512.  
  44513.    * `LAST_INSERT_ID()' is now updated for `INSERT INTO ... SELECT'.
  44514.  
  44515.    * Some small changes to the join table optimizer to make some joins
  44516.      faster.
  44517.  
  44518.    * `SELECT DISTINCT' is much faster; It uses the new `UNIQUE'
  44519.      functionality in `MyISAM'. One difference compared to MySQL
  44520.      Version 3.22 is that the output of `DISTINCT' is not sorted
  44521.      anymore.
  44522.  
  44523.    * All C client API macros are now functions to make shared libraries
  44524.      more reliable. Because of this, you can no longer call
  44525.      `mysql_num_fields()' on a `MYSQL' object, you must use
  44526.      `mysql_field_count()' instead.
  44527.  
  44528.    * Added use of `LIBWRAP';  Patch by Henning P . Schmiedehausen.
  44529.  
  44530.    * Don't allow `AUTO_INCREMENT' for other than numerical columns.
  44531.  
  44532.    * Using `AUTO_INCREMENT' will now automatically make the column `NOT
  44533.      NULL'.
  44534.  
  44535.    * Show `NULL' as the default value for AUTO_INCREMENT columns.
  44536.  
  44537.    * Added `SQL_BIG_RESULT';  `SQL_SMALL_RESULT' is now default.
  44538.  
  44539.    * Added a shared library RPM. This enhancement was contributed by
  44540.      David Fox (dsfox@cogsci.ucsd.edu).
  44541.  
  44542.    * Added a `--enable-large-files/--disable-large-files' switch to
  44543.      `configure'. See `configure.in' for some systems where this is
  44544.      automatically turned off because of broken implementations.
  44545.  
  44546.    * Upgraded `readline' to 4.0.
  44547.  
  44548.    * New `CREATE TABLE' options: `PACK_KEYS' and `CHECKSUM'.
  44549.  
  44550.    * Added `mysqld' option `--default-table-type'.
  44551.  
  44552. 
  44553. File: mysql.info,  Node: News-3.22.x,  Next: News-3.21.x,  Prev: News-3.23.x,  Up: News
  44554.  
  44555. Changes in release 3.22.x (Older; Still supported)
  44556. ==================================================
  44557.  
  44558. The 3.22 version has faster and safer connect code than version 3.21,
  44559. as well as a lot of new nice enhancements.  The reason for not
  44560. including these changes As there aren't really any MAJOR changes,
  44561. upgrading from 3.21 to 3.22 should be very easy and painless.  *Note
  44562. Upgrading-from-3.21::.
  44563.  
  44564. * Menu:
  44565.  
  44566. * News-3.22.35::                Changes in release 3.22.35
  44567. * News-3.22.34::                Changes in release 3.22.34
  44568. * News-3.22.33::                Changes in release 3.22.33
  44569. * News-3.22.32::                Changes in release 3.22.32
  44570. * News-3.22.31::                Changes in release 3.22.31
  44571. * News-3.22.30::                Changes in release 3.22.30
  44572. * News-3.22.29::                Changes in release 3.22.29
  44573. * News-3.22.28::                Changes in release 3.22.28
  44574. * News-3.22.27::                Changes in release 3.22.27
  44575. * News-3.22.26::                Changes in release 3.22.26
  44576. * News-3.22.25::                Changes in release 3.22.25
  44577. * News-3.22.24::                Changes in release 3.22.24
  44578. * News-3.22.23::                Changes in release 3.22.23
  44579. * News-3.22.22::                Changes in release 3.22.22
  44580. * News-3.22.21::                Changes in release 3.22.21
  44581. * News-3.22.20::                Changes in release 3.22.20
  44582. * News-3.22.19::                Changes in release 3.22.19
  44583. * News-3.22.18::                Changes in release 3.22.18
  44584. * News-3.22.17::                Changes in release 3.22.17
  44585. * News-3.22.16::                Changes in release 3.22.16
  44586. * News-3.22.15::                Changes in release 3.22.15
  44587. * News-3.22.14::                Changes in release 3.22.14
  44588. * News-3.22.13::                Changes in release 3.22.13
  44589. * News-3.22.12::                Changes in release 3.22.12
  44590. * News-3.22.11::                Changes in release 3.22.11
  44591. * News-3.22.10::                Changes in release 3.22.10
  44592. * News-3.22.9::                 Changes in release 3.22.9
  44593. * News-3.22.8::                 Changes in release 3.22.8
  44594. * News-3.22.7::                 Changes in release 3.22.7
  44595. * News-3.22.6::                 Changes in release 3.22.6
  44596. * News-3.22.5::                 Changes in release 3.22.5
  44597. * News-3.22.4::                 Changes in release 3.22.4
  44598. * News-3.22.3::                 Changes in release 3.22.3
  44599. * News-3.22.2::                 Changes in release 3.22.2
  44600. * News-3.22.1::                 Changes in release 3.22.1
  44601. * News-3.22.0::                 Changes in release 3.22.0
  44602.  
  44603. 
  44604. File: mysql.info,  Node: News-3.22.35,  Next: News-3.22.34,  Prev: News-3.22.x,  Up: News-3.22.x
  44605.  
  44606. Changes in release 3.22.35
  44607. --------------------------
  44608.  
  44609.    * Fixed problem with `STD()'.
  44610.  
  44611.    * Merged changes from the newest `ISAM' library from 3.23.
  44612.  
  44613.    * Fixed problem with `INSERT DELAYED'.
  44614.  
  44615.    * Fixed a bug core dump when using a `LEFT JOIN'/`STRAIGHT_JOIN' on
  44616.      a table with only one row.
  44617.  
  44618. 
  44619. File: mysql.info,  Node: News-3.22.34,  Next: News-3.22.33,  Prev: News-3.22.35,  Up: News-3.22.x
  44620.  
  44621. Changes in release 3.22.34
  44622. --------------------------
  44623.  
  44624.    * Fixed problem with `GROUP BY' on `TINYBLOB' columns;  This caused
  44625.      bugzilla to not show rows in some queries.
  44626.  
  44627.    * Had to do total recompile of the Windows binary version as VC++
  44628.      didn't compile all relevant files for 3.22.33 :(
  44629.  
  44630. 
  44631. File: mysql.info,  Node: News-3.22.33,  Next: News-3.22.32,  Prev: News-3.22.34,  Up: News-3.22.x
  44632.  
  44633. Changes in release 3.22.33
  44634. --------------------------
  44635.  
  44636.    * Fixed problems in Windows when locking tables with `LOCK TABLE'
  44637.  
  44638.    * Quicker kill of `SELECT DISTINCT' queries.
  44639.  
  44640. 
  44641. File: mysql.info,  Node: News-3.22.32,  Next: News-3.22.31,  Prev: News-3.22.33,  Up: News-3.22.x
  44642.  
  44643. Changes in release 3.22.32
  44644. --------------------------
  44645.  
  44646.    * Fixed problem when storing numbers in timestamps.
  44647.  
  44648.    * Fix problem with timezones that have half hour offsets.
  44649.  
  44650.    * `mysqlhotcopy' - fast on-line hot-backup utility for local MySQL
  44651.      databases. By Tim Bunce.
  44652.  
  44653.    * New more secure `mysqlaccess'. Thanks to Steve Harvey for this.
  44654.  
  44655.    * Fixed security problem in the protocol regarding password checking.
  44656.  
  44657.    * Fixed problem that affected queries that did arithmetic on `GROUP'
  44658.      functions.
  44659.  
  44660.    * Fixed a bug in the `ISAM' code when deleting rows on tables with
  44661.      packed indexes.
  44662.  
  44663. 
  44664. File: mysql.info,  Node: News-3.22.31,  Next: News-3.22.30,  Prev: News-3.22.32,  Up: News-3.22.x
  44665.  
  44666. Changes in release 3.22.31
  44667. --------------------------
  44668.  
  44669.    * A few small fixes for the Windows version.
  44670.  
  44671. 
  44672. File: mysql.info,  Node: News-3.22.30,  Next: News-3.22.29,  Prev: News-3.22.31,  Up: News-3.22.x
  44673.  
  44674. Changes in release 3.22.30
  44675. --------------------------
  44676.  
  44677.    * Fixed optimizer problem on `SELECT' when using many overlapping
  44678.      indexes.
  44679.  
  44680.    * Disabled floating-point exceptions for FreeBSD to fix core dump
  44681.      when doing `SELECT floor(pow(2,63))'.
  44682.  
  44683.    * Added print of default arguments options to all clients.
  44684.  
  44685.    * Fixed critical problem with the `WITH GRANT OPTION' option.
  44686.  
  44687.    * Fixed non-critical Y2K problem when writing short date to log
  44688.      files.
  44689.  
  44690. 
  44691. File: mysql.info,  Node: News-3.22.29,  Next: News-3.22.28,  Prev: News-3.22.30,  Up: News-3.22.x
  44692.  
  44693. Changes in release 3.22.29
  44694. --------------------------
  44695.  
  44696.    * Upgraded the configure and include files to match the latest 3.23
  44697.      version.  This should increase portability and make it easier to
  44698.      build shared libraries.
  44699.  
  44700.    * Added latest patches to mit-pthreads for NetBSD.
  44701.  
  44702.    * Fixed problem with timezones that are < GMT -11.
  44703.  
  44704.    * Fixed a bug when deleting packed keys in NISAM.
  44705.  
  44706.    * Fixed problem that could cause MySQL to touch freed memory when
  44707.      doing very complicated `GROUP BY' queries.
  44708.  
  44709.    * Fixed core dump if you got a crashed table where an `ENUM' field
  44710.      value was too big.
  44711.  
  44712.    * Added `mysqlshutdown.exe' and `mysqlwatch.exe' to the Windows
  44713.      distribution.
  44714.  
  44715.    * Fixed problem when doing `ORDER BY' on a reference key.
  44716.  
  44717.    * Fixed that `INSERT DELAYED' doesn't update timestamps that are
  44718.      given.
  44719.  
  44720. 
  44721. File: mysql.info,  Node: News-3.22.28,  Next: News-3.22.27,  Prev: News-3.22.29,  Up: News-3.22.x
  44722.  
  44723. Changes in release 3.22.28
  44724. --------------------------
  44725.  
  44726.    * Fixed problem with `LEFT JOIN' and `COUNT()' on a column which was
  44727.      declared `NULL' + and it had a `DEFAULT' value.
  44728.  
  44729.    * Fixed core dump problem when using `CONCAT()' in a `WHERE' clause.
  44730.  
  44731.    * Fixed problem with `AVG()' and `STD()' with `NULL' values.
  44732.  
  44733. 
  44734. File: mysql.info,  Node: News-3.22.27,  Next: News-3.22.26,  Prev: News-3.22.28,  Up: News-3.22.x
  44735.  
  44736. Changes in release 3.22.27
  44737. --------------------------
  44738.  
  44739.    * Fixed prototype in `my_ctype.h' when using other character sets.
  44740.  
  44741.    * Some configure issues to fix problems with big file system
  44742.      detection.
  44743.  
  44744.    * Fixed problem when sorting on big blob columns.
  44745.  
  44746.    * `ROUND()' will now work on Windows.
  44747.  
  44748. 
  44749. File: mysql.info,  Node: News-3.22.26,  Next: News-3.22.25,  Prev: News-3.22.27,  Up: News-3.22.x
  44750.  
  44751. Changes in release 3.22.26
  44752. --------------------------
  44753.  
  44754.    * Fixed core dump with empty `BLOB/TEXT' column to `REVERSE()'.
  44755.  
  44756.    * Extended `/*! */' with version numbers.
  44757.  
  44758.    * Changed `SUBSTRING(text FROM pos)' to conform to ANSI SQL. (Before
  44759.      this construct returned the rightmost 'pos' characters).
  44760.  
  44761.    * Fixed problem with `LOCK TABLES' combined with `DELETE FROM table'
  44762.  
  44763.    * Fixed problem that INSERT ... SELECT didn't use SQL_BIG_TABLES.
  44764.  
  44765.    * `SET SQL_LOW_PRIORITY_UPDATES=#' didn't work.
  44766.  
  44767.    * Password wasn't updated correctly if privileges didn't change on:
  44768.      `GRANT ... IDENTIFIED BY'
  44769.  
  44770.    * Fixed range optimizer bug in `SELECT * FROM table_name WHERE
  44771.      key_part1 >= const AND (key_part2 = const OR key_part2 = const)'
  44772.  
  44773.    * Fixed bug in compression key handling in ISAM.
  44774.  
  44775. 
  44776. File: mysql.info,  Node: News-3.22.25,  Next: News-3.22.24,  Prev: News-3.22.26,  Up: News-3.22.x
  44777.  
  44778. Changes in release 3.22.25
  44779. --------------------------
  44780.  
  44781.    * Fixed some small problems with the installation.
  44782.  
  44783. 
  44784. File: mysql.info,  Node: News-3.22.24,  Next: News-3.22.23,  Prev: News-3.22.25,  Up: News-3.22.x
  44785.  
  44786. Changes in release 3.22.24
  44787. --------------------------
  44788.  
  44789.    * `DATA' is not a reserved word anymore.
  44790.  
  44791.    * Fixed optimizer bug with tables with only one row.
  44792.  
  44793.    * Fixed bug when using `LOCK TABLES table_name READ; FLUSH TABLES;'
  44794.  
  44795.    * Applied some patches for HP-UX.
  44796.  
  44797.    * `isamchk' should now work on Windows.
  44798.  
  44799.    * Changed `configure' to not use big file handling on Linux as this
  44800.      crashes some RedHat 6.0 systems
  44801.  
  44802. 
  44803. File: mysql.info,  Node: News-3.22.23,  Next: News-3.22.22,  Prev: News-3.22.24,  Up: News-3.22.x
  44804.  
  44805. Changes in release 3.22.23
  44806. --------------------------
  44807.  
  44808.    * Upgraded to use Autoconf 2.13, Automake 1.4 and `libtool' 1.3.2.
  44809.  
  44810.    * Better support for SCO in `configure'.
  44811.  
  44812.    * Added option `--defaults-file=###' to option file handling to
  44813.      force use of only one specific option file.
  44814.  
  44815.    * Extended `CREATE' syntax to ignore MySQL Version 3.23 keywords.
  44816.  
  44817.    * Fixed deadlock problem when using `INSERT DELAYED' on a table
  44818.      locked with `LOCK TABLES'.
  44819.  
  44820.    * Fixed deadlock problem when using `DROP TABLE' on a table that was
  44821.      locked by another thread.
  44822.  
  44823.    * Add logging of `GRANT/REVOKE' commands in the update log.
  44824.  
  44825.    * Fixed `isamchk' to detect a new error condition.
  44826.  
  44827.    * Fixed bug in `NATURAL LEFT JOIN'.
  44828.  
  44829. 
  44830. File: mysql.info,  Node: News-3.22.22,  Next: News-3.22.21,  Prev: News-3.22.23,  Up: News-3.22.x
  44831.  
  44832. Changes in release 3.22.22
  44833. --------------------------
  44834.  
  44835.    * Fixed problem in the C API when you called `mysql_close()'
  44836.      directly after `mysql_init()'.
  44837.  
  44838.    * Better client error message when you can't open socket.
  44839.  
  44840.    * Fixed `delayed_insert_thread' counting when you couldn't create a
  44841.      new delayed_insert thread.
  44842.  
  44843.    * Fixed bug in `CONCAT()' with many arguments.
  44844.  
  44845.    * Added patches for DEC 3.2 and SCO.
  44846.  
  44847.    * Fixed path-bug when installing MySQL as a service on NT.
  44848.  
  44849.    * The MySQL-Windows version is now compiled with VC++ 6.0 instead of
  44850.      with VC++ 5.0.
  44851.  
  44852.    * New installation setup for MySQL-Windows.
  44853.  
  44854. 
  44855. File: mysql.info,  Node: News-3.22.21,  Next: News-3.22.20,  Prev: News-3.22.22,  Up: News-3.22.x
  44856.  
  44857. Changes in release 3.22.21
  44858. --------------------------
  44859.  
  44860.    * Fixed problem with `DELETE FROM TABLE' when table was locked by
  44861.      another thread.
  44862.  
  44863.    * Fixed bug in `LEFT JOIN' involving empty tables.
  44864.  
  44865.    * Changed the `mysql.db' column from `char(32)' to `char(60)'.
  44866.  
  44867.    * `MODIFY' and `DELAYED' are not reserved words anymore.
  44868.  
  44869.    * Fixed a bug when storing days in a `TIME' column.
  44870.  
  44871.    * Fixed a problem with `Host '...' is not allowed to connect to this
  44872.      MySQL server' after one had inserted a new MySQL user with a
  44873.      `GRANT' command.
  44874.  
  44875.    * Changed to use `TCP_NODELAY' also on Linux (Should give faster
  44876.      TCP/IP connections).
  44877.  
  44878. 
  44879. File: mysql.info,  Node: News-3.22.20,  Next: News-3.22.19,  Prev: News-3.22.21,  Up: News-3.22.x
  44880.  
  44881. Changes in release 3.22.20
  44882. --------------------------
  44883.  
  44884.    * Fixed `STD()' for big tables when result should be 0.
  44885.  
  44886.    * The update log didn't have newlines on some operating systems.
  44887.  
  44888.    * `INSERT DELAYED' had some garbage at end in the update log.
  44889.  
  44890. 
  44891. File: mysql.info,  Node: News-3.22.19,  Next: News-3.22.18,  Prev: News-3.22.20,  Up: News-3.22.x
  44892.  
  44893. Changes in release 3.22.19
  44894. --------------------------
  44895.  
  44896.    * Fixed bug in `mysql_install_db' (from 3.22.17).
  44897.  
  44898.    * Changed default key cache size to 8M.
  44899.  
  44900.    * Fixed problem with queries that needed temporary tables with `BLOB'
  44901.      columns.
  44902.  
  44903. 
  44904. File: mysql.info,  Node: News-3.22.18,  Next: News-3.22.17,  Prev: News-3.22.19,  Up: News-3.22.x
  44905.  
  44906. Changes in release 3.22.18
  44907. --------------------------
  44908.  
  44909.    * Fixes a fatal problem in 3.22.17 on Linux;  After `shutdown' all
  44910.      threads didn't die properly.
  44911.  
  44912.    * Added option `-O flush_time=#' to `mysqld'.  This is mostly useful
  44913.      on Windows and tells how often MySQL should close all unused
  44914.      tables and flush all updated tables to disk.
  44915.  
  44916.    * Fixed problem that a `VARCHAR' column compared with `CHAR' column
  44917.      didn't use keys efficiently.
  44918.  
  44919. 
  44920. File: mysql.info,  Node: News-3.22.17,  Next: News-3.22.16,  Prev: News-3.22.18,  Up: News-3.22.x
  44921.  
  44922. Changes in release 3.22.17
  44923. --------------------------
  44924.  
  44925.    * Fixed a core dump problem when using `--log-update' and connecting
  44926.      without a default database.
  44927.  
  44928.    * Fixed some `configure' and portability problems.
  44929.  
  44930.    * Using `LEFT JOIN' on tables that had circular dependencies caused
  44931.      `mysqld' to hang forever.
  44932.  
  44933. 
  44934. File: mysql.info,  Node: News-3.22.16,  Next: News-3.22.15,  Prev: News-3.22.17,  Up: News-3.22.x
  44935.  
  44936. Changes in release 3.22.16
  44937. --------------------------
  44938.  
  44939.    * `mysqladmin processlist' could kill the server if a new user
  44940.      logged in.
  44941.  
  44942.    * `DELETE FROM tbl_name WHERE key_column=col_name' didn't find any
  44943.      matching rows.  Fixed.
  44944.  
  44945.    * `DATE_ADD(column, ...)' didn't work.
  44946.  
  44947.    * `INSERT DELAYED' could deadlock with status 'upgrading lock'
  44948.  
  44949.    * Extended `ENCRYPT()' to take longer salt strings than 2 characters.
  44950.  
  44951.    * `longlong2str' is now much faster than before.  For `Intel x86'
  44952.      platforms, this function is written in optimized assembler.
  44953.  
  44954.    * Added the `MODIFY' keyword to `ALTER TABLE'.
  44955.  
  44956. 
  44957. File: mysql.info,  Node: News-3.22.15,  Next: News-3.22.14,  Prev: News-3.22.16,  Up: News-3.22.x
  44958.  
  44959. Changes in release 3.22.15
  44960. --------------------------
  44961.  
  44962.    * `GRANT' used with `IDENTIFIED BY' didn't take effect until
  44963.      privileges were flushed.
  44964.  
  44965.    * Name change of some variables in `SHOW STATUS'.
  44966.  
  44967.    * Fixed problem with `ORDER BY' with 'only index' optimization when
  44968.      there were multiple key definitions for a used column.
  44969.  
  44970.    * `DATE' and `DATETIME' columns are now up to 5 times faster than
  44971.      before.
  44972.  
  44973.    * `INSERT DELAYED' can be used to let the client do other things
  44974.      while the server inserts rows into a table.
  44975.  
  44976.    * `LEFT JOIN USING (col1,col2)' didn't work if one used it with
  44977.      tables from 2 different databases.
  44978.  
  44979.    * `LOAD DATA LOCAL INFILE' didn't work in the Unix version because of
  44980.      a missing file.
  44981.  
  44982.    * Fixed problems with `VARCHAR'/`BLOB' on very short rows (< 4
  44983.      bytes); error 127 could occur when deleting rows.
  44984.  
  44985.    * Updating `BLOB/TEXT' through formulas didn't work for short (< 256
  44986.      char) strings.
  44987.  
  44988.    * When you did a `GRANT' on a new host, `mysqld' could die on the
  44989.      first connect from this host.
  44990.  
  44991.    * Fixed bug when one used `ORDER BY' on column name that was the same
  44992.      name as an alias.
  44993.  
  44994.    * Added `BENCHMARK(loop_count,expression)' function to time
  44995.      expressions.
  44996.  
  44997. 
  44998. File: mysql.info,  Node: News-3.22.14,  Next: News-3.22.13,  Prev: News-3.22.15,  Up: News-3.22.x
  44999.  
  45000. Changes in release 3.22.14
  45001. --------------------------
  45002.  
  45003.    * Allow empty arguments to `mysqld' to make it easier to start from
  45004.      shell scripts.
  45005.  
  45006.    * Setting a `TIMESTAMP' column to `NULL' didn't record the timestamp
  45007.      value in the update log.
  45008.  
  45009.    * Fixed lock handler bug when one did `INSERT INTO TABLE ... SELECT
  45010.      ... GROUP BY'.
  45011.  
  45012.    * Added a patch for `localtime_r()' on Windows so that it will not
  45013.      crash anymore if your date is > 2039, but instead will return a
  45014.      time of all zero.
  45015.  
  45016.    * Names for user-defined functions are no longer case sensitive.
  45017.  
  45018.    * Added escape of `^Z' (ASCII 26) to `\Z' as `^Z' doesn't work with
  45019.      pipes on Windows.
  45020.  
  45021.    * `mysql_fix_privileges' adds a new column to the `mysql.func' to
  45022.      support aggregate UDF functions in future MySQL releases.
  45023.  
  45024. 
  45025. File: mysql.info,  Node: News-3.22.13,  Next: News-3.22.12,  Prev: News-3.22.14,  Up: News-3.22.x
  45026.  
  45027. Changes in release 3.22.13
  45028. --------------------------
  45029.  
  45030.    * Saving `NOW()', `CURDATE()' or `CURTIME()' directly in a column
  45031.      didn't work.
  45032.  
  45033.    * `SELECT COUNT(*) ... LEFT JOIN ...' didn't work with no `WHERE'
  45034.      part.
  45035.  
  45036.    * Updated `config.guess' to allow MySQL to configure on UnixWare
  45037.      7.0.x.
  45038.  
  45039.    * Changed the implementation of `pthread_cond()' on the Windows
  45040.      version.  `get_lock()' now correctly times out on Windows!
  45041.  
  45042. 
  45043. File: mysql.info,  Node: News-3.22.12,  Next: News-3.22.11,  Prev: News-3.22.13,  Up: News-3.22.x
  45044.  
  45045. Changes in release 3.22.12
  45046. --------------------------
  45047.  
  45048.    * Fixed problem when using `DATE_ADD()' and `DATE_SUB()' in a
  45049.      `WHERE' clause.
  45050.  
  45051.    * You can now set the password for a user with the `GRANT ... TO user
  45052.      IDENTIFIED BY 'password'' syntax.
  45053.  
  45054.    * Fixed bug in `GRANT' checking with `SELECT' on many tables.
  45055.  
  45056.    * Added missing file `mysql_fix_privilege_tables' to the RPM
  45057.      distribution. This is not run by default because it relies on the
  45058.      client package.
  45059.  
  45060.    * Added option `SQL_SMALL_RESULT' to `SELECT' to force use of fast
  45061.      temporary tables when you know that the result set will be small.
  45062.  
  45063.    * Allow use of negative real numbers without a decimal point.
  45064.  
  45065.    * Day number is now adjusted to maximum days in month if the
  45066.      resulting month after `DATE_ADD'/`DATE_SUB()' doesn't have enough
  45067.      days.
  45068.  
  45069.    * Fix that `GRANT' compares columns in case-insensitive fashion.
  45070.  
  45071.    * Fixed a bug in `sql_list.h' that made `ALTER TABLE' dump core in
  45072.      some contexts.
  45073.  
  45074.    * The hostname in `user@hostname' can now include `.' and `-'
  45075.      without quotes in the context of the `GRANT', `REVOKE' and `SET
  45076.      PASSWORD FOR ...' statements.
  45077.  
  45078.    * Fix for `isamchk' for tables which need big temporary files.
  45079.  
  45080. 
  45081. File: mysql.info,  Node: News-3.22.11,  Next: News-3.22.10,  Prev: News-3.22.12,  Up: News-3.22.x
  45082.  
  45083. Changes in release 3.22.11
  45084. --------------------------
  45085.  
  45086.    * *IMPORTANT*: You must run the `mysql_fix_privilege_tables' script
  45087.      when you upgrade to this version!  This is needed because of the
  45088.      new `GRANT' system. If you don't do this, you will get `Access
  45089.      denied' when you try to use `ALTER TABLE', `CREATE INDEX' or `DROP
  45090.      INDEX'.
  45091.  
  45092.    * `GRANT' to allow/deny users table and column access.
  45093.  
  45094.    * Changed `USER()' to return `user@host'
  45095.  
  45096.    * Changed the syntax for how to set `PASSWORD' for another user.
  45097.  
  45098.    * New command `FLUSH STATUS' that sets most status variables to zero.
  45099.  
  45100.    * New status variables: `aborted_threads', `aborted_connects'.
  45101.  
  45102.    * New option variable: `connection_timeout'.
  45103.  
  45104.    * Added support for Thai sorting (by Pruet Boonma
  45105.      <pruet@ds90.intanon.nectec.or.th>).
  45106.  
  45107.    * Slovak and japanese error messages.
  45108.  
  45109.    * Configuration and portability fixes.
  45110.  
  45111.    * Added option `SET SQL_WARNINGS=1' to get a warning count also for
  45112.      simple inserts.
  45113.  
  45114.    * MySQL now uses `SIGTERM' instead of `SIGQUIT' with shutdown to
  45115.      work better on FreeBSD.
  45116.  
  45117.    * Added option `\G' (print vertically) to `mysql'.
  45118.  
  45119.    * `SELECT HIGH_PRIORITY ...' killed `mysqld'.
  45120.  
  45121.    * `IS NULL' on a `AUTO_INCREMENT' column in a `LEFT JOIN' didn't
  45122.      work as expected.
  45123.  
  45124.    * New function `MAKE_SET()'.
  45125.  
  45126. 
  45127. File: mysql.info,  Node: News-3.22.10,  Next: News-3.22.9,  Prev: News-3.22.11,  Up: News-3.22.x
  45128.  
  45129. Changes in release 3.22.10
  45130. --------------------------
  45131.  
  45132.    * `mysql_install_db' no longer starts the MySQL server!  You should
  45133.      start `mysqld' with `safe_mysqld' after installing it!  The MySQL
  45134.      RPM will, however, start the server as before.
  45135.  
  45136.    * Added `--bootstrap' option to `mysqld' and recoded
  45137.      `mysql_install_db' to use it.  This will make it easier to install
  45138.      MySQL with RPMs.
  45139.  
  45140.    * Changed `+', `-' (sign and minus), `*', `/', `%', `ABS()' and
  45141.      `MOD()' to be `BIGINT' aware (64-bit safe).
  45142.  
  45143.    * Fixed a bug in `ALTER TABLE' that caused `mysqld' to crash.
  45144.  
  45145.    * MySQL now always reports the conflicting key values when a
  45146.      duplicate key entry occurs. (Before this was only reported for
  45147.      `INSERT').
  45148.  
  45149.    * New syntax: `INSERT INTO tbl_name SET col_name=value,
  45150.      col_name=value, ...'
  45151.  
  45152.    * Most errors in the `.err' log are now prefixed with a time stamp.
  45153.  
  45154.    * Added option `MYSQL_INIT_COMMAND' to `mysql_options()' to make a
  45155.      query on connect or reconnect.
  45156.  
  45157.    * Added option `MYSQL_READ_DEFAULT_FILE' and
  45158.      `MYSQL_READ_DEFAULT_GROUP' to `mysql_options()' to read the
  45159.      following parameters from the MySQL option files: `port',
  45160.      `socket', `compress', `password', `pipe', `timeout', `user',
  45161.      `init-command', `host' and `database'.
  45162.  
  45163.    * Added `maybe_null' to the UDF structure.
  45164.  
  45165.    * Added option `IGNORE' to `INSERT' statements with many rows.
  45166.  
  45167.    * Fixed some problems with sorting of the koi8 character sets; Users
  45168.      of koi8 *MUST* run `isamchk -rq' on each table that has an index on
  45169.      a `CHAR' or `VARCHAR' column.
  45170.  
  45171.    * New script `mysql_setpermission', by Luuk de Boer, allows one to
  45172.      easily create new users with permissions for specific databases.
  45173.  
  45174.    * Allow use of hexadecimal strings (0x...) when specifying a
  45175.      constant string (like in the column separators with `LOAD DATA
  45176.      INFILE').
  45177.  
  45178.    * Ported to OS/2 (thanks to Antony T. Curtis
  45179.      <antony.curtis@olcs.net>).
  45180.  
  45181.    * Added more variables to `SHOW STATUS' and changed format of output
  45182.      to be like `SHOW VARIABLES'.
  45183.  
  45184.    * Added `extended-status' command to `mysqladmin' which will show the
  45185.      new status variables.
  45186.  
  45187. 
  45188. File: mysql.info,  Node: News-3.22.9,  Next: News-3.22.8,  Prev: News-3.22.10,  Up: News-3.22.x
  45189.  
  45190. Changes in release 3.22.9
  45191. -------------------------
  45192.  
  45193.    * `SET SQL_LOG_UPDATE=0' caused a lockup of the server.
  45194.  
  45195.    * New SQL command:  `FLUSH [ TABLES | HOSTS | LOGS | PRIVILEGES ] [,
  45196.      ...]'
  45197.  
  45198.    * New SQL command:  `KILL' `thread_id'.
  45199.  
  45200.    * Added casts and changed include files to make MySQL easier to
  45201.      compile on AIX and DEC OSF1 4.x
  45202.  
  45203.    * Fixed conversion problem when using `ALTER TABLE' from a `INT' to
  45204.      a short `CHAR()' column.
  45205.  
  45206.    * Added `SELECT HIGH_PRIORITY'; This will get a lock for the
  45207.      `SELECT' even if there is a thread waiting for another `SELECT' to
  45208.      get a `WRITE LOCK'.
  45209.  
  45210.    * Moved wild_compare to string class to be able to use `LIKE' on
  45211.      `BLOB'/`TEXT' columns with `\0'.
  45212.  
  45213.    * Added `ESCAPE' option to `LIKE'.
  45214.  
  45215.    * Added a lot more output to `mysqladmin debug'.
  45216.  
  45217.    * You can now start `mysqld' on Windows with the `--flush' option.
  45218.      This will flush all tables to disk after each update.  This makes
  45219.      things much safer on NT/Win98 but also *MUCH* slower.
  45220.  
  45221. 
  45222. File: mysql.info,  Node: News-3.22.8,  Next: News-3.22.7,  Prev: News-3.22.9,  Up: News-3.22.x
  45223.  
  45224. Changes in release 3.22.8
  45225. -------------------------
  45226.  
  45227.    * Czech character sets should now work much better.  You must also
  45228.      install
  45229.      `http://www.mysql.com/Downloads/Patches/czech-3.22.8-patch'.  This
  45230.      patch should also be installed if you are using a character set
  45231.      with uses `my_strcoll()'!  The patch should always be safe to
  45232.      install (for any system), but as this patch changes ISAM internals
  45233.      it's not yet in the default distribution.
  45234.  
  45235.    * `DATE_ADD()' and `DATE_SUB()' didn't work with group functions.
  45236.  
  45237.    * `mysql' will now also try to reconnect on `USE DATABASE' commands.
  45238.  
  45239.    * Fix problem with `ORDER BY' and `LEFT JOIN' and `const' tables.
  45240.  
  45241.    * Fixed problem with `ORDER BY' if the first `ORDER BY' column was a
  45242.      key and the rest of the `ORDER BY' columns wasn't part of the key.
  45243.  
  45244.    * Fixed a big problem with `OPTIMIZE TABLE'.
  45245.  
  45246.    * MySQL clients on NT will now by default first try to connect with
  45247.      named pipes and after this with TCP/IP.
  45248.  
  45249.    * Fixed a problem with `DROP TABLE' and `mysqladmin shutdown' on
  45250.      Windows (a fatal bug from 3.22.6).
  45251.  
  45252.    * Fixed problems with `TIME columns' and negative strings.
  45253.  
  45254.    * Added an extra thread signal loop on shutdown to avoid some error
  45255.      messages from the client.
  45256.  
  45257.    * MySQL now uses the next available number as extension for the
  45258.      update log file.
  45259.  
  45260.    * Added patches for UNIXWARE 7.
  45261.  
  45262. 
  45263. File: mysql.info,  Node: News-3.22.7,  Next: News-3.22.6,  Prev: News-3.22.8,  Up: News-3.22.x
  45264.  
  45265. Changes in release 3.22.7
  45266. -------------------------
  45267.  
  45268.    * Added `LIMIT' clause for the `DELETE' statement.
  45269.  
  45270.    * You can now use the `/*! ... */' syntax to hide MySQL-specific
  45271.      keywords when you write portable code.  MySQL will parse the code
  45272.      inside the comments as if the surrounding `/*!' and `*/' comment
  45273.      characters didn't exist.
  45274.  
  45275.    * `OPTIMIZE TABLE tbl_name' can now be used to reclaim disk space
  45276.      after many deletes.  Currently, this uses `ALTER TABLE' to
  45277.      regenerate the table, but in the future it will use an integrated
  45278.      `isamchk' for more speed.
  45279.  
  45280.    * Upgraded `libtool' to get the configure more portable.
  45281.  
  45282.    * Fixed slow `UPDATE' and `DELETE' operations when using `DATETIME'
  45283.      or `DATE' keys.
  45284.  
  45285.    * Changed optimizer to make it better at deciding when to do a full
  45286.      join and when using keys.
  45287.  
  45288.    * You can now use `mysqladmin proc' to display information about
  45289.      your own threads. Only users with the *Process_priv* privilege can
  45290.      get information about all threads.
  45291.  
  45292.    * Added handling of formats `YYMMDD', `YYYYMMDD', `YYMMDDHHMMSS' for
  45293.      numbers when using `DATETIME' and `TIMESTAMP' types. (Formerly
  45294.      these formats only worked with strings.)
  45295.  
  45296.    * Added connect option `CLIENT_IGNORE_SPACE' to allow use of spaces
  45297.      after function names and before `(' (Powerbuilder requires this).
  45298.      This will make all function names reserved words.
  45299.  
  45300.    * Added the `--log-long-format' option to `mysqld' to enable
  45301.      timestamps and INSERT_ID's in the update log.
  45302.  
  45303.    * Added `--where' option to `mysqldump' (patch by Jim Faucette).
  45304.  
  45305.    * The lexical analyzer now uses "perfect hashing" for faster parsing
  45306.      of SQL statements.
  45307.  
  45308. 
  45309. File: mysql.info,  Node: News-3.22.6,  Next: News-3.22.5,  Prev: News-3.22.7,  Up: News-3.22.x
  45310.  
  45311. Changes in release 3.22.6
  45312. -------------------------
  45313.  
  45314.    * Faster `mysqldump'.
  45315.  
  45316.    * For the `LOAD DATA INFILE' statement, you can now use the new
  45317.      `LOCAL' keyword to read the file from the client.  `mysqlimport'
  45318.      will automatically use `LOCAL' when importing with the TCP/IP
  45319.      protocol.
  45320.  
  45321.    * Fixed small optimize problem when updating keys.
  45322.  
  45323.    * Changed makefiles to support shared libraries.
  45324.  
  45325.    * MySQL-NT can now use named pipes, which means that you can now use
  45326.      MySQL-NT without having to install TCP/IP.
  45327.  
  45328. 
  45329. File: mysql.info,  Node: News-3.22.5,  Next: News-3.22.4,  Prev: News-3.22.6,  Up: News-3.22.x
  45330.  
  45331. Changes in release 3.22.5
  45332. -------------------------
  45333.  
  45334.    * All table lock handing is changed to avoid some very subtle
  45335.      deadlocks when using `DROP TABLE', `ALTER TABLE', `DELETE FROM
  45336.      TABLE' and `mysqladmin flush-tables' under heavy usage.  Changed
  45337.      locking code to get better handling of locks of different types.
  45338.  
  45339.    * Updated `DBI' to 1.00 and `DBD' to 1.2.0.
  45340.  
  45341.    * Added a check that the error message file contains error messages
  45342.      suitable for the current version of `mysqld'. (To avoid errors if
  45343.      you accidentally try to use an old error message file.)
  45344.  
  45345.    * All count structures in the client (`affected_rows()',
  45346.      `insert_id()', ...) are now of type `BIGINT' to allow 64-bit values
  45347.      to be used.  This required a minor change in the MySQL protocol
  45348.      which should affect only old clients when using tables with
  45349.      `AUTO_INCREMENT' values > 16M.
  45350.  
  45351.    * The return type of `mysql_fetch_lengths()' has changed from `uint
  45352.      *' to `ulong *'. This may give a warning for old clients but
  45353.      should work on most machines.
  45354.  
  45355.    * Change `mysys' and `dbug' libraries to allocate all thread
  45356.      variables in one struct.  This makes it easier to make a threaded
  45357.      `libmysql.dll' library.
  45358.  
  45359.    * Use the result from `gethostname()' (instead of `uname()') when
  45360.      constructing `.pid' file names.
  45361.  
  45362.    * New better compressed server/client protocol.
  45363.  
  45364.    * `COUNT()', `STD()' and `AVG()' are extended to handle more than 4G
  45365.      rows.
  45366.  
  45367.    * You can now store values in the range `-838:59:59' <= x <=
  45368.      `838:59:59' in a `TIME' column.
  45369.  
  45370.    * *WARNING: INCOMPATIBLE CHANGE!!* If you set a `TIME' column to too
  45371.      short a value, MySQL now assumes the value is given as: `[[[D
  45372.      ]HH:]MM:]SS' instead of `HH[:MM[:SS]]'.
  45373.  
  45374.    * `TIME_TO_SEC()' and `SEC_TO_TIME()' can now handle negative times
  45375.      and hours up to 32767.
  45376.  
  45377.    * Added new option `SET OPTION SQL_LOG_UPDATE={0|1}' to allow users
  45378.      with the *process* privilege to bypass the update log.  (Modified
  45379.      patch from Sergey A Mukhin <violet@rosnet.net>.)
  45380.  
  45381.    * Fixed fatal bug in `LPAD()'.
  45382.  
  45383.    * Initialize line buffer in `mysql.cc' to make `BLOB' reading from
  45384.      pipes safer.
  45385.  
  45386.    * Added `-O max_connect_errors=#' option to `mysqld'.  Connect
  45387.      errors are now reset for each correct connection.
  45388.  
  45389.    * Increased the default value of `max_allowed_packet' to `1M' in
  45390.      `mysqld'.
  45391.  
  45392.    * Added `--low-priority-updates' option to `mysqld', to give
  45393.      table-modifying operations (`INSERT', `REPLACE', `UPDATE',
  45394.      `DELETE') lower priority than retrievals.  You can now use
  45395.      `{INSERT | REPLACE | UPDATE | DELETE} LOW_PRIORITY ...' You can
  45396.      also use `SET OPTION SQL_LOW_PRIORITY_UPDATES={0|1}' to change the
  45397.      priority for one thread.  One side effect is that `LOW_PRIORITY'
  45398.      is now a reserved word. :(
  45399.  
  45400.    * Add support for `INSERT INTO table ... VALUES(...),(...),(...)',
  45401.      to allow inserting multiple rows with a single statement.
  45402.  
  45403.    * `INSERT INTO tbl_name' is now also cached when used with `LOCK
  45404.      TABLES'.  (Previously only `INSERT ... SELECT' and `LOAD DATA
  45405.      INFILE' were cached.)
  45406.  
  45407.    * Allow `GROUP BY' functions with `HAVING':
  45408.           mysql> SELECT col FROM table GROUP BY col HAVING COUNT(*)>0;
  45409.  
  45410.    * `mysqld' will now ignore trailing `;' characters in queries. This
  45411.      is to make it easier to migrate from some other SQL servers that
  45412.      require the trailing `;'.
  45413.  
  45414.    * Fix for corrupted fixed-format output generated by `SELECT INTO
  45415.      OUTFILE'.
  45416.  
  45417.    * *WARNING: INCOMPATIBLE CHANGE!!* Added Oracle `GREATEST()' and
  45418.      `LEAST()' functions.  You must now use these instead of the
  45419.      `MAX()' and `MIN()' functions to get the largest/smallest value
  45420.      from a list of values. These can now handle `REAL', `BIGINT' and
  45421.      string (`CHAR' or `VARCHAR') values.
  45422.  
  45423.    * *WARNING: INCOMPATIBLE CHANGE!!* `DAYOFWEEK()' had offset 0 for
  45424.      Sunday. Changed the offset to 1.
  45425.  
  45426.    * Give an error for queries that mix `GROUP BY' columns and fields
  45427.      when there is no `GROUP BY' specification.
  45428.  
  45429.    * Added `--vertical' option to `mysql', for printing results in
  45430.      vertical mode.
  45431.  
  45432.    * Index-only optimization; some queries are now resolved using only
  45433.      indexes.  Until MySQL 4.0, this works only for numeric columns.
  45434.      *Note MySQL indexes: MySQL indexes.
  45435.  
  45436.    * Lots of new benchmarks.
  45437.  
  45438.    * A new C API chapter and lots of other improvements in the manual.
  45439.  
  45440. 
  45441. File: mysql.info,  Node: News-3.22.4,  Next: News-3.22.3,  Prev: News-3.22.5,  Up: News-3.22.x
  45442.  
  45443. Changes in release 3.22.4
  45444. -------------------------
  45445.  
  45446.    * Added `--tmpdir' option to `mysqld', for specifying the location
  45447.      of the temporary file directory.
  45448.  
  45449.    * MySQL now automatically changes a query from an ODBC client:
  45450.           SELECT ... FROM table WHERE auto_increment_column IS NULL
  45451.      to:
  45452.           SELECT ... FROM table WHERE auto_increment_column == LAST_INSERT_ID()
  45453.      This allows some ODBC programs (Delphi, Access) to retrieve the
  45454.      newly inserted row to fetch the `AUTO_INCREMENT' id.
  45455.  
  45456.    * `DROP TABLE' now waits for all users to free a table before
  45457.      deleting it.
  45458.  
  45459.    * Fixed small memory leak in the new connect protocol.
  45460.  
  45461.    * New functions `BIN()', `OCT()', `HEX()' and `CONV()' for
  45462.      converting between different number bases.
  45463.  
  45464.    * Added function `SUBSTRING()' with 2 arguments.
  45465.  
  45466.    * If you created a table with a record length smaller than 5, you
  45467.      couldn't delete rows from the table.
  45468.  
  45469.    * Added optimization to remove const reference tables from `ORDER
  45470.      BY' and `GROUP BY'.
  45471.  
  45472.    * `mysqld' now automatically disables system locking on Linux and
  45473.      Windows, and for systems that use MIT-pthreads.  You can force the
  45474.      use of locking with the `--enable-locking' option.
  45475.  
  45476.    * Added `--console' option to `mysqld', to force a console window
  45477.      (for error messages) when using Windows.
  45478.  
  45479.    * Fixed table locks for Windows.
  45480.  
  45481.    * Allow `$' in identifiers.
  45482.  
  45483.    * Changed name of user-specific configuration file from `my.cnf' to
  45484.      `.my.cnf' (Unix only).
  45485.  
  45486.    * Added `DATE_ADD()' and `DATE_SUB()' functions.
  45487.  
  45488. 
  45489. File: mysql.info,  Node: News-3.22.3,  Next: News-3.22.2,  Prev: News-3.22.4,  Up: News-3.22.x
  45490.  
  45491. Changes in release 3.22.3
  45492. -------------------------
  45493.  
  45494.    * Fixed a lock problem (bug in MySQL Version 3.22.1) when closing
  45495.      temporary tables.
  45496.  
  45497.    * Added missing `mysql_ping()' to the client library.
  45498.  
  45499.    * Added `--compress' option to all MySQL clients.
  45500.  
  45501.    * Changed `byte' to `char' in `mysql.h' and `mysql_com.h'.
  45502.  
  45503. 
  45504. File: mysql.info,  Node: News-3.22.2,  Next: News-3.22.1,  Prev: News-3.22.3,  Up: News-3.22.x
  45505.  
  45506. Changes in release 3.22.2
  45507. -------------------------
  45508.  
  45509.    * Searching on multiple constant keys that matched more than 30% of
  45510.      the rows didn't always use the best possible key.
  45511.  
  45512.    * New functions `<<', `>>', `RPAD()' and `LPAD()'.
  45513.  
  45514.    * You can now save default options (like passwords) in a
  45515.      configuration file (`my.cnf').
  45516.  
  45517.    * Lots of small changes to get `ORDER BY' to work when no records
  45518.      are found when using fields that are not in `GROUP BY' (MySQL
  45519.      extension).
  45520.  
  45521.    * Added `--chroot' option to `mysqld', to start `mysqld' in a chroot
  45522.      environment (by Nikki Chumakov <nikkic@cityline.ru>).
  45523.  
  45524.    * Trailing spaces are now ignored when comparing case-sensitive
  45525.      strings; this should fix some problems with ODBC and flag 512!
  45526.  
  45527.    * Fixed a core-dump bug in the range optimizer.
  45528.  
  45529.    * Added `--one-thread' option to `mysqld', for debugging with
  45530.      LinuxThreads (or `glibc').  (This replaces the `-T32' flag)
  45531.  
  45532.    * Added `DROP TABLE IF EXISTS' to prevent an error from occurring if
  45533.      the table doesn't exist.
  45534.  
  45535.    * `IF' and `EXISTS' are now reserved words (they would have to be
  45536.      sooner or later).
  45537.  
  45538.    * Added lots of new options to `mysqldump'.
  45539.  
  45540.    * Server error messages are now in `mysqld_error.h'.
  45541.  
  45542.    * The server/client protocol now supports compression.
  45543.  
  45544.    * All bug fixes from MySQL Version 3.21.32.
  45545.  
  45546. 
  45547. File: mysql.info,  Node: News-3.22.1,  Next: News-3.22.0,  Prev: News-3.22.2,  Up: News-3.22.x
  45548.  
  45549. Changes in release 3.22.1
  45550. -------------------------
  45551.  
  45552.    * Added new C API function `mysql_ping()'.
  45553.  
  45554.    * Added new API functions `mysql_init()' and `mysql_options()'.  You
  45555.      now MUST call `mysql_init()' before you call
  45556.      `mysql_real_connect()'.  You don't have to call `mysql_init()' if
  45557.      you only use `mysql_connect()'.
  45558.  
  45559.    * Added `mysql_options(...,MYSQL_OPT_CONNECT_TIMEOUT,...)' so you
  45560.      can set a timeout for connecting to a server.
  45561.  
  45562.    * Added `--timeout' option to `mysqladmin', as a test of
  45563.      `mysql_options()'.
  45564.  
  45565.    * Added `AFTER column' and `FIRST' options to `ALTER TABLE ... ADD
  45566.      columns'.  This makes it possible to add a new column at some
  45567.      specific location within a row in an existing table.
  45568.  
  45569.    * `WEEK()' now takes an optional argument to allow handling of weeks
  45570.      when the week starts on Monday (some European countries).  By
  45571.      default, `WEEK()' assumes the week starts on Sunday.
  45572.  
  45573.    * `TIME' columns weren't stored properly (bug in MySQL Version
  45574.      3.22.0).
  45575.  
  45576.    * `UPDATE' now returns information about how many rows were matched
  45577.      and updated, and how many "warnings" occurred when doing the
  45578.      update.
  45579.  
  45580.    * Fixed incorrect result from `FORMAT(-100,2)'.
  45581.  
  45582.    * `ENUM' and `SET' columns were compared in binary (case-sensitive)
  45583.      fashion; changed to be case insensitive.
  45584.  
  45585. 
  45586. File: mysql.info,  Node: News-3.22.0,  Prev: News-3.22.1,  Up: News-3.22.x
  45587.  
  45588. Changes in release 3.22.0
  45589. -------------------------
  45590.  
  45591.    * New (backward compatible) connect protocol that allows you to
  45592.      specify the database to use when connecting, to get much faster
  45593.      connections to a specific database.
  45594.  
  45595.      The `mysql_real_connect()' call is changed to:
  45596.  
  45597.           mysql_real_connect(MYSQL *mysql, const char *host, const char *user,
  45598.                              const char *passwd, const char *db, uint port,
  45599.                              const char *unix_socket, uint client_flag)
  45600.  
  45601.    * Each connection is handled by its own thread, rather than by the
  45602.      master `accept()' thread.  This fixes permanently the telnet bug
  45603.      that was a topic on the mail list some time ago.
  45604.  
  45605.    * All TCP/IP connections are now checked with backward resolution of
  45606.      the hostname to get better security. `mysqld' now has a local
  45607.      hostname resolver cache so connections should actually be faster
  45608.      than before, even with this feature.
  45609.  
  45610.    * A site automatically will be blocked from future connections if
  45611.      someone repeatedly connects with an "improper header" (like when
  45612.      one uses telnet).
  45613.  
  45614.    * You can now refer to tables in different databases with references
  45615.      of the form `tbl_name@db_name' or `db_name.tbl_name'.  This makes
  45616.      it possible to give a user read access to some tables and write
  45617.      access to others simply by keeping them in different databases!
  45618.  
  45619.    * Added `--user' option to `mysqld', to allow it to run as another
  45620.      Unix user (if it is started as the Unix `root' user).
  45621.  
  45622.    * Added caching of users and access rights (for faster access rights
  45623.      checking)
  45624.  
  45625.    * Normal users (not anonymous ones) can change their password with
  45626.      `mysqladmin password 'new_password''.  This uses encrypted
  45627.      passwords that are not logged in the normal MySQL log!
  45628.  
  45629.    * All important string functions are now coded in assembler for x86
  45630.      Linux machines.  This gives a speedup of 10% in many cases.
  45631.  
  45632.    * For tables that have many columns, the column names are now hashed
  45633.      for much faster column name lookup (this will speed up some
  45634.      benchmark tests a lot!)
  45635.  
  45636.    * Some benchmarks are changed to get better individual timing.
  45637.      (Some loops were so short that a specific test took < 2 seconds.
  45638.      The loops have been changed to take about 20 seconds to make it
  45639.      easier to compare different databases. A test that took 1-2
  45640.      seconds before now takes 11-24 seconds, which is much better)
  45641.  
  45642.    * Re-arranged `SELECT' code to handle some very specific queries
  45643.      involving group functions (like `COUNT(*)') without a `GROUP BY'
  45644.      but with `HAVING'. The following now works:
  45645.           mysql> SELECT count(*) as C FROM table HAVING C > 1;
  45646.  
  45647.    * Changed the protocol for field functions to be faster and avoid
  45648.      some calls to `malloc()'.
  45649.  
  45650.    * Added `-T32' option to `mysqld', for running all queries under the
  45651.      main thread.  This makes it possible to debug `mysqld' under Linux
  45652.      with `gdb'!
  45653.  
  45654.    * Added optimization of `not_null_column IS NULL' (needed for some
  45655.      Access queries).
  45656.  
  45657.    * Allow `STRAIGHT_JOIN' to be used between two tables to force the
  45658.      optimizer to join them in a specific order.
  45659.  
  45660.    * String functions now return `VARCHAR' rather than `CHAR' and the
  45661.      column type is now `VARCHAR' for fields saved as `VARCHAR'.  This
  45662.      should make the *MyODBC* driver better, but may break some old
  45663.      MySQL clients that don't handle `FIELD_TYPE_VARCHAR' the same way
  45664.      as `FIELD_TYPE_CHAR'.
  45665.  
  45666.    * `CREATE INDEX' and `DROP INDEX' are now implemented through `ALTER
  45667.      TABLE'.  `CREATE TABLE' is still the recommended (fast) way to
  45668.      create indexes.
  45669.  
  45670.    * Added `--set-variable' option `wait_timeout' to `mysqld'.
  45671.  
  45672.    * Added time column to `mysqladmin processlist' to show how long a
  45673.      query has taken or how long a thread has slept.
  45674.  
  45675.    * Added lots of new variables to `show variables' and some new to
  45676.      `show status'.
  45677.  
  45678.    * Added new type `YEAR'. `YEAR' is stored in 1 byte with allowable
  45679.      values of 0, and 1901 to 2155.
  45680.  
  45681.    * Added new `DATE' type that is stored in 3 bytes rather than 4
  45682.      bytes.  All new tables are created with the new date type if you
  45683.      don't use the `--old-protocol' option to `mysqld'.
  45684.  
  45685.    * Fixed bug in record caches; for some queries, you could get `Error
  45686.      from table handler: #' on some operating systems.
  45687.  
  45688.    * Added `--enable-assembler' option to `configure', for x86 machines
  45689.      (tested on Linux + `gcc').  This will enable assembler functions
  45690.      for the most important string functions for more speed!
  45691.  
  45692. 
  45693. File: mysql.info,  Node: News-3.21.x,  Next: News-3.20.x,  Prev: News-3.22.x,  Up: News
  45694.  
  45695. Changes in release 3.21.x
  45696. =========================
  45697.  
  45698. Version 3.21 is quite old now, and should be avoided if possible.  This
  45699. information is kept here for historical purposes only.
  45700.  
  45701. * Menu:
  45702.  
  45703. * News-3.21.33::                Changes in release 3.21.33
  45704. * News-3.21.32::                Changes in release 3.21.32
  45705. * News-3.21.31::                Changes in release 3.21.31
  45706. * News-3.21.30::                Changes in release 3.21.30
  45707. * News-3.21.29::                Changes in release 3.21.29
  45708. * News-3.21.28::                Changes in release 3.21.28
  45709. * News-3.21.27::                Changes in release 3.21.27
  45710. * News-3.21.26::                Changes in release 3.21.26
  45711. * News-3.21.25::                Changes in release 3.21.25
  45712. * News-3.21.24::                Changes in release 3.21.24
  45713. * News-3.21.23::                Changes in release 3.21.23
  45714. * News-3.21.22::                Changes in release 3.21.22
  45715. * News-3.21.21a::               Changes in release 3.21.21a
  45716. * News-3.21.21::                Changes in release 3.21.21
  45717. * News-3.21.20::                Changes in release 3.21.20
  45718. * News-3.21.19::                Changes in release 3.21.19
  45719. * News-3.21.18::                Changes in release 3.21.18
  45720. * News-3.21.17::                Changes in release 3.21.17
  45721. * News-3.21.16::                Changes in release 3.21.16
  45722. * News-3.21.15::                Changes in release 3.21.15
  45723. * News-3.21.14b::               Changes in release 3.21.14b
  45724. * News-3.21.14a::               Changes in release 3.21.14a
  45725. * News-3.21.13::                Changes in release 3.21.13
  45726. * News-3.21.12::                Changes in release 3.21.12
  45727. * News-3.21.11::                Changes in release 3.21.11
  45728. * News-3.21.10::                Changes in release 3.21.10
  45729. * News-3.21.9::                 Changes in release 3.21.9
  45730. * News-3.21.8::                 Changes in release 3.21.8
  45731. * News-3.21.7::                 Changes in release 3.21.7
  45732. * News-3.21.6::                 Changes in release 3.21.6
  45733. * News-3.21.5::                 Changes in release 3.21.5
  45734. * News-3.21.4::                 Changes in release 3.21.4
  45735. * News-3.21.3::                 Changes in release 3.21.3
  45736. * News-3.21.2::                 Changes in release 3.21.2
  45737. * News-3.21.0::                 Changes in release 3.21.0
  45738.  
  45739. 
  45740. File: mysql.info,  Node: News-3.21.33,  Next: News-3.21.32,  Prev: News-3.21.x,  Up: News-3.21.x
  45741.  
  45742. Changes in release 3.21.33
  45743. --------------------------
  45744.  
  45745.    * Fixed problem when sending `SIGHUP' to `mysqld'; `mysqld' core
  45746.      dumped when starting from boot on some systems.
  45747.  
  45748.    * Fixed problem with losing a little memory for some connections.
  45749.  
  45750.    * `DELETE FROM tbl_name' without a `WHERE' condition is now done the
  45751.      long way when you use `LOCK TABLES' or if the table is in use, to
  45752.      avoid race conditions.
  45753.  
  45754.    * `INSERT INTO TABLE (timestamp_column) VALUES (NULL);' didn't set
  45755.      timestamp.
  45756.  
  45757. 
  45758. File: mysql.info,  Node: News-3.21.32,  Next: News-3.21.31,  Prev: News-3.21.33,  Up: News-3.21.x
  45759.  
  45760. Changes in release 3.21.32
  45761. --------------------------
  45762.  
  45763.    * Fixed some possible race conditions when doing many reopen/close
  45764.      on the same tables under heavy load!  This can happen if you
  45765.      execute `mysqladmin refresh' often. This could in some very rare
  45766.      cases corrupt the header of the index file and cause error 126 or
  45767.      138.
  45768.  
  45769.    * Fixed fatal bug in `refresh()' when running with the
  45770.      `--skip-locking' option.  There was a "very small" time gap after
  45771.      a `mysqladmin refresh' when a table could be corrupted if one
  45772.      thread updated a table while another thread did `mysqladmin
  45773.      refresh' and another thread started a new update ont the same table
  45774.      before the first thread had finished.  A refresh (or
  45775.      `--flush-tables') will now not return until all used tables are
  45776.      closed!
  45777.  
  45778.    * `SELECT DISTINCT' with a `WHERE' clause that didn't match any rows
  45779.      returned a row in some contexts (bug only in 3.21.31).
  45780.  
  45781.    * `GROUP BY' + `ORDER BY' returned one empty row when no rows where
  45782.      found.
  45783.  
  45784.    * Fixed a bug in the range optimizer that wrote `Use_count: Wrong
  45785.      count for ...' in the error log file.
  45786.  
  45787. 
  45788. File: mysql.info,  Node: News-3.21.31,  Next: News-3.21.30,  Prev: News-3.21.32,  Up: News-3.21.x
  45789.  
  45790. Changes in release 3.21.31
  45791. --------------------------
  45792.  
  45793.    * Fixed a sign extension problem for the `TINYINT' type on Irix.
  45794.  
  45795.    * Fixed problem with `LEFT("constant_string",function)'.
  45796.  
  45797.    * Fixed problem with `FIND_IN_SET()'.
  45798.  
  45799.    * `LEFT JOIN' core dumped if the second table is used with a constant
  45800.      `WHERE/ON' expression that uniquely identifies one record.
  45801.  
  45802.    * Fixed problems with `DATE_FORMAT()' and incorrect dates.
  45803.      `DATE_FORMAT()' now ignores `'%'' to make it possible to extend it
  45804.      more easily in the future.
  45805.  
  45806. 
  45807. File: mysql.info,  Node: News-3.21.30,  Next: News-3.21.29,  Prev: News-3.21.31,  Up: News-3.21.x
  45808.  
  45809. Changes in release 3.21.30
  45810. --------------------------
  45811.  
  45812.    * `mysql' now returns an exit code > 0 if the query returned an
  45813.      error.
  45814.  
  45815.    * Saving of command line history to file in `mysql' client.  By
  45816.      Tommy Larsen <tommy@mix.hive.no>.
  45817.  
  45818.    * Fixed problem with empty lines that were ignored in `mysql.cc'.
  45819.  
  45820.    * Save the pid of the signal handler thread in the pid file instead
  45821.      of the pid of the main thread.
  45822.  
  45823.    * Added patch by <tommy@valley.ne.jp> to support Japanese characters
  45824.      SJIS and UJIS.
  45825.  
  45826.    * Changed `safe_mysqld' to redirect startup messages to
  45827.      `'hostname'.err' instead of `'hostname'.log' to reclaim file space
  45828.      on `mysqladmin refresh'.
  45829.  
  45830.    * `ENUM' always had the first entry as default value.
  45831.  
  45832.    * `ALTER TABLE' wrote two entries to the update log.
  45833.  
  45834.    * `sql_acc()' now closes the `mysql' grant tables after a reload to
  45835.      save table space and memory.
  45836.  
  45837.    * Changed `LOAD DATA' to use less memory with tables and `BLOB'
  45838.      columns.
  45839.  
  45840.    * Sorting on a function which made a division / 0 produced a wrong
  45841.      set in some cases.
  45842.  
  45843.    * Fixed `SELECT' problem with `LEFT()' when using the czech character
  45844.      set.
  45845.  
  45846.    * Fixed problem in `isamchk'; it couldn't repair a packed table in a
  45847.      very unusual case.
  45848.  
  45849.    * `SELECT' statements with `&' or `|' (bit functions) failed on
  45850.      columns with `NULL' values.
  45851.  
  45852.    * When comparing a field = field, where one of the fields was a part
  45853.      key, only the length of the part key was compared.
  45854.  
  45855. 
  45856. File: mysql.info,  Node: News-3.21.29,  Next: News-3.21.28,  Prev: News-3.21.30,  Up: News-3.21.x
  45857.  
  45858. Changes in release 3.21.29
  45859. --------------------------
  45860.  
  45861.    * `LOCK TABLES' + `DELETE from tbl_name' never removed locks
  45862.      properly.
  45863.  
  45864.    * Fixed problem when grouping on an `OR' function.
  45865.  
  45866.    * Fixed permission problem with `umask()' and creating new databases.
  45867.  
  45868.    * Fixed permission problem on result file with `SELECT ... INTO
  45869.      OUTFILE ...'
  45870.  
  45871.    * Fixed problem in range optimizer (core dump) for a very complex
  45872.      query.
  45873.  
  45874.    * Fixed problem when using `MIN(integer)' or `MAX(integer)' in
  45875.      `GROUP BY'.
  45876.  
  45877.    * Fixed bug on Alpha when using integer keys. (Other keys worked on
  45878.      Alpha).
  45879.  
  45880.    * Fixed bug in `WEEK("XXXX-xx-01")'.
  45881.  
  45882. 
  45883. File: mysql.info,  Node: News-3.21.28,  Next: News-3.21.27,  Prev: News-3.21.29,  Up: News-3.21.x
  45884.  
  45885. Changes in release 3.21.28
  45886. --------------------------
  45887.  
  45888.    * Fixed socket permission (clients couldn't connect to Unix socket
  45889.      on Linux).
  45890.  
  45891.    * Fixed bug in record caches; for some queries, you could get `Error
  45892.      from table handler: #' on some operating systems.
  45893.  
  45894. 
  45895. File: mysql.info,  Node: News-3.21.27,  Next: News-3.21.26,  Prev: News-3.21.28,  Up: News-3.21.x
  45896.  
  45897. Changes in release 3.21.27
  45898. --------------------------
  45899.  
  45900.    * Added user level lock functions `GET_LOCK(string,timeout)',
  45901.      `RELEASE_LOCK(string)'.
  45902.  
  45903.    * Added `opened_tables' to `show status'.
  45904.  
  45905.    * Changed connect timeout to 3 seconds to make it somewhat harder
  45906.      for crackers to kill `mysqld' through telnet + TCP/IP.
  45907.  
  45908.    * Fixed bug in range optimizer when using `WHERE key_part_1 >=
  45909.      something AND key_part_2 <= something_else'.
  45910.  
  45911.    * Changed `configure' for detection of FreeBSD 3.0 9803xx and above
  45912.  
  45913.    * `WHERE' with string_column_key = constant_string didn't always find
  45914.      all rows if the column had many values differing only with
  45915.      characters of the same sort value (like e and e').
  45916.  
  45917.    * Strings keys looked up with 'ref' were not compared in
  45918.      case-sensitive fashion.
  45919.  
  45920.    * Added `umask()' to make log files non-readable for normal users.
  45921.  
  45922.    * Ignore users with old (8-byte) password on startup if not using
  45923.      `--old-protocol' option to `mysqld'.
  45924.  
  45925.    * `SELECT' which matched all key fields returned the values in the
  45926.      case of the matched values, not of the found values. (Minor
  45927.      problem.)
  45928.  
  45929. 
  45930. File: mysql.info,  Node: News-3.21.26,  Next: News-3.21.25,  Prev: News-3.21.27,  Up: News-3.21.x
  45931.  
  45932. Changes in release 3.21.26
  45933. --------------------------
  45934.  
  45935.    * `FROM_DAYS(0)' now returns "0000-00-00".
  45936.  
  45937.    * In `DATE_FORMAT()', PM and AM were swapped for hours 00 and 12.
  45938.  
  45939.    * Extended the default maximum key size to 256.
  45940.  
  45941.    * Fixed bug when using `BLOB'/`TEXT' in `GROUP BY' with many tables.
  45942.  
  45943.    * An `ENUM' field that is not declared `NOT NULL' has `NULL' as the
  45944.      default value.  (Previously, the default value was the first
  45945.      enumeration value.)
  45946.  
  45947.    * Fixed bug in the join optimizer code when using many part keys on
  45948.      the same key:  `INDEX (Organization,Surname(35),Initials(35))'.
  45949.  
  45950.    * Added some tests to the table order optimizer to get some cases
  45951.      with `SELECT ... FROM many_tables' much faster.
  45952.  
  45953.    * Added a retry loop around `accept()' to possibly fix some problems
  45954.      on some Linux machines.
  45955.  
  45956. 
  45957. File: mysql.info,  Node: News-3.21.25,  Next: News-3.21.24,  Prev: News-3.21.26,  Up: News-3.21.x
  45958.  
  45959. Changes in release 3.21.25
  45960. --------------------------
  45961.  
  45962.    * Changed `typedef 'string'' to `typedef 'my_string'' for better
  45963.      portability.
  45964.  
  45965.    * You can now kill threads that are waiting on a disk-full condition.
  45966.  
  45967.    * Fixed some problems with UDF functions.
  45968.  
  45969.    * Added long options to `isamchk'. Try `isamchk --help'.
  45970.  
  45971.    * Fixed a bug when using 8 bytes long (alpha); `filesort()' didn't
  45972.      work.  Affects `DISTINCT', `ORDER BY' and `GROUP BY' on 64-bit
  45973.      processors.
  45974.  
  45975. 
  45976. File: mysql.info,  Node: News-3.21.24,  Next: News-3.21.23,  Prev: News-3.21.25,  Up: News-3.21.x
  45977.  
  45978. Changes in release 3.21.24
  45979. --------------------------
  45980.  
  45981.    * Dynamic loadable functions. Based on source from Alexis Mikhailov.
  45982.  
  45983.    * You couldn't delete from a table if no one had done a `SELECT' on
  45984.      the table.
  45985.  
  45986.    * Fixed problem with range optimizer with many `OR' operators on key
  45987.      parts inside each other.
  45988.  
  45989.    * Recoded `MIN()' and `MAX()' to work properly with strings and
  45990.      `HAVING'.
  45991.  
  45992.    * Changed default umask value for new files from `0664' to `0660'.
  45993.  
  45994.    * Fixed problem with `LEFT JOIN' and constant expressions in the `ON'
  45995.      part.
  45996.  
  45997.    * Added Italian error messages from <brenno@dewinter.com>.
  45998.  
  45999.    * `configure' now works better on OSF1 (tested on 4.0D).
  46000.  
  46001.    * Added hooks to allow `LIKE' optimization with international
  46002.      character support.
  46003.  
  46004.    * Upgraded `DBI' to 0.93.
  46005.  
  46006. 
  46007. File: mysql.info,  Node: News-3.21.23,  Next: News-3.21.22,  Prev: News-3.21.24,  Up: News-3.21.x
  46008.  
  46009. Changes in release 3.21.23
  46010. --------------------------
  46011.  
  46012.    * The following symbols are now reserved words: `TIME', `DATE',
  46013.      `TIMESTAMP', `TEXT', `BIT', `ENUM', `NO', `ACTION', `CHECK',
  46014.      `YEAR', `MONTH', `DAY', `HOUR', `MINUTE', `SECOND', `STATUS',
  46015.      `VARIABLES'.
  46016.  
  46017.    * Setting a `TIMESTAMP' to `NULL' in `LOAD DATA INFILE ...' didn't
  46018.      set the current time for the `TIMESTAMP'.
  46019.  
  46020.    * Fix `BETWEEN' to recognize binary strings. Now `BETWEEN' is case
  46021.      sensitive.
  46022.  
  46023.    * Added `--skip-thread-priority' option to `mysqld', for systems
  46024.      where `mysqld''s thread scheduling doesn't work properly (BSDI
  46025.      3.1).
  46026.  
  46027.    * Added ODBC functions `DAYNAME()' and `MONTHNAME()'.
  46028.  
  46029.    * Added function `TIME_FORMAT()'.  This works like `DATE_FORMAT()',
  46030.      but takes a time string (`'HH:MM:DD'') as argument.
  46031.  
  46032.    * Fixed unlikely(?) key optimizer bug when using `OR's of key parts
  46033.      inside `AND's.
  46034.  
  46035.    * Added command `variables' to `mysqladmin'.
  46036.  
  46037.    * A lot of small changes to the binary releases.
  46038.  
  46039.    * Fixed a bug in the new protocol from MySQL Version 3.21.20.
  46040.  
  46041.    * Changed `ALTER TABLE' to work with Windows (Windows can't rename
  46042.      open files).  Also fixed a couple of small bugs in the Windows
  46043.      version.
  46044.  
  46045.    * All standard MySQL clients are now ported to MySQL-Windows.
  46046.  
  46047.    * MySQL can now be started as a service on NT.
  46048.  
  46049. 
  46050. File: mysql.info,  Node: News-3.21.22,  Next: News-3.21.21a,  Prev: News-3.21.23,  Up: News-3.21.x
  46051.  
  46052. Changes in release 3.21.22
  46053. --------------------------
  46054.  
  46055.    * Starting with this version, all MySQL distributions will be
  46056.      configured, compiled and tested with `crash-me' and the benchmarks
  46057.      on the following platforms: SunOS 5.6 sun4u, SunOS 5.5.1 sun4u,
  46058.      SunOS 4.14 sun4c, SunOS 5.6 i86pc, Irix 6.3 mips5k, HP-UX 10.20
  46059.      hppa, AIX 4.2.1 ppc, OSF1 V4.0 alpha, FreeBSD 2.2.2 i86pc and BSDI
  46060.      3.1 i386.
  46061.  
  46062.    * Fix `COUNT(*)' problems when the `WHERE' clause didn't match any
  46063.      records.  (Bug from 3.21.17.)
  46064.  
  46065.    * Removed that `NULL = NULL' is true.  Now you must use `IS NULL' or
  46066.      `IS NOT NULL' to test whether or not a value is `NULL'.  (This is
  46067.      according to ANSI SQL but may break old applications that are
  46068.      ported from `mSQL'.)  You can get the old behavior by compiling
  46069.      with `-DmSQL_COMPLIANT'.
  46070.  
  46071.    * Fixed bug that core dumped when using many `LEFT OUTER JOIN'
  46072.      clauses.
  46073.  
  46074.    * Fixed bug in `ORDER BY' on string formula with possible `NULL'
  46075.      values.
  46076.  
  46077.    * Fixed problem in range optimizer when using <= on sub index.
  46078.  
  46079.    * Added functions `DAYOFYEAR()', `DAYOFMONTH()', `MONTH()',
  46080.      `YEAR()', `WEEK()', `QUARTER()', `HOUR()', `MINUTE()', `SECOND()'
  46081.      and `FIND_IN_SET()'.
  46082.  
  46083.    * Added command `SHOW VARIABLES'.
  46084.  
  46085.    * Added support of "long constant strings" from ANSI SQL:
  46086.           mysql> SELECT 'first ' 'second';       -> 'first second'
  46087.  
  46088.    * Upgraded mSQL-Mysql-modules to 1.1825.
  46089.  
  46090.    * Upgraded `mysqlaccess' to 2.02.
  46091.  
  46092.    * Fixed problem with Russian character set and `LIKE'.
  46093.  
  46094.    * Ported to OpenBSD 2.1.
  46095.  
  46096.    * New Dutch error messages.
  46097.  
  46098. 
  46099. File: mysql.info,  Node: News-3.21.21a,  Next: News-3.21.21,  Prev: News-3.21.22,  Up: News-3.21.x
  46100.  
  46101. Changes in release 3.21.21a
  46102. ---------------------------
  46103.  
  46104.    * Configure changes for some operating systems.
  46105.  
  46106. 
  46107. File: mysql.info,  Node: News-3.21.21,  Next: News-3.21.20,  Prev: News-3.21.21a,  Up: News-3.21.x
  46108.  
  46109. Changes in release 3.21.21
  46110. --------------------------
  46111.  
  46112.    * Fixed optimizer bug when using `WHERE data_field = date_field2 AND
  46113.      date_field2 = constant'.
  46114.  
  46115.    * Added command `SHOW STATUS'.
  46116.  
  46117.    * Removed `manual.ps' from the source distribution to make it
  46118.      smaller.
  46119.  
  46120. 
  46121. File: mysql.info,  Node: News-3.21.20,  Next: News-3.21.19,  Prev: News-3.21.21,  Up: News-3.21.x
  46122.  
  46123. Changes in release 3.21.20
  46124. --------------------------
  46125.  
  46126.    * Changed the maximum table name and column name lengths from 32 to
  46127.      64.
  46128.  
  46129.    * Aliases can now be of "any" length.
  46130.  
  46131.    * Fixed `mysqladmin stat' to return the right number of queries.
  46132.  
  46133.    * Changed protocol (downward compatible) to mark if a column has the
  46134.      `AUTO_INCREMENT' attribute or is a `TIMESTAMP'. This is needed for
  46135.      the new Java driver.
  46136.  
  46137.    * Added Hebrew sorting order by Zeev Suraski.
  46138.  
  46139.    * Solaris 2.6: Fixed `configure' bugs and increased maximum table
  46140.      size from 2G to 4G.
  46141.  
  46142. 
  46143. File: mysql.info,  Node: News-3.21.19,  Next: News-3.21.18,  Prev: News-3.21.20,  Up: News-3.21.x
  46144.  
  46145. Changes in release 3.21.19
  46146. --------------------------
  46147.  
  46148.    * Upgraded `DBD' to 1823. This version implements `mysql_use_result'
  46149.      in `DBD-Mysql'.
  46150.  
  46151.    * Benchmarks updated for empress (by Luuk).
  46152.  
  46153.    * Fixed a case of slow range searching.
  46154.  
  46155.    * Configure fixes (`Docs' directory).
  46156.  
  46157.    * Added function `REVERSE()' (by Zeev Suraski).
  46158.  
  46159. 
  46160. File: mysql.info,  Node: News-3.21.18,  Next: News-3.21.17,  Prev: News-3.21.19,  Up: News-3.21.x
  46161.  
  46162. Changes in release 3.21.18
  46163. --------------------------
  46164.  
  46165.    * Issue error message if client C functions are called in wrong
  46166.      order.
  46167.  
  46168.    * Added automatic reconnect to the `libmysql.c' library. If a write
  46169.      command fails, an automatic reconnect is done.
  46170.  
  46171.    * Small sort sets no longer use temporary files.
  46172.  
  46173.    * Upgraded `DBI' to 0.91.
  46174.  
  46175.    * Fixed a couple of problems with `LEFT OUTER JOIN'.
  46176.  
  46177.    * Added `CROSS JOIN' syntax. `CROSS' is now a reserved word.
  46178.  
  46179.    * Recoded `yacc'/`bison' stack allocation to be even safer and to
  46180.      allow MySQL to handle even bigger expressions.
  46181.  
  46182.    * Fixed a couple of problems with the update log.
  46183.  
  46184.    * `ORDER BY' was slow when used with key ranges.
  46185.  
  46186. 
  46187. File: mysql.info,  Node: News-3.21.17,  Next: News-3.21.16,  Prev: News-3.21.18,  Up: News-3.21.x
  46188.  
  46189. Changes in release 3.21.17
  46190. --------------------------
  46191.  
  46192.    * Changed documentation string of `--with-unix-socket-path' to avoid
  46193.      confusion.
  46194.  
  46195.    * Added ODBC and ANSI SQL style `LEFT OUTER JOIN'.
  46196.  
  46197.    * The following are new reserved words: `LEFT', `NATURAL', `USING'.
  46198.  
  46199.    * The client library now uses the value of the environment variable
  46200.      `MYSQL_HOST' as the default host if it's defined.
  46201.  
  46202.    * `SELECT col_name, SUM(expr)' now returns `NULL' for `col_name'
  46203.      when there are matching rows.
  46204.  
  46205.    * Fixed problem with comparing binary strings and `BLOB's with ASCII
  46206.      characters over 127.
  46207.  
  46208.    * Fixed lock problem: when freeing a read lock on a table with
  46209.      multiple read locks, a thread waiting for a write lock would have
  46210.      been given the lock.  This shouldn't affect data integrity, but
  46211.      could possibly make `mysqld' restart if one thread was reading
  46212.      data that another thread modified.
  46213.  
  46214.    * `LIMIT offset,count' didn't work in `INSERT ... SELECT'.
  46215.  
  46216.    * Optimized key block caching. This will be quicker than the old
  46217.      algorithm when using bigger key caches.
  46218.  
  46219. 
  46220. File: mysql.info,  Node: News-3.21.16,  Next: News-3.21.15,  Prev: News-3.21.17,  Up: News-3.21.x
  46221.  
  46222. Changes in release 3.21.16
  46223. --------------------------
  46224.  
  46225.    * Added ODBC 2.0 & 3.0 functions `POWER()', `SPACE()', `COT()',
  46226.      `DEGREES()', `RADIANS()', `ROUND(2 arg)' and `TRUNCATE()'.
  46227.  
  46228.    * *WARNING: INCOMPATIBLE CHANGE!!* `LOCATE()' parameters were
  46229.      swapped according to ODBC standard. Fixed.
  46230.  
  46231.    * Added function `TIME_TO_SEC()'.
  46232.  
  46233.    * In some cases, default values were not used for `NOT NULL' fields.
  46234.  
  46235.    * Timestamp wasn't always updated properly in `UPDATE SET ...'
  46236.      statements.
  46237.  
  46238.    * Allow empty strings as default values for `BLOB' and `TEXT', to be
  46239.      compatible with `mysqldump'.
  46240.  
  46241. 
  46242. File: mysql.info,  Node: News-3.21.15,  Next: News-3.21.14b,  Prev: News-3.21.16,  Up: News-3.21.x
  46243.  
  46244. Changes in release 3.21.15
  46245. --------------------------
  46246.  
  46247.    * *WARNING: INCOMPATIBLE CHANGE!!* `mysqlperl' is now from
  46248.      Msql-Mysql-modules. This means that `connect()' now takes `host',
  46249.      `database', `user', `password' arguments! The old version took
  46250.      `host', `database', `password', `user'.
  46251.  
  46252.    * Allow `DATE '1997-01-01'', `TIME '12:10:10'' and `TIMESTAMP
  46253.      '1997-01-01 12:10:10'' formats required by ANSI SQL.  *WARNING:
  46254.      INCOMPATIBLE CHANGE!!* This has the unfortunate side-effect that
  46255.      you no longer can have columns named `DATE', `TIME' or
  46256.      `TIMESTAMP'. :( Old columns can still be accessed through
  46257.      `tablename.columnname'!)
  46258.  
  46259.    * Changed Makefiles to hopefully work better with BSD systems. Also,
  46260.      `manual.dvi' is now included in the distribution to avoid having
  46261.      stupid `make' programs trying to rebuild it.
  46262.  
  46263.    * `readline' library upgraded to version 2.1.
  46264.  
  46265.    * A new sortorder german-1. That is a normal ISO-Latin1 with a
  46266.      german sort order.
  46267.  
  46268.    * Perl `DBI'/`DBD' is now included in the distribution. `DBI' is now
  46269.      the recommended way to connect to MySQL from Perl.
  46270.  
  46271.    * New portable benchmark suite with `DBD', with test results from
  46272.      `mSQL' 2.0.3, MySQL, PostgreSQL 6.2.1 and Solid server 2.2.
  46273.  
  46274.    * `crash-me' is now included with the benchmarks; This is a Perl
  46275.      program designed to find as many limits as possible in a SQL
  46276.      server. Tested with `mSQL', PostgreSQL, Solid and MySQL.
  46277.  
  46278.    * Fixed bug in range-optimizer that crashed MySQL on some queries.
  46279.  
  46280.    * Table and column name completion for `mysql' command line tool, by
  46281.      Zeev Suraski and Andi Gutmans.
  46282.  
  46283.    * Added new command `REPLACE' that works like `INSERT' but replaces
  46284.      conflicting records with the new record. `REPLACE INTO TABLE ...
  46285.      SELECT ...' works also.
  46286.  
  46287.    * Added new commands `CREATE DATABASE db_name' and `DROP DATABASE
  46288.      db_name'.
  46289.  
  46290.    * Added `RENAME' option to `ALTER TABLE': `ALTER TABLE name RENAME
  46291.      TO new_name'.
  46292.  
  46293.    * `make_binary_distribution' now includes `libgcc.a' in
  46294.      `libmysqlclient.a'. This should make linking work for people who
  46295.      don't have `gcc'.
  46296.  
  46297.    * Changed `net_write()' to `my_net_write()' because of a name
  46298.      conflict with Sybase.
  46299.  
  46300.    * New function `DAYOFWEEK()' compatible with ODBC.
  46301.  
  46302.    * Stack checking and `bison' memory overrun checking to make MySQL
  46303.      safer with weird queries.
  46304.  
  46305. 
  46306. File: mysql.info,  Node: News-3.21.14b,  Next: News-3.21.14a,  Prev: News-3.21.15,  Up: News-3.21.x
  46307.  
  46308. Changes in release 3.21.14b
  46309. ---------------------------
  46310.  
  46311.    * Fixed a couple of small `configure' problems on some platforms.
  46312.  
  46313. 
  46314. File: mysql.info,  Node: News-3.21.14a,  Next: News-3.21.13,  Prev: News-3.21.14b,  Up: News-3.21.x
  46315.  
  46316. Changes in release 3.21.14a
  46317. ---------------------------
  46318.  
  46319.    * Ported to SCO Openserver 5.0.4  with FSU Pthreads.
  46320.  
  46321.    * HP-UX 10.20 should work.
  46322.  
  46323.    * Added new function `DATE_FORMAT()'.
  46324.  
  46325.    * Added `NOT IN'.
  46326.  
  46327.    * Added automatic removal of 'ODBC function conversions': `{fn now()
  46328.      }'
  46329.  
  46330.    * Handle ODBC 2.50.3 option flags.
  46331.  
  46332.    * Fixed comparison of `DATE' and `TIME' values with `NULL'.
  46333.  
  46334.    * Changed language name from germany to german to be consistent with
  46335.      the other language names.
  46336.  
  46337.    * Fixed sorting problem on functions returning a `FLOAT'.
  46338.      Previously, the values were converted to `INT's before sorting.
  46339.  
  46340.    * Fixed slow sorting when sorting on key field when using
  46341.      `key_column=constant'.
  46342.  
  46343.    * Sorting on calculated `DOUBLE' values sorted on integer results
  46344.      instead.
  46345.  
  46346.    * `mysql' no longer needs a database argument.
  46347.  
  46348.    * Changed the place where `HAVING' should be. According to ANSI, it
  46349.      should be after `GROUP BY' but before `ORDER BY'. MySQL Version
  46350.      3.20 incorrectly had it last.
  46351.  
  46352.    * Added Sybase command `USE DATABASE' to start using another
  46353.      database.
  46354.  
  46355.    * Added automatic adjusting of number of connections and table cache
  46356.      size if the maximum number of files that can be opened is less
  46357.      than needed.  This should fix that `mysqld' doesn't crash even if
  46358.      you haven't done a `ulimit -n 256' before starting `mysqld'.
  46359.  
  46360.    * Added lots of limit checks to make it safer when running with too
  46361.      little memory or when doing weird queries.
  46362.  
  46363. 
  46364. File: mysql.info,  Node: News-3.21.13,  Next: News-3.21.12,  Prev: News-3.21.14a,  Up: News-3.21.x
  46365.  
  46366. Changes in release 3.21.13
  46367. --------------------------
  46368.  
  46369.    * Added retry of interrupted reads and clearing of `errno'.  This
  46370.      makes Linux systems much safer!
  46371.  
  46372.    * Fixed locking bug when using many aliases on the same table in the
  46373.      same `SELECT'.
  46374.  
  46375.    * Fixed bug with `LIKE' on number key.
  46376.  
  46377.    * New error message so you can check whether the connection was lost
  46378.      while the command was running or whether the connection was down
  46379.      from the start.
  46380.  
  46381.    * Added `--table' option to `mysql' to print in table format.  Moved
  46382.      time and row information after query result.  Added automatic
  46383.      reconnect of lost connections.
  46384.  
  46385.    * Added `!=' as a synonym for `<>'.
  46386.  
  46387.    * Added function `VERSION()' to make easier logs.
  46388.  
  46389.    * New multi-user test `tests/fork_test.pl' to put some strain on the
  46390.      thread library.
  46391.  
  46392. 
  46393. File: mysql.info,  Node: News-3.21.12,  Next: News-3.21.11,  Prev: News-3.21.13,  Up: News-3.21.x
  46394.  
  46395. Changes in release 3.21.12
  46396. --------------------------
  46397.  
  46398.    * Fixed `ftruncate()' call in MIT-pthreads. This made `isamchk'
  46399.      destroy the `.ISM' files on (Free)BSD 2.x systems.
  46400.  
  46401.    * Fixed broken `__P_' patch in MIT-pthreads.
  46402.  
  46403.    * Many memory overrun checks. All string functions now return `NULL'
  46404.      if the returned string should be longer than `max_allowed_packet'
  46405.      bytes.
  46406.  
  46407.    * Changed the name of the `INTERVAL' type to `ENUM', because
  46408.      `INTERVAL' is used in ANSI SQL.
  46409.  
  46410.    * In some cases, doing a `JOIN' + `GROUP' + `INTO OUTFILE', the
  46411.      result wasn't grouped.
  46412.  
  46413.    * `LIKE' with `'_'' as last character didn't work. Fixed.
  46414.  
  46415.    * Added extended ANSI SQL `TRIM()' function.
  46416.  
  46417.    * Added `CURTIME()'.
  46418.  
  46419.    * Added `ENCRYPT()' function by Zeev Suraski.
  46420.  
  46421.    * Fixed better `FOREIGN KEY' syntax skipping. New reserved words:
  46422.      `MATCH', `FULL', `PARTIAL'.
  46423.  
  46424.    * `mysqld' now allows IP number and hostname to the `--bind-address'
  46425.      option.
  46426.  
  46427.    * Added `SET OPTION CHARACTER SET cp1251_koi8' to enable conversions
  46428.      of data to/from cp1251_koi8.
  46429.  
  46430.    * Lots of changes for Win95 port. In theory, this version should now
  46431.      be easily portable to Win95.
  46432.  
  46433.    * Changed the `CREATE COLUMN' syntax of `NOT NULL' columns to be
  46434.      after the `DEFAULT' value, as specified in the ANSI SQL standard.
  46435.      This will make `mysqldump' with `NOT NULL' and default values
  46436.      incompatible with MySQL Version 3.20.
  46437.  
  46438.    * Added many function name aliases so the functions can be used with
  46439.      ODBC or ANSI SQL92 syntax.
  46440.  
  46441.    * Fixed syntax of `ALTER TABLE tbl_name ALTER COLUMN col_name SET
  46442.      DEFAULT NULL'.
  46443.  
  46444.    * Added `CHAR' and `BIT' as synonyms for `CHAR(1)'.
  46445.  
  46446.    * Fixed core dump when updating as a user who has only *select*
  46447.      privilege.
  46448.  
  46449.    * `INSERT ... SELECT ... GROUP BY' didn't work in some cases. An
  46450.      `Invalid use of group function' error occurred.
  46451.  
  46452.    * When using `LIMIT', `SELECT' now always uses keys instead of record
  46453.      scan.  This will give better performance on `SELECT' and a `WHERE'
  46454.      that matches many rows.
  46455.  
  46456.    * Added Russian error messages.
  46457.  
  46458. 
  46459. File: mysql.info,  Node: News-3.21.11,  Next: News-3.21.10,  Prev: News-3.21.12,  Up: News-3.21.x
  46460.  
  46461. Changes in release 3.21.11
  46462. --------------------------
  46463.  
  46464.    * Configure changes.
  46465.  
  46466.    * MySQL now works with the new thread library on BSD/OS 3.0.
  46467.  
  46468.    * Added new group functions `BIT_OR()' and `BIT_AND()'.
  46469.  
  46470.    * Added compatibility functions `CHECK' and `REFERENCES'.  `CHECK'
  46471.      is now a reserved word.
  46472.  
  46473.    * Added `ALL' option to `GRANT' for better compatibility. (`GRANT'
  46474.      is still a dummy function.)
  46475.  
  46476.    * Added partly-translated dutch messages.
  46477.  
  46478.    * Fixed bug in `ORDER BY' and `GROUP BY' with `NULL' columns.
  46479.  
  46480.    * Added function `last_insert_id()' to retrieve last `AUTO_INCREMENT'
  46481.      value.  This is intended for clients to ODBC that can't use the
  46482.      `mysql_insert_id()' API function, but can be used by any client.
  46483.  
  46484.    * Added `--flush-logs' option to `mysqladmin'.
  46485.  
  46486.    * Added command `STATUS' to `mysql'.
  46487.  
  46488.    * Fixed problem with `ORDER BY'/`GROUP BY' because of bug in `gcc'.
  46489.  
  46490.    * Fixed problem with `INSERT ... SELECT ... GROUP BY'.
  46491.  
  46492. 
  46493. File: mysql.info,  Node: News-3.21.10,  Next: News-3.21.9,  Prev: News-3.21.11,  Up: News-3.21.x
  46494.  
  46495. Changes in release 3.21.10
  46496. --------------------------
  46497.  
  46498.    * New `mysqlaccess'.
  46499.  
  46500.    * `CREATE' now supports all ODBC types and the `mSQL' `TEXT' type.
  46501.      All ODBC 2.5 functions are also supported (added `REPEAT'). This
  46502.      provides better portability.
  46503.  
  46504.    * Added text types `TINYTEXT', `TEXT', `MEDIUMTEXT' and `LONGTEXT'.
  46505.      These are actually `BLOB'types, but all searching is done in
  46506.      case-insensitive fashion.
  46507.  
  46508.    * All old `BLOB' fields are now `TEXT' fields.  This only changes
  46509.      that all searching on strings is done in case-sensitive fashion.
  46510.      You must do an `ALTER TABLE' and change the field type to `BLOB'
  46511.      if you want to have tests done in case-sensitive fashion.
  46512.  
  46513.    * Fixed some `configure' issues.
  46514.  
  46515.    * Made the locking code a bit safer. Fixed very unlikely deadlock
  46516.      situation.
  46517.  
  46518.    * Fixed a couple of bugs in the range optimizer. Now the new range
  46519.      benchmark `test-select' works.
  46520.  
  46521. 
  46522. File: mysql.info,  Node: News-3.21.9,  Next: News-3.21.8,  Prev: News-3.21.10,  Up: News-3.21.x
  46523.  
  46524. Changes in release 3.21.9
  46525. -------------------------
  46526.  
  46527.    * Added `--enable-unix-socket=pathname' option to `configure'.
  46528.  
  46529.    * Fixed a couple of portability problems with include files.
  46530.  
  46531.    * Fixed bug in range calculation that could return empty set when
  46532.      searching on multiple key with only one entry (very rare).
  46533.  
  46534.    * Most things ported to FSU Pthreads, which should allow MySQL to
  46535.      run on SCO. *Note SCO::.
  46536.  
  46537. 
  46538. File: mysql.info,  Node: News-3.21.8,  Next: News-3.21.7,  Prev: News-3.21.9,  Up: News-3.21.x
  46539.  
  46540. Changes in release 3.21.8
  46541. -------------------------
  46542.  
  46543.    * Works now in Solaris 2.6.
  46544.  
  46545.    * Added handling of calculation of `SUM()' functions.  For example,
  46546.      you can now use `SUM(column)/COUNT(column)'.
  46547.  
  46548.    * Added handling of trigometric functions: `PI()', `ACOS()',
  46549.      `ASIN()', `ATAN()', `COS()', `SIN()' and `TAN()'.
  46550.  
  46551.    * New languages: norwegian, norwegian-ny and portuguese.
  46552.  
  46553.    * Fixed parameter bug in `net_print()' in `procedure.cc'.
  46554.  
  46555.    * Fixed a couple of memory leaks.
  46556.  
  46557.    * Now allow also the old `SELECT ... INTO OUTFILE' syntax.
  46558.  
  46559.    * Fixed bug with `GROUP BY' and `SELECT' on key with many values.
  46560.  
  46561.    * `mysql_fetch_lengths()' sometimes returned incorrect lengths when
  46562.      you used `mysql_use_result()'. This affected at least some cases of
  46563.      `mysqldump --quick'.
  46564.  
  46565.    * Fixed bug in optimization of `WHERE const op field'.
  46566.  
  46567.    * Fixed problem when sorting on `NULL' fields.
  46568.  
  46569.    * Fixed a couple of 64-bit (Alpha) problems.
  46570.  
  46571.    * Added `--pid-file=#' option to `mysqld'.
  46572.  
  46573.    * Added date formatting to `FROM_UNIXTIME()', originally by Zeev
  46574.      Suraski.
  46575.  
  46576.    * Fixed bug in `BETWEEN' in range optimizer (Did only test = of the
  46577.      first argument).
  46578.  
  46579.    * Added machine-dependent files for MIT-pthreads i386-SCO. There is
  46580.      probably more to do to get this to work on SCO 3.5.
  46581.  
  46582. 
  46583. File: mysql.info,  Node: News-3.21.7,  Next: News-3.21.6,  Prev: News-3.21.8,  Up: News-3.21.x
  46584.  
  46585. Changes in release 3.21.7
  46586. -------------------------
  46587.  
  46588.    * Changed `Makefile.am' to take advantage of Automake 1.2.
  46589.  
  46590.    * Added the beginnings of a benchmark suite.
  46591.  
  46592.    * Added more secure password handling.
  46593.  
  46594.    * Added new client function `mysql_errno()', to get the error number
  46595.      of the error message. This makes error checking in the client much
  46596.      easier.  This makes the new server incompatible with the 3.20.x
  46597.      server when running without `--old-protocol'.  The client code is
  46598.      backward compatible.  More information can be found in the
  46599.      `README' file!
  46600.  
  46601.    * Fixed some problems when using very long, illegal names.
  46602.  
  46603. 
  46604. File: mysql.info,  Node: News-3.21.6,  Next: News-3.21.5,  Prev: News-3.21.7,  Up: News-3.21.x
  46605.  
  46606. Changes in release 3.21.6
  46607. -------------------------
  46608.  
  46609.    * Fixed more portability issues (incorrect `sigwait' and `sigset'
  46610.      defines).
  46611.  
  46612.    * `configure' should now be able to detect the last argument to
  46613.      `accept()'.
  46614.  
  46615. 
  46616. File: mysql.info,  Node: News-3.21.5,  Next: News-3.21.4,  Prev: News-3.21.6,  Up: News-3.21.x
  46617.  
  46618. Changes in release 3.21.5
  46619. -------------------------
  46620.  
  46621.    * Should now work with FreeBSD 3.0 if used with
  46622.      `FreeBSD-3.0-libc_r-1.0.diff', which can be found at
  46623.      `http://www.mysql.com/Downloads/Patches/'.
  46624.  
  46625.    * Added new option `-O tmp_table_size=#' to `mysqld'.
  46626.  
  46627.    * New function `FROM_UNIXTIME(timestamp)' which returns a date
  46628.      string in 'YYYY-MM-DD HH:MM:DD' format.
  46629.  
  46630.    * New function `SEC_TO_TIME(seconds)' which returns a string in
  46631.      'HH:MM:SS' format.
  46632.  
  46633.    * New function `SUBSTRING_INDEX()', originally by Zeev Suraski.
  46634.  
  46635. 
  46636. File: mysql.info,  Node: News-3.21.4,  Next: News-3.21.3,  Prev: News-3.21.5,  Up: News-3.21.x
  46637.  
  46638. Changes in release 3.21.4
  46639. -------------------------
  46640.  
  46641.    * Should now configure and compile on OSF1 4.0 with the DEC compiler.
  46642.  
  46643.    * Configuration and compilation on BSD/OS 3.0 works, but due to some
  46644.      bugs in BSD/OS 3.0, `mysqld' doesn't work on it yet.
  46645.  
  46646.    * Configuration and compilation on FreeBSD 3.0 works, but I couldn't
  46647.      get `pthread_create' to work.
  46648.  
  46649. 
  46650. File: mysql.info,  Node: News-3.21.3,  Next: News-3.21.2,  Prev: News-3.21.4,  Up: News-3.21.x
  46651.  
  46652. Changes in release 3.21.3
  46653. -------------------------
  46654.  
  46655.    * Added reverse check lookup of hostnames to get better security.
  46656.  
  46657.    * Fixed some possible buffer overflows if filenames that are too
  46658.      long are used.
  46659.  
  46660.    * `mysqld' doesn't accept hostnames that start with digits followed
  46661.      by a `'.'', because the hostname may look like an IP number.
  46662.  
  46663.    * Added `--skip-networking' option to `mysqld', to only allow socket
  46664.      connections.  (This will not work with MIT-pthreads!)
  46665.  
  46666.    * Added check of too long table names for alias.
  46667.  
  46668.    * Added check if database name is okay.
  46669.  
  46670.    * Added check if too long table names.
  46671.  
  46672.    * Removed incorrect `free()' that killed the server on `CREATE
  46673.      DATABASE' or `DROP DATABASE'.
  46674.  
  46675.    * Changed some `mysqld' `-O' options to better names.
  46676.  
  46677.    * Added `-O join_cache_size=#' option to `mysqld'.
  46678.  
  46679.    * Added `-O max_join_size=#' option to `mysqld', to be able to set a
  46680.      limit how big queries (in this case big = slow) one should be able
  46681.      to handle without specifying `SET OPTION SQL_BIG_SELECTS=1'.  A #
  46682.      = is about 10 examined records. The default is "unlimited".
  46683.  
  46684.    * When comparing a `TIME', `DATE', `DATETIME' or `TIMESTAMP' column
  46685.      to a constant, the constant is converted to a time value before
  46686.      performing the comparison.  This will make it easier to get ODBC
  46687.      (particularly Access97) to work with the above types. It should
  46688.      also make dates easier to use and the comparisons should be
  46689.      quicker than before.
  46690.  
  46691.    * Applied patch from Jochen Wiedmann that allows `query()' in
  46692.      `mysqlperl' to take a query with `\0' in it.
  46693.  
  46694.    * Storing a timestamp with a 2-digit year (`YYMMDD') didn't work.
  46695.  
  46696.    * Fix that timestamp wasn't automatically updated if set in an
  46697.      `UPDATE' clause.
  46698.  
  46699.    * Now the automatic timestamp field is the FIRST timestamp field.
  46700.  
  46701.    * `SELECT * INTO OUTFILE', which didn't correctly if the outfile
  46702.      already existed.
  46703.  
  46704.    * `mysql' now shows the thread ID when starting or doing a reconnect.
  46705.  
  46706.    * Changed the default sort buffer size from 2M to 1M.
  46707.  
  46708. 
  46709. File: mysql.info,  Node: News-3.21.2,  Next: News-3.21.0,  Prev: News-3.21.3,  Up: News-3.21.x
  46710.  
  46711. Changes in release 3.21.2
  46712. -------------------------
  46713.  
  46714.    * The range optimizer is coded, but only 85% tested. It can be
  46715.      enabled with `--new', but it crashes core a lot yet...
  46716.  
  46717.    * More portable. Should compile on AIX and alpha-digital.  At least
  46718.      the `isam' library should be relatively 64-bit clean.
  46719.  
  46720.    * New `isamchk' which can detect and fix more problems.
  46721.  
  46722.    * New options for `isamlog'.
  46723.  
  46724.    * Using new version of Automake.
  46725.  
  46726.    * Many small portability changes (from the AIX and alpha-digital
  46727.      port) Better checking of pthread(s) library.
  46728.  
  46729.    * czech error messages by <snajdr@pvt.net>.
  46730.  
  46731.    * Decreased size of some buffers to get fewer problems on systems
  46732.      with little memory.  Also added more checks to handle "out of
  46733.      memory" problems.
  46734.  
  46735.    * `mysqladmin': you can now do `mysqladmin kill 5,6,7,8' to kill
  46736.      multiple threads.
  46737.  
  46738.    * When the maximum connection limit is reached, one extra connection
  46739.      by a user with the *PROCESS_ACL* privilege is granted.
  46740.  
  46741.    * Added `-O backlog=#' option to `mysqld'.
  46742.  
  46743.    * Increased maximum packet size from 512K to 1024K for client.
  46744.  
  46745.    * Almost all of the function code is now tested in the internal test
  46746.      suite.
  46747.  
  46748.    * `ALTER TABLE' now returns warnings from field conversions.
  46749.  
  46750.    * Port changed to 3306 (got it reserved from ISI).
  46751.  
  46752.    * Added a fix for Visual FoxBase so that any schema name from a table
  46753.      specification is automatically removed.
  46754.  
  46755.    * New function `ASCII()'.
  46756.  
  46757.    * Removed function `BETWEEN(a,b,c)'. Use the standard ANSI syntax
  46758.      instead: `expr BETWEEN expr AND expr'.
  46759.  
  46760.    * MySQL no longer has to use an extra temporary table when sorting
  46761.      on functions or `SUM()' functions.
  46762.  
  46763.    * Fixed bug that you couldn't use `tbl_name.field_name' in `UPDATE'.
  46764.  
  46765.    * Fixed `SELECT DISTINCT' when using 'hidden group'. For example:
  46766.           mysql> SELECT DISTINCT MOD(some_field,10) FROM test
  46767.                      GROUP BY some_field;
  46768.      Note: `some_field' is normally in the `SELECT' part. ANSI SQL
  46769.      should require it.
  46770.  
  46771. 
  46772. File: mysql.info,  Node: News-3.21.0,  Prev: News-3.21.2,  Up: News-3.21.x
  46773.  
  46774. Changes in release 3.21.0
  46775. -------------------------
  46776.  
  46777.    * New reserved words used: `INTERVAL', `EXPLAIN', `READ', `WRITE',
  46778.      `BINARY'.
  46779.  
  46780.    * Added ODBC function `CHAR(num,...)'.
  46781.  
  46782.    * New operator `IN'. This uses a binary search to find a match.
  46783.  
  46784.    * New command `LOCK TABLES tbl_name [AS alias] {READ|WRITE} ...'
  46785.  
  46786.    * Added `--log-update' option to `mysqld', to get a log suitable for
  46787.      incremental updates.
  46788.  
  46789.    * New command `EXPLAIN SELECT ...' to get information about how the
  46790.      optimizer will do the join.
  46791.  
  46792.    * For easier client code, the client should no longer use
  46793.      `FIELD_TYPE_TINY_BLOB', `FIELD_TYPE_MEDIUM_BLOB',
  46794.      `FIELD_TYPE_LONG_BLOB' or `FIELD_TYPE_VAR_STRING' (as previously
  46795.      returned by `mysql_list_fields').  You should instead only use
  46796.      `FIELD_TYPE_BLOB' or `FIELD_TYPE_STRING'.  If you want exact
  46797.      types, you should use the command `SHOW FIELDS'.
  46798.  
  46799.    * Added varbinary syntax: `0x######' which can be used as a string
  46800.      (default) or a number.
  46801.  
  46802.    * `FIELD_TYPE_CHAR' is renamed to `FIELD_TYPE_TINY'.
  46803.  
  46804.    * Changed all fields to C++ classes.
  46805.  
  46806.    * Removed FORM struct.
  46807.  
  46808.    * Fields with `DEFAULT' values no longer need to be `NOT NULL'.
  46809.  
  46810.    * New field types:
  46811.     `ENUM'
  46812.           A string which can take only a couple of defined values. The
  46813.           value is stored as a 1-3 byte number that is mapped
  46814.           automatically to a string.  This is sorted according to
  46815.           string positions!
  46816.  
  46817.     `SET'
  46818.           A string which may have one or many string values separated
  46819.           with ','.  The string is stored as a 1-, 2-, 3-, 4- or 8-byte
  46820.           number where each bit stands for a specific set member.  This
  46821.           is sorted according to the unsigned value of the stored
  46822.           packed number.
  46823.  
  46824.    * Now all function calculation is done with `double' or `long long'.
  46825.      This will provide the full 64-bit range with bit functions and fix
  46826.      some conversions that previously could result in precision losses.
  46827.      One should avoid using `unsigned long long' columns with full
  46828.      64-bit range (numbers bigger than 9223372036854775807) because
  46829.      calculations are done with `signed long long'.
  46830.  
  46831.    * `ORDER BY' will now put `NULL' field values first. `GROUP BY' will
  46832.      also work with `NULL' values.
  46833.  
  46834.    * Full `WHERE' with expressions.
  46835.  
  46836.    * New range optimizer that can resolve ranges when some keypart
  46837.      prefix is constant. Example:
  46838.           mysql> SELECT * FROM tbl_name
  46839.                      WHERE key_part_1="customer"
  46840.                      AND key_part_2>=10 AND key_part_2<=10;
  46841.  
  46842. 
  46843. File: mysql.info,  Node: News-3.20.x,  Next: News-3.19.x,  Prev: News-3.21.x,  Up: News
  46844.  
  46845. Changes in release 3.20.x
  46846. =========================
  46847.  
  46848. Version 3.20 is quite old now, and should be avoided if possible.  This
  46849. information is kept here for historical purposes only.
  46850.  
  46851. Changes from 3.20.18 to 3.20.32b are not documented here because the
  46852. 3.21 release branched here. And the relevant changes are also
  46853. documented as changes to the 3.21 version.
  46854.  
  46855. * Menu:
  46856.  
  46857. * News-3.20.18::                Changes in release 3.20.18
  46858. * News-3.20.17::                Changes in release 3.20.17
  46859. * News-3.20.16::                Changes in release 3.20.16
  46860. * News-3.20.15::                Changes in release 3.20.15
  46861. * News-3.20.14::                Changes in release 3.20.14
  46862. * News-3.20.13::                Changes in release 3.20.13
  46863. * News-3.20.11::                Changes in release 3.20.11
  46864. * News-3.20.10::                Changes in release 3.20.10
  46865. * News-3.20.9::                 Changes in release 3.20.9
  46866. * News-3.20.8::                 Changes in release 3.20.8
  46867. * News-3.20.7::                 Changes in release 3.20.7
  46868. * News-3.20.6::                 Changes in release 3.20.6
  46869. * News-3.20.3::                 Changes in release 3.20.3
  46870. * News-3.20.0::                 Changes in releases 3.20.0
  46871.  
  46872. 
  46873. File: mysql.info,  Node: News-3.20.18,  Next: News-3.20.17,  Prev: News-3.20.x,  Up: News-3.20.x
  46874.  
  46875. Changes in release 3.20.18
  46876. --------------------------
  46877.  
  46878.    * Added `-p#' (remove `#' directories from path) to `isamlog'.  All
  46879.      files are written with a relative path from the database directory
  46880.      Now `mysqld' shouldn't crash on shutdown when using the
  46881.      `--log-isam' option.
  46882.  
  46883.    * New `mysqlperl' version. It is now compatible with `msqlperl-0.63'.
  46884.  
  46885.    * New `DBD' module available at
  46886.      `http://www.mysql.com/Downloads/Contrib/' site.
  46887.  
  46888.    * Added group function `STD()' (standard deviation).
  46889.  
  46890.    * The `mysqld' server is now compiled by default without debugging
  46891.      information.  This will make the daemon smaller and faster.
  46892.  
  46893.    * Now one usually only has to specify the `--basedir' option to
  46894.      `mysqld'. All other paths are relative in a normal installation.
  46895.  
  46896.    * `BLOB' columns sometimes contained garbage when used with a
  46897.      `SELECT' on more than one table and `ORDER BY'.
  46898.  
  46899.    * Fixed that calculations that are not in `GROUP BY' work as expected
  46900.      (ANSI SQL extension).  Example:
  46901.           mysql> SELECT id,id+1 FROM table GROUP BY id;
  46902.  
  46903.    * The test of using `MYSQL_PWD' was reversed. Now `MYSQL_PWD' is
  46904.      enabled as default in the default release.
  46905.  
  46906.    * Fixed conversion bug which caused `mysqld' to core dump with
  46907.      Arithmetic error on Sparc-386.
  46908.  
  46909.    * Added `--unbuffered' option to `mysql', for new `mysqlaccess'.
  46910.  
  46911.    * When using overlapping (unnecessary) keys and join over many
  46912.      tables, the optimizer could get confused and return 0 records.
  46913.  
  46914. 
  46915. File: mysql.info,  Node: News-3.20.17,  Next: News-3.20.16,  Prev: News-3.20.18,  Up: News-3.20.x
  46916.  
  46917. Changes in release 3.20.17
  46918. --------------------------
  46919.  
  46920.    * You can now use `BLOB' columns and the functions `IS NULL' and `IS
  46921.      NOT NULL' in the `WHERE' clause.
  46922.  
  46923.    * All communication packets and row buffers are now allocated
  46924.      dynamically on demand. The default value of `max_allowed_packet'
  46925.      is now 64K for the server and 512K for the client. This is mainly
  46926.      used to catch incorrect packets that could trash all memory. The
  46927.      server limit may be changed when it is started.
  46928.  
  46929.    * Changed stack usage to use less memory.
  46930.  
  46931.    * Changed `safe_mysqld' to check for running daemon.
  46932.  
  46933.    * The `ELT()' function is renamed to `FIELD()'.  The new `ELT()'
  46934.      function returns a value based on an index: `FIELD()' is the
  46935.      inverse of `ELT()' Example: `ELT(2,"A","B","C")' returns `"B"'.
  46936.      `FIELD("B","A","B","C")' returns `2'.
  46937.  
  46938.    * `COUNT(field)', where `field' could have a `NULL' value, now works.
  46939.  
  46940.    * A couple of bugs fixed in `SELECT ... GROUP BY'.
  46941.  
  46942.    * Fixed memory overrun bug in `WHERE' with many unoptimizable brace
  46943.      levels.
  46944.  
  46945.    * Fixed some small bugs in the grant code.
  46946.  
  46947.    * If hostname isn't found by `get_hostname', only the IP is checked.
  46948.      Previously, you got `Access denied'.
  46949.  
  46950.    * Inserts of timestamps with values didn't always work.
  46951.  
  46952.    * `INSERT INTO ... SELECT ... WHERE' could give the error
  46953.      `Duplicated field'.
  46954.  
  46955.    * Added some tests to `safe_mysqld' to make it "safer".
  46956.  
  46957.    * `LIKE' was case sensitive in some places and case insensitive in
  46958.      others.  Now `LIKE' is always case insensitive.
  46959.  
  46960.    * `mysql.cc': Allow `'#'' anywhere on the line.
  46961.  
  46962.    * New command `SET OPTION SQL_SELECT_LIMIT=#'. See the FAQ for more
  46963.      details.
  46964.  
  46965.    * New version of the `mysqlaccess' script.
  46966.  
  46967.    * Change `FROM_DAYS()' and `WEEKDAY()' to also take a full
  46968.      `TIMESTAMP' or `DATETIME' as argument. Before they only took a
  46969.      number of type `YYYYMMDD' or `YYMMDD'.
  46970.  
  46971.    * Added new function `UNIX_TIMESTAMP(timestamp_column)'.
  46972.  
  46973. 
  46974. File: mysql.info,  Node: News-3.20.16,  Next: News-3.20.15,  Prev: News-3.20.17,  Up: News-3.20.x
  46975.  
  46976. Changes in release 3.20.16
  46977. --------------------------
  46978.  
  46979.    * More changes in MIT-pthreads to get them safer. Fixed also some
  46980.      link bugs at least in SunOS.
  46981.  
  46982.    * Changed `mysqld' to work around a bug in MIT-pthreads. This makes
  46983.      multiple small `SELECT' operations 20 times faster. Now
  46984.      `lock_test.pl' should work.
  46985.  
  46986.    * Added `mysql_FetchHash(handle)' to `mysqlperl'.
  46987.  
  46988.    * The `mysqlbug' script is now distributed built to allow for
  46989.      reporting bugs that appear during the build with it.
  46990.  
  46991.    * Changed `libmysql.c' to prefer `getpwuid()' instead of `cuserid()'.
  46992.  
  46993.    * Fixed bug in `SELECT' optimizer when using many tables with the
  46994.      same column used as key to different tables.
  46995.  
  46996.    * Added new latin2 and Russian KOI8 character tables.
  46997.  
  46998.    * Added support for a dummy `GRANT' command to satisfy Powerbuilder.
  46999.  
  47000. 
  47001. File: mysql.info,  Node: News-3.20.15,  Next: News-3.20.14,  Prev: News-3.20.16,  Up: News-3.20.x
  47002.  
  47003. Changes in release 3.20.15
  47004. --------------------------
  47005.  
  47006.    * Fixed fatal bug `packets out of order' when using MIT-pthreads.
  47007.  
  47008.    * Removed possible loop when a thread waits for command from client
  47009.      and `fcntl()' fails. Thanks to Mike Bretz for finding this bug.
  47010.  
  47011.    * Changed alarm loop in `mysqld.cc' because shutdown didn't always
  47012.      succeed in Linux.
  47013.  
  47014.    * Removed use of `termbits' from `mysql.cc'.  This conflicted with
  47015.      `glibc' 2.0.
  47016.  
  47017.    * Fixed some syntax errors for at least BSD and Linux.
  47018.  
  47019.    * Fixed bug when doing a `SELECT' as superuser without a database.
  47020.  
  47021.    * Fixed bug when doing `SELECT' with group calculation to outfile.
  47022.  
  47023. 
  47024. File: mysql.info,  Node: News-3.20.14,  Next: News-3.20.13,  Prev: News-3.20.15,  Up: News-3.20.x
  47025.  
  47026. Changes in release 3.20.14
  47027. --------------------------
  47028.  
  47029.    * If one gives `-p' or `--password' option to `mysql' without an
  47030.      argument, the user is solicited for the password from the tty.
  47031.  
  47032.    * Added default password from `MYSQL_PWD' (by Elmar Haneke).
  47033.  
  47034.    * Added command `kill' to `mysqladmin' to kill a specific MySQL
  47035.      thread.
  47036.  
  47037.    * Sometimes when doing a reconnect on a down connection this
  47038.      succeeded first on second try.
  47039.  
  47040.    * Fixed adding an `AUTO_INCREMENT' key with `ALTER_TABLE'.
  47041.  
  47042.    * `AVG()' gave too small value on some `SELECT's with `GROUP BY' and
  47043.      `ORDER BY'.
  47044.  
  47045.    * Added new `DATETIME' type (by Giovanni Maruzzelli
  47046.      <maruzz@matrice.it>).
  47047.  
  47048.    * Fixed that define `DONT_USE_DEFAULT_FIELDS' works.
  47049.  
  47050.    * Changed to use a thread to handle alarms instead of signals on
  47051.      Solaris to avoid race conditions.
  47052.  
  47053.    * Fixed default length of signed numbers. (George Harvey
  47054.      <georgeh@pinacl.co.uk>.)
  47055.  
  47056.    * Allow anything for `CREATE INDEX'.
  47057.  
  47058.    * Add prezeros when packing numbers to `DATE', `TIME' and
  47059.      `TIMESTAMP'.
  47060.  
  47061.    * Fixed a bug in `OR' of multiple tables (gave empty set).
  47062.  
  47063.    * Added many patches to MIT-pthreads. This fixes at least one lookup
  47064.      bug.
  47065.  
  47066. 
  47067. File: mysql.info,  Node: News-3.20.13,  Next: News-3.20.11,  Prev: News-3.20.14,  Up: News-3.20.x
  47068.  
  47069. Changes in release 3.20.13
  47070. --------------------------
  47071.  
  47072.    * Added ANSI SQL94 `DATE' and `TIME' types.
  47073.  
  47074.    * Fixed bug in `SELECT' with `AND'-`OR' levels.
  47075.  
  47076.    * Added support for Slovenian characters. The `Contrib' directory
  47077.      contains source and instructions for adding other character sets.
  47078.  
  47079.    * Fixed bug with `LIMIT' and `ORDER BY'.
  47080.  
  47081.    * Allow `ORDER BY' and `GROUP BY' on items that aren't in the
  47082.      `SELECT' list.  (Thanks to Wim Bonis <bonis@kiss.de>, for pointing
  47083.      this out.)
  47084.  
  47085.    * Allow setting of timestamp values in `INSERT'.
  47086.  
  47087.    * Fixed bug with `SELECT ... WHERE ... = NULL'.
  47088.  
  47089.    * Added changes for `glibc' 2.0. To get `glibc' to work, you should
  47090.      add the `gibc-2.0-sigwait-patch' before compiling `glibc'.
  47091.  
  47092.    * Fixed bug in `ALTER TABLE' when changing a `NOT NULL' field to
  47093.      allow `NULL' values.
  47094.  
  47095.    * Added some ANSI92 synonyms as field types to `CREATE TABLE'.
  47096.      `CREATE TABLE' now allows `FLOAT(4)' and `FLOAT(8)' to mean
  47097.      `FLOAT' and `DOUBLE'.
  47098.  
  47099.    * New utility program `mysqlaccess' by <Yves.Carlier@rug.ac.be>.
  47100.      This program shows the access rights for a specific user and the
  47101.      grant rows that determine this grant.
  47102.  
  47103.    * Added `WHERE const op field' (by <bonis@kiss.de>).
  47104.  
  47105. 
  47106. File: mysql.info,  Node: News-3.20.11,  Next: News-3.20.10,  Prev: News-3.20.13,  Up: News-3.20.x
  47107.  
  47108. Changes in release 3.20.11
  47109. --------------------------
  47110.  
  47111.    * When using `SELECT ... INTO OUTFILE', all temporary tables are ISAM
  47112.      instead of HEAP to allow big dumps.
  47113.  
  47114.    * Changed date functions to be string functions. This fixed some
  47115.      "funny" side effects when sorting on dates.
  47116.  
  47117.    * Extended `ALTER TABLE' according to SQL92.
  47118.  
  47119.    * Some minor compatibility changes.
  47120.  
  47121.    * Added `--port' and `--socket' options to all utility programs and
  47122.      `mysqld'.
  47123.  
  47124.    * Fixed MIT-pthreads `readdir_r()'. Now `mysqladmin create database'
  47125.      and `mysqladmin drop database' should work.
  47126.  
  47127.    * Changed MIT-pthreads to use our `tempnam()'. This should fix the
  47128.      "sort aborted" bug.
  47129.  
  47130.    * Added sync of records count in `sql_update'. This fixed slow
  47131.      updates on first connection. (Thanks to Vaclav Bittner for the
  47132.      test.)
  47133.  
  47134. 
  47135. File: mysql.info,  Node: News-3.20.10,  Next: News-3.20.9,  Prev: News-3.20.11,  Up: News-3.20.x
  47136.  
  47137. Changes in release 3.20.10
  47138. --------------------------
  47139.  
  47140.    * New insert type: `INSERT INTO ... SELECT ...'
  47141.  
  47142.    * `MEDIUMBLOB' fixed.
  47143.  
  47144.    * Fixed bug in `ALTER TABLE' and `BLOB's.
  47145.  
  47146.    * `SELECT ... INTO OUTFILE' now creates the file in the current
  47147.      database directory.
  47148.  
  47149.    * `DROP TABLE' now can take a list of tables.
  47150.  
  47151.    * Oracle synonym `DESCRIBE' (`DESC').
  47152.  
  47153.    * Changes to `make_binary_distribution'.
  47154.  
  47155.    * Added some comments to installation instructions about
  47156.      `configure''s C++ link test.
  47157.  
  47158.    * Added `--without-perl' option to `configure'.
  47159.  
  47160.    * Lots of small portability changes.
  47161.  
  47162. 
  47163. File: mysql.info,  Node: News-3.20.9,  Next: News-3.20.8,  Prev: News-3.20.10,  Up: News-3.20.x
  47164.  
  47165. Changes in release 3.20.9
  47166. -------------------------
  47167.  
  47168.    * `ALTER TABLE' didn't copy null bit. As a result, fields that were
  47169.      allowed to have `NULL' values were always `NULL'.
  47170.  
  47171.    * `CREATE' didn't take numbers as `DEFAULT'.
  47172.  
  47173.    * Some compatibility changes for SunOS.
  47174.  
  47175.    * Removed `config.cache' from old distribution.
  47176.  
  47177. 
  47178. File: mysql.info,  Node: News-3.20.8,  Next: News-3.20.7,  Prev: News-3.20.9,  Up: News-3.20.x
  47179.  
  47180. Changes in release 3.20.8
  47181. -------------------------
  47182.  
  47183.    * Fixed bug with `ALTER TABLE' and multi-part keys.
  47184.  
  47185. 
  47186. File: mysql.info,  Node: News-3.20.7,  Next: News-3.20.6,  Prev: News-3.20.8,  Up: News-3.20.x
  47187.  
  47188. Changes in release 3.20.7
  47189. -------------------------
  47190.  
  47191.    * New commands: `ALTER TABLE', `SELECT ... INTO OUTFILE' and `LOAD
  47192.      DATA INFILE'.
  47193.  
  47194.    * New function: `NOW()'.
  47195.  
  47196.    * Added new field *file_priv* to `mysql/user' table.
  47197.  
  47198.    * New script `add_file_priv' which adds the new field *file_priv* to
  47199.      the `user' table. This script must be executed if you want to use
  47200.      the new `SELECT ... INTO' and `LOAD DATA INFILE ...' commands with
  47201.      a version of MySQL earlier than 3.20.7.
  47202.  
  47203.    * Fixed bug in locking code, which made `lock_test.pl' test fail.
  47204.  
  47205.    * New files `NEW' and `BUGS'.
  47206.  
  47207.    * Changed `select_test.c' and `insert_test.c' to include `config.h'.
  47208.  
  47209.    * Added command `status' to `mysqladmin' for short logging.
  47210.  
  47211.    * Increased maximum number of keys to 16 and maximum number of key
  47212.      parts to 15.
  47213.  
  47214.    * Use of sub keys. A key may now be a prefix of a string field.
  47215.  
  47216.    * Added `-k' option to `mysqlshow', to get key information for a
  47217.      table.
  47218.  
  47219.    * Added long options to `mysqldump'.
  47220.  
  47221. 
  47222. File: mysql.info,  Node: News-3.20.6,  Next: News-3.20.3,  Prev: News-3.20.7,  Up: News-3.20.x
  47223.  
  47224. Changes in release 3.20.6
  47225. -------------------------
  47226.  
  47227.    * Portable to more systems because of MIT-pthreads, which will be
  47228.      used automatically if `configure' cannot find a `-lpthreads'
  47229.      library.
  47230.  
  47231.    * Added GNU-style long options to almost all programs. Test with
  47232.      `program --help'.
  47233.  
  47234.    * Some shared library support for Linux.
  47235.  
  47236.    * The FAQ is now in `.texi' format and is available in `.html',
  47237.      `.txt' and `.ps' formats.
  47238.  
  47239.    * Added new SQL function `RAND([init])'.
  47240.  
  47241.    * Changed `sql_lex' to handle `\0' unquoted, but the client can't
  47242.      send the query through the C API, because it takes a str pointer.
  47243.      You must use `mysql_real_query()' to send the query.
  47244.  
  47245.    * Added API function `mysql_get_client_info()'.
  47246.  
  47247.    * `mysqld' now uses the `N_MAX_KEY_LENGTH' from `nisam.h' as the
  47248.      maximum allowed key length.
  47249.  
  47250.    * The following now works:
  47251.           mysql> SELECT filter_nr,filter_nr FROM filter ORDER BY filter_nr;
  47252.      Previously, this resulted in the error: `Column: 'filter_nr' in
  47253.      order clause is ambiguous'.
  47254.  
  47255.    * `mysql' now outputs `'\0'', `'\t'', `'\n'' and `'\\'' when
  47256.      encountering ASCII 0, tab, newline or `'\'' while writing
  47257.      tab-separated output.  This is to allow printing of binary data in
  47258.      a portable format.  To get the old behavior, use `-r' (or `--raw').
  47259.  
  47260.    * Added german error messages (60 of 80 error messages translated).
  47261.  
  47262.    * Added new API function `mysql_fetch_lengths(MYSQL_RES *)', which
  47263.      returns an array of column lengths (of type `uint').
  47264.  
  47265.    * Fixed bug with `IS NULL' in `WHERE' clause.
  47266.  
  47267.    * Changed the optimizer a little to get better results when
  47268.      searching on a key part.
  47269.  
  47270.    * Added `SELECT' option `STRAIGHT_JOIN' to tell the optimizer that
  47271.      it should join tables in the given order.
  47272.  
  47273.    * Added support for comments starting with `'--'' in `mysql.cc'
  47274.      (Postgres syntax).
  47275.  
  47276.    * You can have `SELECT' expressions and table columns in a `SELECT'
  47277.      which are not used in the group part. This makes it efficient to
  47278.      implement lookups.  The column that is used should be a constant
  47279.      for each group because the value is calculated only once for the
  47280.      first row that is found for a group.
  47281.           mysql> SELECT id,lookup.text,sum(*) FROM test,lookup
  47282.                    WHERE test.id=lookup.id GROUP BY id;
  47283.  
  47284.    * Fixed bug in `SUM(function)' (could cause a core dump).
  47285.  
  47286.    * Changed `AUTO_INCREMENT' placement in the SQL query:
  47287.           INSERT into table (auto_field) values (0);
  47288.      inserted 0, but it should insert an `AUTO_INCREMENT' value.
  47289.  
  47290.    * `mysqlshow.c': Added number of records in table. Had to change the
  47291.      client code a little to fix this.
  47292.  
  47293.    * `mysql' now allows doubled `''' or `""' within strings for
  47294.      embedded `'' or `"'.
  47295.  
  47296.    * New math functions: `EXP()', `LOG()', `SQRT()', `ROUND()',
  47297.      `CEILING()'.
  47298.  
  47299. 
  47300. File: mysql.info,  Node: News-3.20.3,  Next: News-3.20.0,  Prev: News-3.20.6,  Up: News-3.20.x
  47301.  
  47302. Changes in release 3.20.3
  47303. -------------------------
  47304.  
  47305.    * The `configure' source now compiles a thread-free client library
  47306.      `-lmysqlclient'. This is the only library that needs to be linked
  47307.      with client applications.  When using the binary releases, you must
  47308.      link with `-lmysql -lmysys -ldbug -lstrings' as before.
  47309.  
  47310.    * New `readline' library from `bash-2.0'.
  47311.  
  47312.    * LOTS of small changes to `configure' and makefiles (and related
  47313.      source).
  47314.  
  47315.    * It should now be possible to compile in another directory using
  47316.      `VPATH'. Tested with GNU Make 3.75.
  47317.  
  47318.    * `safe_mysqld' and `mysql.server' changed to be more compatible
  47319.      between the source and the binary releases.
  47320.  
  47321.    * `LIMIT' now takes one or two numeric arguments.  If one argument
  47322.      is given, it indicates the maximum number of rows in a result. If
  47323.      two arguments are given, the first argument indicates the offset
  47324.      of the first row to return, the second is the maximum number of
  47325.      rows.  With this it's easy to do a poor man's next page/previous
  47326.      page WWW application.
  47327.  
  47328.    * Changed name of SQL function `FIELDS()' to `ELT()'.  Changed SQL
  47329.      function `INTERVALL()' to `INTERVAL()'.
  47330.  
  47331.    * Made `SHOW COLUMNS' a synonym for `SHOW FIELDS'.  Added
  47332.      compatibility syntax `FRIEND KEY' to `CREATE TABLE'. In MySQL,
  47333.      this creates a non-unique key on the given columns.
  47334.  
  47335.    * Added `CREATE INDEX' and `DROP INDEX' as compatibility functions.
  47336.      In MySQL, `CREATE INDEX' only checks if the index exists and
  47337.      issues an error if it doesn't exist. `DROP INDEX' always succeeds.
  47338.  
  47339.    * `mysqladmin.c': added client version to version information.
  47340.  
  47341.    * Fixed core dump bug in `sql_acl' (core on new connection).
  47342.  
  47343.    * Removed `host', `user' and `db' tables from database `test' in the
  47344.      distribution.
  47345.  
  47346.    * `FIELD_TYPE_CHAR' can now be signed (-128 - 127) or unsigned (0 -
  47347.      255) Previously, it was always unsigned.
  47348.  
  47349.    * Bug fixes in `CONCAT()' and `WEEKDAY()'.
  47350.  
  47351.    * Changed a lot of source to get `mysqld' to be compiled with SunPro
  47352.      compiler.
  47353.  
  47354.    * SQL functions must now have a `'('' immediately after the function
  47355.      name (no intervening space).  For example, `'user('' is regarded
  47356.      as beginning a function call, and `'user ('' is regarded as an
  47357.      identifier `user' followed by a `'('', not as a function call.
  47358.  
  47359. 
  47360. File: mysql.info,  Node: News-3.20.0,  Prev: News-3.20.3,  Up: News-3.20.x
  47361.  
  47362. Changes in release 3.20.0
  47363. -------------------------
  47364.  
  47365.    * The source distribution is done with `configure' and Automake.  It
  47366.      will make porting much easier.  The `readline' library is included
  47367.      in the distribution.
  47368.  
  47369.    * Separate client compilation: the client code should be very easy
  47370.      to compile on systems which don't have threads.
  47371.  
  47372.    * The old Perl interface code is automatically compiled and
  47373.      installed.  Automatic compiling of `DBD' will follow when the new
  47374.      `DBD' code is ported.
  47375.  
  47376.    * Dynamic language support: `mysqld' can now be started with Swedish
  47377.      or English (default) error messages.
  47378.  
  47379.    * New functions: `INSERT()', `RTRIM()', `LTRIM()' and `FORMAT()'.
  47380.  
  47381.    * `mysqldump' now works correctly for all field types (even
  47382.      `AUTO_INCREMENT'). The format for `SHOW FIELDS FROM tbl_name' is
  47383.      changed so the `Type' column contains information suitable for
  47384.      `CREATE TABLE'.  In previous releases, some `CREATE TABLE'
  47385.      information had to be patched when re-creating tables.
  47386.  
  47387.    * Some parser bugs from 3.19.5 (`BLOB' and `TIMESTAMP') are
  47388.      corrected.  `TIMESTAMP' now returns different date information
  47389.      depending on its create length.
  47390.  
  47391.    * Changed parser to allow a database, table or field name to start
  47392.      with a number or `'_''.
  47393.  
  47394.    * All old C code from Unireg changed to C++ and cleaned up. This
  47395.      makes the daemon a little smaller and easier to understand.
  47396.  
  47397.    * A lot of small bug fixes done.
  47398.  
  47399.    * New `INSTALL' files (not final version) and some information
  47400.      regarding porting.
  47401.  
  47402. 
  47403. File: mysql.info,  Node: News-3.19.x,  Prev: News-3.20.x,  Up: News
  47404.  
  47405. Changes in release 3.19.x
  47406. =========================
  47407.  
  47408. Version 3.19 is quite old now, and should be avoided if possible.  This
  47409. information is kept here for historical purposes only.
  47410.  
  47411. * Menu:
  47412.  
  47413. * News-3.19.5::                 Changes in release 3.19.5
  47414. * News-3.19.4::                 Changes in release 3.19.4
  47415. * News-3.19.3::                 Changes in release 3.19.3
  47416.  
  47417. 
  47418. File: mysql.info,  Node: News-3.19.5,  Next: News-3.19.4,  Prev: News-3.19.x,  Up: News-3.19.x
  47419.  
  47420. Changes in release 3.19.5
  47421. -------------------------
  47422.  
  47423.    * Some new functions, some more optimization on joins.
  47424.  
  47425.    * Should now compile clean on Linux (2.0.x).
  47426.  
  47427.    * Added functions `DATABASE()', `USER()', `POW()', `LOG10()' (needed
  47428.      for ODBC).
  47429.  
  47430.    * In a `WHERE' with an `ORDER BY' on fields from only one table, the
  47431.      table is now preferred as first table in a multi-join.
  47432.  
  47433.    * `HAVING' and `IS NULL' or `IS NOT NULL' now works.
  47434.  
  47435.    * A group on one column and a sort on a group function (`SUM()',
  47436.      `AVG()'...) didn't work together. Fixed.
  47437.  
  47438.    * `mysqldump': Didn't send password to server.
  47439.  
  47440. 
  47441. File: mysql.info,  Node: News-3.19.4,  Next: News-3.19.3,  Prev: News-3.19.5,  Up: News-3.19.x
  47442.  
  47443. Changes in release 3.19.4
  47444. -------------------------
  47445.  
  47446.    * Fixed horrible locking bug when inserting in one thread and reading
  47447.      in another thread.
  47448.  
  47449.    * Fixed one-off decimal bug.  1.00 was output as 1.0.
  47450.  
  47451.    * Added attribute `'Locked'' to process list as info if a query is
  47452.      locked by another query.
  47453.  
  47454.    * Fixed full magic timestamp. Timestamp length may now be 14, 12,
  47455.      10, 8, 6, 4 or 2 bytes.
  47456.  
  47457.    * Sort on some numeric functions could sort incorrectly on last
  47458.      number.
  47459.  
  47460.    * `IF(arg,syntax_error,syntax_error)' crashed.
  47461.  
  47462.    * Added functions `CEILING()', `ROUND()', `EXP()', `LOG()' and
  47463.      `SQRT()'.
  47464.  
  47465.    * Enhanced `BETWEEN' to handle strings.
  47466.  
  47467. 
  47468. File: mysql.info,  Node: News-3.19.3,  Prev: News-3.19.4,  Up: News-3.19.x
  47469.  
  47470. Changes in release 3.19.3
  47471. -------------------------
  47472.  
  47473.    * Fixed `SELECT' with grouping on `BLOB' columns not to return
  47474.      incorrect `BLOB' info. Grouping, sorting and distinct on `BLOB'
  47475.      columns will not yet work as expected (probably it will group/sort
  47476.      by the first 7 characters in the `BLOB'). Grouping on formulas
  47477.      with a fixed string size (use `MID()' on a `BLOB') should work.
  47478.  
  47479.    * When doing a full join (no direct keys) on multiple tables with
  47480.      `BLOB' fields, the `BLOB' was garbage on output.
  47481.  
  47482.    * Fixed `DISTINCT' with calculated columns.
  47483.  
  47484. 
  47485. File: mysql.info,  Node: Porting,  Next: Environment variables,  Prev: News,  Up: Top
  47486.  
  47487. Comments on porting to other systems
  47488. ************************************
  47489.  
  47490. A working Posix thread library is needed for the server. On Solaris 2.5
  47491. we use Sun PThreads (the native thread support in 2.4 and earlier
  47492. versions are not good enough) and on Linux we use LinuxThreads by Xavier
  47493. Leroy, <Xavier.Leroy@inria.fr>.
  47494.  
  47495. The hard part of porting to a new Unix variant without good native
  47496. thread support is probably to port MIT-pthreads. See
  47497. `mit-pthreads/README' and Programming POSIX Threads
  47498. (http://www.humanfactor.com/pthreads/).
  47499.  
  47500. The MySQL distribution includes a patched version of Provenzano's
  47501. Pthreads from MIT (see MIT Pthreads web page
  47502. (http://www.mit.edu:8001/people/proven/pthreads.html)). This can be
  47503. used for some operating systems that do not have POSIX threads.
  47504.  
  47505. It is also possible to use another user level thread package named FSU
  47506. Pthreads (see FSU Pthreads home page
  47507. (http://www.informatik.hu-berlin.de/~mueller/pthreads.html)). This
  47508. implementation is being used for the SCO port.
  47509.  
  47510. See the `thr_lock.c' and `thr_alarm.c' programs in the `mysys'
  47511. directory for some tests/examples of these problems.
  47512.  
  47513. Both the server and the client need a working C++ compiler (we use `gcc'
  47514. and have tried SparcWorks). Another compiler that is known to work is
  47515. the Irix `cc'.
  47516.  
  47517. To compile only the client use `./configure --without-server'.
  47518.  
  47519. There is currently no support for only compiling the server, nor is it
  47520. likly to be added unless someone has a good reason for it.
  47521.  
  47522. If you want/need to change any `Makefile' or the configure script you
  47523. must get Automake and Autoconf. We have used the `automake-1.2' and
  47524. `autoconf-2.12' distributions.
  47525.  
  47526. All steps needed to remake everything from the most basic files.
  47527.  
  47528.      /bin/rm */.deps/*.P
  47529.      /bin/rm -f config.cache
  47530.      aclocal
  47531.      autoheader
  47532.      aclocal
  47533.      automake
  47534.      autoconf
  47535.      ./configure --with-debug=full --prefix='your installation directory'
  47536.      
  47537.      # The makefiles generated above need GNU make 3.75 or newer.
  47538.      # (called gmake below)
  47539.      gmake clean all install init-db
  47540.  
  47541. If you run into problems with a new port, you may have to do some
  47542. debugging of MySQL!  *Note Debugging server::.
  47543.  
  47544. *NOTE:* Before you start debugging `mysqld', first get the test
  47545. programs `mysys/thr_alarm' and `mysys/thr_lock' to work.  This will
  47546. ensure that your thread installation has even a remote chance to work!
  47547.  
  47548. * Menu:
  47549.  
  47550. * Debugging server::            Debugging a MySQL server
  47551. * Debugging client::            Debugging a MySQL client
  47552. * The DBUG package::            The DBUG package
  47553. * Locking methods::             Locking methods
  47554. * RTS-threads::                 Comments about RTS threads
  47555. * Thread packages::             Differences between different thread packages
  47556.  
  47557. 
  47558. File: mysql.info,  Node: Debugging server,  Next: Debugging client,  Prev: Porting,  Up: Porting
  47559.  
  47560. Debugging a MySQL server
  47561. ========================
  47562.  
  47563. If you are using some functionality that is very new in MySQL, you can
  47564. try to run `mysqld' with the `--skip-new' (which will disable all new,
  47565. potentially unsafe functionality) or with `--safe-mode' which disables
  47566. a lot of optimization that may cause problems.  *Note Crashing::.
  47567.  
  47568. If `mysqld' doesn't want to start, you should check that you don't have
  47569. any `my.cnf' files that interfere with your setup!  You can check your
  47570. `my.cnf' arguments with `mysqld --print-defaults' and avoid using them
  47571. by starting with `mysqld --no-defaults ...'.
  47572.  
  47573. If `mysqld' starts to eat up CPU or memory or if it "hangs", you can
  47574. use `mysqladmin processlist status' to find out if someone is executing
  47575. a query that takes a long time.  It may be a good idea to run
  47576. `mysqladmin -i10 processlist status' in some window if you are
  47577. experiencing performance problems or problems when new clients can't
  47578. connect.
  47579.  
  47580. The command `mysqladmin debug' will dump some information about locks
  47581. in use, used memory and query usage to the mysql log file. This may
  47582. help solve some problems.  This command also provides some useful
  47583. information even if you haven't compiled MySQL for debugging!
  47584.  
  47585. If the problem is that some tables are getting slower and slower you
  47586. should try to optimize the table with `OPTIMIZE TABLE' or `myisamchk'.
  47587. *Note MySQL Database Administration::. You should also check the slow
  47588. queries with `EXPLAIN'.
  47589.  
  47590. You should also read the OS-specific section in this manual for
  47591. problems that may be unique to your environment.  *Note Operating
  47592. System Specific Notes::.
  47593.  
  47594. * Menu:
  47595.  
  47596. * Compiling for debugging::     Compiling MYSQL for debugging.
  47597. * Making trace files::          Creating trace files
  47598. * Using gdb on mysqld::         Debugging mysqld under gdb
  47599. * Using stack trace::           Using a stack trace
  47600. * Using log files::             Using log files to find cause of errors in mysqld
  47601. * Reproduceable test case::     Making a test case when you experience table corruption
  47602.  
  47603. 
  47604. File: mysql.info,  Node: Compiling for debugging,  Next: Making trace files,  Prev: Debugging server,  Up: Debugging server
  47605.  
  47606. Compiling MYSQL for debugging.
  47607. ------------------------------
  47608.  
  47609. If you have some very specific problem, you can always try to debug
  47610. MySQL.  To do this you must configure MySQL with the `--with-debug' or
  47611. the `--with-debug=full' option.  You can check whether or not MySQL was
  47612. compiled with debugging by doing: `mysqld --help'.  If the `--debug'
  47613. flag is listed with the options then you have debugging enabled.
  47614. `mysqladmin ver' also lists the `mysqld' version as `mysql ... --debug'
  47615. in this case.
  47616.  
  47617. If you are using gcc or egcs, the recommended configure line is:
  47618.  
  47619.      CC=gcc CFLAGS="-O2" CXX=gcc CXXFLAGS="-O2 -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --with-debug --with-extra-charsets=complex
  47620.  
  47621. This will avoid problems with the `libstdc++' library and with C++
  47622. exceptions (many compilers have problems with C++ exceptions in threaded
  47623. code) and compile a MySQL version with support for all character sets.
  47624.  
  47625. If you suspect a memory overrun error, you can configure MySQL with
  47626. `--with-debug=full', which will install a memory allocation
  47627. (`SAFEMALLOC') checker. Running with `SAFEMALLOC' is however quite
  47628. slow, so if you get performance problems you should start `mysqld' with
  47629. the `--skip-safemalloc' option. This will disable the memory overrun
  47630. checks for each call to `malloc' and `free'.
  47631.  
  47632. If `mysqld' stops crashing when you compile it with `--with-debug', you
  47633. have probably found a compiler bug or a timing bug within MySQL.  In
  47634. this case you can try to add `-g' to the `CFLAGS' and `CXXFLAGS'
  47635. variables above and not use `--with-debug'. If `mysqld' now dies, you
  47636. can at least attach to it with `gdb' or use `gdb' on the core file to
  47637. find out what happened.
  47638.  
  47639. When you configure MySQL for debugging you automatically enable a lot
  47640. of extra safety check functions that monitor the health of `mysqld'.
  47641. If they find something "unexpected," an entry will be written to
  47642. `stderr', which `safe_mysqld' directs to the error log!  This also
  47643. means that if you are having some unexpected problems with MySQL and
  47644. are using a source distribution, the first thing you should do is to
  47645. configure MySQL for debugging!  (The second thing, of course, is to
  47646. send mail to <mysql@lists.mysql.com> and ask for help.  Please use the
  47647. `mysqlbug' script for all bug reports or questions regarding the MySQL
  47648. version you are using!
  47649.  
  47650. In the Windows MySQL distribution, `mysqld.exe' is by default compiled
  47651. with support for trace files.
  47652.  
  47653. 
  47654. File: mysql.info,  Node: Making trace files,  Next: Using gdb on mysqld,  Prev: Compiling for debugging,  Up: Debugging server
  47655.  
  47656. Creating trace files
  47657. --------------------
  47658.  
  47659. If the `mysqld' server doesn't start or if you can cause the `mysqld'
  47660. server to crash quickly, you can try to create a trace file to find the
  47661. problem.
  47662.  
  47663. To do this you have to have a `mysqld' that is compiled for debugging.
  47664. You can check this by executing `mysqld -V'.  If the version number
  47665. ends with `-debug', it's compiled with support for trace files.
  47666.  
  47667. Start the `mysqld' server with a trace log in `/tmp/mysqld.trace' (or
  47668. `C:\mysqld.trace' on Windows):
  47669.  
  47670. `mysqld --debug'
  47671.  
  47672. On Windows you should also use the `--standalone' flag to not start
  47673. `mysqld' as a service:
  47674.  
  47675. In a DOS window do:
  47676.  
  47677.      mysqld --debug --standalone
  47678.  
  47679. After this you can use the `mysql.exe' command line tool in a second
  47680. DOS window to reproduce the problem. You can take down the above
  47681. `mysqld' server with `mysqladmin shutdown'.
  47682.  
  47683. Note that the trace file will get very _BIG_!  If you want to have a
  47684. smaller trace file, you can use something like:
  47685.  
  47686. `mysqld --debug=d,info,error,query,general,where:O,/tmp/mysqld.trace'
  47687.  
  47688. which only prints information with the most interesting tags in
  47689. `/tmp/mysqld.trace'.
  47690.  
  47691. If you make a bug report about this, please only send the lines from the
  47692. trace file to the appropriate mailing list where something seems to go
  47693. wrong! If you can't locate the wrong place, you can ftp the trace file,
  47694. together with a full bug report, to
  47695. `ftp://support.mysql.com/pub/mysql/secret' so that a MySQL developer
  47696. can take a look a this.
  47697.  
  47698. The trace file is made with the *DBUG* package by Fred Fish.  *Note The
  47699. DBUG package::.
  47700.  
  47701. 
  47702. File: mysql.info,  Node: Using gdb on mysqld,  Next: Using stack trace,  Prev: Making trace files,  Up: Debugging server
  47703.  
  47704. Debugging mysqld under gdb
  47705. --------------------------
  47706.  
  47707. On most system you can also start `mysqld' from `gdb' to get more
  47708. information if `mysqld' crashes.
  47709.  
  47710. With some older `gdb' versions on Linux you must use `run --one-thread'
  47711. if you want to be able to debug `mysqld' threads.  In this case you can
  47712. only have one thread active at a time.
  47713.  
  47714. When running `mysqld' under gdb, you should disable the stack trace
  47715. with `--skip-stack-trace' to be able to catch segfaults within gdb.
  47716.  
  47717. It's very hard to debug MySQL under `gdb' if you do a lot of new
  47718. connections the whole time as `gdb' doesn't free the memory for old
  47719. threads.  You can avoid this problem by starting `mysqld' with `-O
  47720. thread_cache_size= 'max_connections +1''.  In most cases just using `-O
  47721. thread_cache_size=5'' will help a lot!
  47722.  
  47723. If you want to get a core dump on Linux if `mysqld' dies with a SIGSEGV
  47724. signal, you can start `mysqld' with the `--core-file' option.  This
  47725. core file can be used to make a backtrace that may help you find out
  47726. why `mysqld' died:
  47727.  
  47728.      shell> gdb mysqld core
  47729.      gdb>   backtrace full
  47730.      gdb>   exit
  47731.  
  47732. *Note Crashing::.
  47733.  
  47734. If you are using gdb 4.17.x or above on Linux, you should install a
  47735. `.gdb' file, with the following information, in your current directory:
  47736.  
  47737.      set print sevenbit off
  47738.      handle SIGUSR1 nostop noprint
  47739.      handle SIGUSR2 nostop noprint
  47740.      handle SIGWAITING nostop noprint
  47741.      handle SIGLWP nostop noprint
  47742.      handle SIGPIPE nostop
  47743.      handle SIGALRM nostop
  47744.      handle SIGHUP nostop
  47745.      handle SIGTERM nostop noprint
  47746.  
  47747. If you have problems debugging threads with gdb, you should download
  47748. gdb 5.x and try this instead. The new gdb version has very improved
  47749. thread handling!
  47750.  
  47751. Here is an example how to debug mysqld:
  47752.  
  47753.      shell> gdb /usr/local/libexec/mysqld
  47754.      gdb> run
  47755.      ...
  47756.      backtrace full # Do this when mysqld crashes
  47757.  
  47758. Include the above output in a mail generated with `mysqlbug' and mail
  47759. this to `mysql@lists.mysql.com'.
  47760.  
  47761. If `mysqld' hangs you can try to use some system tools like `strace' or
  47762. `/usr/proc/bin/pstack' to examine where `mysqld' has hung.
  47763.  
  47764.      strace /tmp/log libexec/mysqld
  47765.  
  47766. If you are using the Perl `DBI' interface, you can turn on debugging
  47767. information by using the `trace' method or by setting the `DBI_TRACE'
  47768. environment variable.  *Note Perl `DBI' Class: Perl DBI Class.
  47769.  
  47770. 
  47771. File: mysql.info,  Node: Using stack trace,  Next: Using log files,  Prev: Using gdb on mysqld,  Up: Debugging server
  47772.  
  47773. Using a stack trace
  47774. -------------------
  47775.  
  47776. On some operating systems, the error log will contain a stack trace if
  47777. `mysqld' dies unexpectedly. You can use this to find out where (and
  47778. maybe why) `mysqld' died. *Note Error log::.  To get a stack trace, you
  47779. should NOT compile `mysqld' with the `-fomit-frame-pointer' option to
  47780. gcc. *Note Compiling for debugging::.
  47781.  
  47782. If the error file contains something like the following:
  47783.  
  47784.      mysqld got signal 11;
  47785.      The manual section 'Debugging a MySQL server' tells you how to use a
  47786.      stack trace and/or the core file to produce a readable backtrace that may
  47787.      help in finding out why mysqld died
  47788.      Attemping backtrace. You can use the following information to find out
  47789.      where mysqld died.  If you see no messages after this, something went
  47790.      terribly wrong
  47791.      stack range sanity check, ok, backtrace follows
  47792.      0x40077552
  47793.      0x81281a0
  47794.      0x8128f47
  47795.      0x8127be0
  47796.      0x8127995
  47797.      0x8104947
  47798.      0x80ff28f
  47799.      0x810131b
  47800.      0x80ee4bc
  47801.      0x80c3c91
  47802.      0x80c6b43
  47803.      0x80c1fd9
  47804.      0x80c1686
  47805.  
  47806. you can find where `mysqld' died by doing the following:
  47807.  
  47808.   1. Copy the above numbers to a file, for example `mysqld.stack'.
  47809.  
  47810.   2. Make a symbol file for the `mysqld' server:
  47811.           nm -n libexec/mysqld > /tmp/mysqld.sym
  47812.  
  47813.      Note that many MySQL binary distributions comes with the above
  47814.      file, named `mysqld.sym.gz'.  In this case you must unpack this by
  47815.      doing:
  47816.           gunzip < bin/mysqld.sym.gz > /tmp/mysqld.sym
  47817.  
  47818.   3. Execute `resolve_stack_dump -s /tmp/mysqld.sym -n mysqld.stack'.
  47819.  
  47820.      This will print out where `mysqld' died. If this doesn't help you
  47821.      find out why `mysqld' died, you should make a bug report and
  47822.      include the output from the above commend with the bug report.
  47823.  
  47824.      Note however that in most cases it will not help us to just have a
  47825.      stack trace to find the reason for the problem.  To be able to
  47826.      locate the bug or provide a workaround, we would in most cases
  47827.      need to know the query that killed `mysqld' and preferable a test
  47828.      case so that we can repeat the problem!  *Note Bug reports::.
  47829.  
  47830. 
  47831. File: mysql.info,  Node: Using log files,  Next: Reproduceable test case,  Prev: Using stack trace,  Up: Debugging server
  47832.  
  47833. Using log files to find cause of errors in mysqld
  47834. -------------------------------------------------
  47835.  
  47836. Note that before starting `mysqld' with `--log' you should check all
  47837. your tables with `myisamchk'.  *Note MySQL Database Administration::.
  47838.  
  47839. If `mysqld' dies or hangs, you should start `mysqld' with `--log'.
  47840. When `mysqld' dies again, you can examine the end of the log file for
  47841. the query that killed `mysqld'.
  47842.  
  47843. If you are using `--log' without a file name, the log is stored in the
  47844. database directory as 'hostname'.log In most cases it's the last query
  47845. in the log file that killed `mysqld', but if possible you should verify
  47846. this by restarting `mysqld' and executing the found query from the
  47847. `mysql' command line tools. If this works, you should also test all
  47848. complicated queries that didn't complete.
  47849.  
  47850. You can also try the command `EXPLAIN' on all `SELECT' statements that
  47851. takes a long time to ensure that `mysqld' is using indexes properly.
  47852. *Note `EXPLAIN': EXPLAIN.
  47853.  
  47854. You can find the queries that take a long time to execute by starting
  47855. `mysqld' with `--log-slow-queries'. *Note Slow query log::.
  47856.  
  47857. If you find the text `mysqld restarted' in the error log file (normally
  47858. named `hostname.err') you have probably found a query that causes
  47859. `mysqld' to fail.  If this happens you should check all your tables
  47860. with `myisamchk' (*note MySQL Database Administration::), and test the
  47861. queries in the MySQL log files to see if one doesn't work.  If you find
  47862. such a query, try first upgrading to the newest MySQL version.  If this
  47863. doesn't help and you can't find anything in the `mysql' mail archive,
  47864. you should report the bug to <mysql@lists.mysql.com>.  Links to mail
  47865. archives are available online at the MySQL documentation page
  47866. (http://www.mysql.com/documentation/).
  47867.  
  47868. If you have started `mysqld' with `--with-myisam-recover', MySQL will
  47869. automatically check and try to repair `MyISAM' tables if they are
  47870. marked as 'not closed properly' or 'crashed'.  If this happens, MySQL
  47871. will write an entry in the `hostname.err' file `'Warning: Checking
  47872. table ...'' which is followed by `Warning: Repairing table' if the
  47873. table needs to be repaired.  If you get a lot of these errors, without
  47874. `mysqld' having died unexpectedly just before, then something is wrong
  47875. and needs to be investigated further. *Note Command-line options::.
  47876.  
  47877. It's of course not a good sign if `mysqld' did died unexpectedly, but
  47878. in this case one shouldn't investigate the `Checking table...' messages
  47879. but instead try to find out why `mysqld' died.
  47880.  
  47881. 
  47882. File: mysql.info,  Node: Reproduceable test case,  Prev: Using log files,  Up: Debugging server
  47883.  
  47884. Making a test case when you experience table corruption
  47885. -------------------------------------------------------
  47886.  
  47887. If you get corrupted tables or if `mysqld' always fails after some
  47888. update commands, you can test if this bug is reproducible by doing the
  47889. following:
  47890.  
  47891.    * Take down the MySQL daemon (with `mysqladmin shutdown').
  47892.  
  47893.    * Make a backup of the tables (to guard against the very unlikely
  47894.      case that the repair will do something bad).
  47895.  
  47896.    * Check all tables with `myisamchk -s database/*.MYI'.  Repair any
  47897.      wrong tables with `myisamchk -r database/table.MYI'.
  47898.  
  47899.    * Make a second backup of the tables.
  47900.  
  47901.    * Remove (or move away) any old log files from the MySQL data
  47902.      directory if you need more space.
  47903.  
  47904.    * Start `mysqld' with `--log-bin'. *Note Binary log::.  If you want
  47905.      to find a query that crashes `mysqld', you should use `--log
  47906.      --log-bin'.
  47907.  
  47908.    * When you have gotten a crashed table, stop the `mysqld server'.
  47909.  
  47910.    * Restore the backup.
  47911.  
  47912.    * Restart the `mysqld' server *without* `--log-bin'
  47913.  
  47914.    * Re-execute the commands with `mysqlbinlog update-log-file | mysql'.
  47915.      The update log is saved in the MySQL database directory with the
  47916.      name `hostname-bin.#'.
  47917.  
  47918.    * If the tables are corrupted again or you can get `mysqld' to die
  47919.      with the above command, you have found reproducible bug that
  47920.      should be easy to fix! FTP the tables and the binary log to
  47921.      `ftp://support.mysql.com/pub/mysql/secret' and send a mail to
  47922.      <bugs@lists.mysql.com> or (if you are a support customer) to
  47923.      <support@mysql.com> about the problem and the MySQL team will fix
  47924.      it as soon as possible.
  47925.  
  47926. You can also use the script `mysql_find_rows' to just execute some of
  47927. the update statements if you want to narrow down the problem.
  47928.  
  47929. 
  47930. File: mysql.info,  Node: Debugging client,  Next: The DBUG package,  Prev: Debugging server,  Up: Porting
  47931.  
  47932. Debugging a MySQL client
  47933. ========================
  47934.  
  47935. To be able to debug a MySQL client with the integrated debug package,
  47936. you should configure MySQL with `--with-debug'.  *Note configure
  47937. options::.
  47938.  
  47939. Before running a client, you should set the `MYSQL_DEBUG' environment
  47940. variable:
  47941.  
  47942.      shell> MYSQL_DEBUG=d:t:O,/tmp/client.trace
  47943.      shell> export MYSQL_DEBUG
  47944.  
  47945. This causes clients to generate a trace file in `/tmp/client.trace'.
  47946.  
  47947. If you have problems with your own client code, you should attempt to
  47948. connect to the server and run your query using a client that is known to
  47949. work.  Do this by running `mysql' in debugging mode (assuming you have
  47950. compiled MySQL with debugging on):
  47951.  
  47952.      shell> mysql --debug=d:t:O,/tmp/client.trace
  47953.  
  47954. This will provide useful information in case you mail a bug report.
  47955. *Note Bug reports::.
  47956.  
  47957. If your client crashes at some 'legal' looking code, you should check
  47958. that your `mysql.h' include file matches your mysql library file.  A
  47959. very common mistake is to use an old `mysql.h' file from an old MySQL
  47960. installation with new MySQL library.
  47961.  
  47962. 
  47963. File: mysql.info,  Node: The DBUG package,  Next: Locking methods,  Prev: Debugging client,  Up: Porting
  47964.  
  47965. The DBUG package.
  47966. =================
  47967.  
  47968. The MySQL server and most MySQL clients are compiled with the DBUG
  47969. package originally made by Fred Fish.  When one has configured MySQL
  47970. for debugging, this package makes it possible to get a trace file of
  47971. what the program is debugging. *Note Making trace files::.
  47972.  
  47973. One uses the debug package by invoking the program with the
  47974. `--debug="..."' or the `-#...' option.
  47975.  
  47976. Most MySQL programs has a default debug string that will be used if you
  47977. don't specify an option to `--debug'.  The default trace file is
  47978. usually `/tmp/programname.trace' on Unix and `\programname.trace' on
  47979. Windows.
  47980.  
  47981. The debug control string is a sequence of colon separated fields as
  47982. follows:
  47983.  
  47984.      <field_1>:<field_2>:...:<field_N>
  47985.  
  47986. Each field consists of a mandatory flag character followed by an
  47987. optional "," and comma-separated list of modifiers:
  47988.  
  47989.      flag[,modifier,modifier,...,modifier]
  47990.  
  47991. The currently recognized flag characters are:
  47992.  
  47993. d       Enable output from DBUG_<N> macros for the current state. May be
  47994.         followed by a list of keywords which selects output only for the
  47995.         DBUG macros with that keyword. An empty list of keywords implies
  47996.         output for all macros.
  47997. D       Delay after each debugger output line. The argument is the
  47998.         number of tenths of seconds to delay, subject to machine
  47999.         capabilities. That is, `-#D,20' is delay two seconds.
  48000. f       Limit debugging and/or tracing, and profiling to the list of
  48001.         named functions.  Note that a null list will disable all
  48002.         functions.    The appropriate "d" or "t" flags must still be
  48003.         given, this flag only limits their actions if they are enabled.
  48004. F       Identify the source file name for each line of debug or trace
  48005.         output.
  48006. i       Identify the process with the pid or thread id for each line of
  48007.         debug or trace output.
  48008. g       Enable profiling.  Create a file called 'dbugmon.out' containing
  48009.         information that can be used to profile the program.  May be
  48010.         followed by a list of keywords that select profiling only for
  48011.         the functions in that list.  A null list implies that all
  48012.         functions are considered.
  48013. L       Identify the source file line number for each line of debug or
  48014.         trace output.
  48015. n       Print the current function nesting depth for each line of debug
  48016.         or trace output.
  48017. N       Number each line of dbug output.
  48018. o       Redirect the debugger output stream to the specified file.  The
  48019.         default output is stderr.
  48020. O       As `O' but the file is really flushed between each write. When
  48021.         needed the file is closed and reopened between each write.
  48022. p       Limit debugger actions to specified processes. A process must be
  48023.         identified with the DBUG_PROCESS macro and match one in the list
  48024.         for debugger actions to occur.
  48025. P       Print the current process name for each line of debug or trace
  48026.         output.
  48027. r       When pushing a new state, do not inherit the previous state's
  48028.         function nesting level. Useful when the output is to start at
  48029.         the left margin.
  48030. S       Do function _sanity(_file_,_line_) at each debugged function
  48031.         until _sanity() returns something that differs from 0. (Mostly
  48032.         used with safemalloc to find memory leaks)
  48033. t       Enable function call/exit trace lines. May be followed by a list
  48034.         (containing only one modifier) giving a numeric maximum trace
  48035.         level, beyond which no output will occur for either debugging or
  48036.         tracing macros.  The default is a compile time option.
  48037.  
  48038. Some examples of debug control strings which might appear on a shell
  48039. command line (the "-#" is typically used to introduce a control string
  48040. to an application program) are:
  48041.  
  48042.      -#d:t
  48043.      -#d:f,main,subr1:F:L:t,20
  48044.      -#d,input,output,files:n
  48045.      -#d:t:i:O,\\mysqld.trace
  48046.  
  48047. In MySQL, common tags to print (with the `d' option) are:
  48048. `enter',`exit',`error',`warning',`info' and `loop'.
  48049.  
  48050. 
  48051. File: mysql.info,  Node: Locking methods,  Next: RTS-threads,  Prev: The DBUG package,  Up: Porting
  48052.  
  48053. Locking methods
  48054. ===============
  48055.  
  48056. Currently MySQL only supports table locking for `ISAM'/`MyISAM' and
  48057. `HEAP' tables and page level locking for `BDB' tables. *Note Internal
  48058. locking::.  With `MyISAM' tables one can freely mix `INSERT' and
  48059. `SELECT' without locks (`Versioning').
  48060.  
  48061. Starting in version 3.23.33, you can analyze the table lock contention
  48062. on your system by checking `Table_locks_waited' and
  48063. `Table_locks_immediate' environment variables.
  48064.  
  48065. Some database users claim that MySQL cannot support near the number of
  48066. concurrent users because it lacks row-level locking.  This may be true
  48067. for some specific applications, but is not generally true. As always
  48068. this depends totally on what the application does and what is the
  48069. access/update pattern of the data.
  48070.  
  48071. Pros for row locking:
  48072.  
  48073.    * Fewer lock conflicts when accessing different rows in many threads.
  48074.  
  48075.    * Less changes for rollbacks.
  48076.  
  48077.    * Makes it possible to lock a single row a long time.
  48078.  
  48079. Cons:
  48080.  
  48081.    * Takes more memory than page level or table locks.
  48082.  
  48083.    * Is slower than page level or table locks when used one a big part
  48084.      of the table, because one has to do many more locks.
  48085.  
  48086.    * Is definitely much worse than other locks if you do often do `GROUP
  48087.      BY' on a large part of the data or if one has to often scan the
  48088.      whole table.
  48089.  
  48090.    * With higher level locks one can also more easily support locks of
  48091.      different types to tune the application as the lock overhead is
  48092.      less notable as for row level locks.
  48093.  
  48094. Table locks are superior to page level / row level locks in the
  48095. following cases:
  48096.  
  48097.    * Mostly reads
  48098.  
  48099.    * Read and updates on strict keys; This is where one updates or
  48100.      deletes a row that can be fetched with one key read:
  48101.           UPDATE table_name SET column=value WHERE unique_key#
  48102.           DELETE FROM table_name WHERE unique_key=#
  48103.  
  48104.    * `SELECT' combined with `INSERT' (and very few `UPDATE''s and
  48105.      `DELETE''s.
  48106.  
  48107.    * Many scans / `GROUP BY' on the whole table without any writers.
  48108.  
  48109. Other options than row / page level locking:
  48110.  
  48111. Versioning (like we use in MySQL for concurrent inserts) where you can
  48112. have one writer at the same time as many readers.  This means that the
  48113. database/table supports different views for the data depending on when
  48114. one started to access it. Other names for this are time travel, copy on
  48115. write or copy on demand.
  48116.  
  48117. Copy on demand is in many case much better than page or row level
  48118. locking; The worst case does, however, use much more memory than when
  48119. using normal locks.
  48120.  
  48121. Instead of using row level locks one can use application level locks.
  48122. (Like get_lock/release_lock in MySQL).  This works of course only in
  48123. well-behaved applications.
  48124.  
  48125. In many cases one can do an educated guess which locking type is best
  48126. for the application but generally it's very hard to say that a given
  48127. lock type is better than another; Everything depends on the application
  48128. and different part of the application may require different lock types.
  48129.  
  48130. Here are some tips about locking in MySQL:
  48131.  
  48132. On web application most applications do lots of selects, very few
  48133. deletes, updates mainly on keys and inserts in some specific tables.
  48134. The base MySQL setup is VERY tuned for this.
  48135.  
  48136. Concurrent users is not a problem if one doesn't mix updates and selects
  48137. that needs to examine many rows in the same table.
  48138.  
  48139. If one mixes inserts and deletes on the same table then `INSERT DELAYED'
  48140. may be of great help.
  48141.  
  48142. One can also use `LOCK TABLES' to speed up things (many updates within
  48143. a single lock is much faster than updates without locks).  Splitting
  48144. thing to different tables will also helps.
  48145.  
  48146. If you get speed problems with the table locks in MySQL, you may be
  48147. able to solve these to convert some of your tables to `BDB' tables.
  48148. *Note BDB::.
  48149.  
  48150. The optimization section in the manual covers a lot of different
  48151. aspects of how to tune ones application. *Note Tips::.
  48152.  
  48153. 
  48154. File: mysql.info,  Node: RTS-threads,  Next: Thread packages,  Prev: Locking methods,  Up: Porting
  48155.  
  48156. Comments about RTS threads
  48157. ==========================
  48158.  
  48159. I have tried to use the RTS thread packages with MySQL but stumbled on
  48160. the following problems:
  48161.  
  48162. They use an old version of a lot of POSIX calls and it is very tedious
  48163. to make wrappers for all functions. I am inclined to think that it would
  48164. be easier to change the thread libraries to the newest POSIX
  48165. specification.
  48166.  
  48167. Some wrappers are already written. See `mysys/my_pthread.c' for more
  48168. info.
  48169.  
  48170. At least the following should be changed:
  48171.  
  48172. `pthread_get_specific' should use one argument.  `sigwait' should take
  48173. two arguments.  A lot of functions (at least `pthread_cond_wait',
  48174. `pthread_cond_timedwait') should return the error code on error. Now
  48175. they return -1 and set `errno'.
  48176.  
  48177. Another problem is that user-level threads use the `ALRM' signal and
  48178. this aborts a lot of functions (`read', `write', `open'...).  MySQL
  48179. should do a retry on interrupt on all of these but it is not that easy
  48180. to verify it.
  48181.  
  48182. The biggest unsolved problem is the following:
  48183.  
  48184. To get thread-level alarms I changed `mysys/thr_alarm.c' to wait between
  48185. alarms with `pthread_cond_timedwait()', but this aborts with error
  48186. `EINTR'.  I tried to debug the thread library as to why this happens,
  48187. but couldn't find any easy solution.
  48188.  
  48189. If someone wants to try MySQL with RTS threads I suggest the following:
  48190.  
  48191.    * Change functions MySQL uses from the thread library to POSIX.
  48192.      This shouldn't take that long.
  48193.  
  48194.    * Compile all libraries with the `-DHAVE_rts_threads'.
  48195.  
  48196.    * Compile `thr_alarm'.
  48197.  
  48198.    * If there are some small differences in the implementation, they
  48199.      may be fixed by changing `my_pthread.h' and `my_pthread.c'.
  48200.  
  48201.    * Run `thr_alarm'. If it runs without any "warning", "error" or
  48202.      aborted messages, you are on the right track. Here is a successful
  48203.      run on Solaris:
  48204.           Main thread: 1
  48205.           Thread 0 (5) started
  48206.           Thread: 5  Waiting
  48207.           process_alarm
  48208.           Thread 1 (6) started
  48209.           Thread: 6  Waiting
  48210.           process_alarm
  48211.           process_alarm
  48212.           thread_alarm
  48213.           Thread: 6  Slept for 1 (1) sec
  48214.           Thread: 6  Waiting
  48215.           process_alarm
  48216.           process_alarm
  48217.           thread_alarm
  48218.           Thread: 6  Slept for 2 (2) sec
  48219.           Thread: 6  Simulation of no alarm needed
  48220.           Thread: 6  Slept for 0 (3) sec
  48221.           Thread: 6  Waiting
  48222.           process_alarm
  48223.           process_alarm
  48224.           thread_alarm
  48225.           Thread: 6  Slept for 4 (4) sec
  48226.           Thread: 6  Waiting
  48227.           process_alarm
  48228.           thread_alarm
  48229.           Thread: 5  Slept for 10 (10) sec
  48230.           Thread: 5  Waiting
  48231.           process_alarm
  48232.           process_alarm
  48233.           thread_alarm
  48234.           Thread: 6  Slept for 5 (5) sec
  48235.           Thread: 6  Waiting
  48236.           process_alarm
  48237.           process_alarm
  48238.           
  48239.           ...
  48240.           thread_alarm
  48241.           Thread: 5  Slept for 0 (1) sec
  48242.           end
  48243.  
  48244. 
  48245. File: mysql.info,  Node: Thread packages,  Prev: RTS-threads,  Up: Porting
  48246.  
  48247. Differences between different thread packages
  48248. =============================================
  48249.  
  48250. MySQL is very dependent on the thread package used. So when choosing a
  48251. good platform for MySQL, the thread package is very important.
  48252.  
  48253. There are at least three types of thread packages:
  48254.  
  48255.    * User threads in a single process. Thread switching is managed with
  48256.      alarms and the threads library manages all non-thread-safe
  48257.      functions with locks. Read, write and select operations are
  48258.      usually managed with a thread-specific select that switches to
  48259.      another thread if the running threads have to wait for data.  If
  48260.      the user thread packages are integrated in the standard libs
  48261.      (FreeBSD and BSDI threads) the thread package requires less
  48262.      overhead than thread packages that have to map all unsafe calls
  48263.      (MIT-pthreads, FSU Pthreads and RTS threads).  In some
  48264.      environments (for example, SCO), all system calls are thread safe
  48265.      so the mapping can be done very easily (FSU Pthreads on SCO).
  48266.      Downside: All mapped calls take a little time and it's quite
  48267.      tricky to be able to handle all situations. There are usually also
  48268.      some system calls that are not handled by the thread package (like
  48269.      MIT-pthreads and sockets). Thread scheduling isn't always optimal.
  48270.  
  48271.    * User threads in separate processes. Thread switching is done by the
  48272.      kernel and all data are shared between threads.  The thread package
  48273.      manages the standard thread calls to allow sharing data between
  48274.      threads.  LinuxThreads is using this method.  Downside: Lots of
  48275.      processes. Thread creating is slow. If one thread dies the rest
  48276.      are usually left hanging and you must kill them all before
  48277.      restarting. Thread switching is somewhat expensive.
  48278.  
  48279.    * Kernel threads. Thread switching is handled by the thread library
  48280.      or the kernel and is very fast. Everything is done in one process,
  48281.      but on some systems, `ps' may show the different threads. If one
  48282.      thread aborts, the whole process aborts. Most system calls are
  48283.      thread safe and should require very little overhead.  Solaris,
  48284.      HP-UX, AIX and OSF1 have kernel threads.
  48285.  
  48286. In some systems kernel threads are managed by integrating user level
  48287. threads in the system libraries. In such cases, the thread switching
  48288. can only be done by the thread library and the kernel isn't really
  48289. "thread aware".
  48290.  
  48291. 
  48292. File: mysql.info,  Node: Environment variables,  Next: Regexp,  Prev: Porting,  Up: Top
  48293.  
  48294. Environment Variables
  48295. *********************
  48296.  
  48297. Here is a list of all the environment variables that are used directly
  48298. or indirectly by MySQL. Most of these can also be found in other places
  48299. in this manual.
  48300.  
  48301. Note that any options on the command line will take precedence over
  48302. values specified in configuration files and environment variables, and
  48303. values in configuration files take precedence over values in environment
  48304. variables.
  48305.  
  48306. In many cases it's preferable to use a configure file instead of
  48307. environment variables to modify the behavior of MySQL. *Note Option
  48308. files::.
  48309.  
  48310. `CCX'          Set this to your C++ compiler when running configure.
  48311. `CC'           Set this to your C compiler when running configure.
  48312. `CFLAGS'       Flags for your C compiler when running configure.
  48313. `CXXFLAGS'     Flags for your C++ compiler when running configure.
  48314. `DBI_USER'     The default user name for Perl DBI.
  48315. `DBI_TRACE'    Used when tracing Perl DBI.
  48316. `HOME'         The default path for the `mysql' history file is
  48317.                `$HOME/.mysql_history'.
  48318. `LD_RUN_PATH'  Used to specify where your `libmysqlclient.so' is.
  48319. `MYSQL_DEBUG'  Debug-trace options when debugging.
  48320. `MYSQL_HISTFILE'The path to the `mysql' history file.
  48321. `MYSQL_HOST'   Default host name used by the `mysql' command-line prompt.
  48322. `MYSQL_PWD'    The default password when connecting to `mysqld'. Note
  48323.                that use of this is insecure!
  48324. `MYSQL_TCP_PORT'The default TCP/IP port.
  48325. `MYSQL_UNIX_PORT'The default socket; used for connections to `localhost'.
  48326. `PATH'         Used by the shell to finds the MySQL programs.
  48327. `TMPDIR'       The directory where temporary tables/files are created.
  48328. `TZ'           This should be set to your local time zone. *Note
  48329.                Timezone problems::.
  48330. `UMASK_DIR'    The user-directory creation mask when creating
  48331.                directories. Note that this is ANDed with `UMASK'!
  48332. `UMASK'        The user-file creation mask when creating files.
  48333. `USER'         The default user on Windows to use when connecting to
  48334.                `mysqld'.
  48335.  
  48336. 
  48337. File: mysql.info,  Node: Regexp,  Next: Unireg,  Prev: Environment variables,  Up: Top
  48338.  
  48339. Description of MySQL regular expression syntax
  48340. **********************************************
  48341.  
  48342. A regular expression (regex) is a powerful way of specifying a complex
  48343. search.
  48344.  
  48345. MySQL uses Henry Spencer's implementation of regular expressions, which
  48346. is aimed at conformance with POSIX 1003.2. MySQL uses the extended
  48347. version.
  48348.  
  48349. This is a simplistic reference that skips the details. To get more exact
  48350. information, see Henry Spencer's `regex(7)' manual page that is
  48351. included in the source distribution. *Note Credits::.
  48352.  
  48353. A regular expression describes a set of strings. The simplest regexp is
  48354. one that has no special characters in it. For example, the regexp
  48355. `hello' matches `hello' and nothing else.
  48356.  
  48357. Non-trivial regular expressions use certain special constructs so that
  48358. they can match more than one string. For example, the regexp
  48359. `hello|word' matches either the string `hello' or the string `word'.
  48360.  
  48361. As a more complex example, the regexp `B[an]*s' matches any of the
  48362. strings `Bananas', `Baaaaas', `Bs', and any other string starting with
  48363. a `B', ending with an `s', and containing any number of `a' or `n'
  48364. characters in between.
  48365.  
  48366. A regular expression may use any of the following special
  48367. characters/constructs:
  48368. `^'
  48369.      Match the beginning of a string.
  48370.           mysql> select "fo\nfo" REGEXP "^fo$";           -> 0
  48371.           mysql> select "fofo" REGEXP "^fo";              -> 1
  48372.  
  48373. `$'
  48374.      Match the end of a string.
  48375.           mysql> select "fo\no" REGEXP "^fo\no$";         -> 1
  48376.           mysql> select "fo\no" REGEXP "^fo$";            -> 0
  48377.  
  48378. `.'
  48379.      Match any character (including newline).
  48380.           mysql> select "fofo" REGEXP "^f.*";             -> 1
  48381.           mysql> select "fo\nfo" REGEXP "^f.*";           -> 1
  48382.  
  48383. `a*'
  48384.      Match any sequence of zero or more `a' characters.
  48385.           mysql> select "Ban" REGEXP "^Ba*n";             -> 1
  48386.           mysql> select "Baaan" REGEXP "^Ba*n";           -> 1
  48387.           mysql> select "Bn" REGEXP "^Ba*n";              -> 1
  48388.  
  48389. `a+'
  48390.      Match any sequence of one or more `a' characters.
  48391.           mysql> select "Ban" REGEXP "^Ba+n";             -> 1
  48392.           mysql> select "Bn" REGEXP "^Ba+n";              -> 0
  48393.  
  48394. `a?'
  48395.      Match either zero or one `a' character.
  48396.           mysql> select "Bn" REGEXP "^Ba?n";              -> 1
  48397.           mysql> select "Ban" REGEXP "^Ba?n";             -> 1
  48398.           mysql> select "Baan" REGEXP "^Ba?n";            -> 0
  48399.  
  48400. `de|abc'
  48401.      Match either of the sequences `de' or `abc'.
  48402.           mysql> select "pi" REGEXP "pi|apa";             -> 1
  48403.           mysql> select "axe" REGEXP "pi|apa";            -> 0
  48404.           mysql> select "apa" REGEXP "pi|apa";            -> 1
  48405.           mysql> select "apa" REGEXP "^(pi|apa)$";        -> 1
  48406.           mysql> select "pi" REGEXP "^(pi|apa)$";         -> 1
  48407.           mysql> select "pix" REGEXP "^(pi|apa)$";        -> 0
  48408.  
  48409. `(abc)*'
  48410.      Match zero or more instances of the sequence `abc'.
  48411.           mysql> select "pi" REGEXP "^(pi)*$";            -> 1
  48412.           mysql> select "pip" REGEXP "^(pi)*$";           -> 0
  48413.           mysql> select "pipi" REGEXP "^(pi)*$";          -> 1
  48414.  
  48415. `{1}'
  48416. `{2,3}'
  48417.      The is a more general way of writing regexps that match many
  48418.      occurrences of the previous atom.
  48419.     `a*'
  48420.           Can be written as `a{0,}'.
  48421.  
  48422.     `a+'
  48423.           Can be written as `a{1,}'.
  48424.  
  48425.     `a?'
  48426.           Can be written as `a{0,1}'.  To be more precise, an atom
  48427.      followed by a bound containing one integer `i' and no comma
  48428.      matches a sequence of exactly `i' matches of the atom. An atom
  48429.      followed by a bound containing one integer `i' and a comma matches
  48430.      a sequence of `i' or more matches of the atom.  An atom followed
  48431.      by a bound containing two integers `i' and `j' matches a sequence
  48432.      of `i' through `j' (inclusive) matches of the atom.
  48433.  
  48434.      Both arguments must be in the range from `0' to `RE_DUP_MAX'
  48435.      (default 255), inclusive.  If there are two arguments, the second
  48436.      must be greater than or equal to the first.
  48437.  
  48438. `[a-dX]'
  48439. `[^a-dX]'
  48440.      Matches any character which is (or is not, if ^ is used) either
  48441.      `a', `b', `c', `d' or `X'. To include a literal `]' character, it
  48442.      must immediately follow the opening bracket `['.  To include a
  48443.      literal `-' character, it must be written first or last. So
  48444.      `[0-9]' matches any decimal digit. Any character that does not have
  48445.      a defined meaning inside a `[]' pair has no special meaning and
  48446.      matches only itself.
  48447.           mysql> select "aXbc" REGEXP "[a-dXYZ]";         -> 1
  48448.           mysql> select "aXbc" REGEXP "^[a-dXYZ]$";       -> 0
  48449.           mysql> select "aXbc" REGEXP "^[a-dXYZ]+$";      -> 1
  48450.           mysql> select "aXbc" REGEXP "^[^a-dXYZ]+$";     -> 0
  48451.           mysql> select "gheis" REGEXP "^[^a-dXYZ]+$";    -> 1
  48452.           mysql> select "gheisa" REGEXP "^[^a-dXYZ]+$";   -> 0
  48453.  
  48454. `[[.characters.]]'
  48455.      The sequence of characters of that collating element. The sequence
  48456.      is a single element of the bracket expression's list. A bracket
  48457.      expression containing a multi-character collating element can thus
  48458.      match more than one character, for example, if the collating
  48459.      sequence includes a `ch' collating element, then the regular
  48460.      expression `[[.ch.]]*c' matches the first five characters of
  48461.      `chchcc'.
  48462.  
  48463. `[=character_class=]'
  48464.      An equivalence class, standing for the sequences of characters of
  48465.      all collating elements equivalent to that one, including itself.
  48466.  
  48467.      For example, if `o' and `(+)' are the members of an equivalence
  48468.      class, then `[[=o=]]', `[[=(+)=]]', and `[o(+)]' are all
  48469.      synonymous. An equivalence class may not be an endpoint of a range.
  48470.  
  48471. `[:character_class:]'
  48472.      Within a bracket expression, the name of a character class
  48473.      enclosed in `[:' and `:]' stands for the list of all characters
  48474.      belonging to that class. Standard character class names are:
  48475.  
  48476.      alnum                  digit                  punct
  48477.      alpha                  graph                  space
  48478.      blank                  lower                  upper
  48479.      cntrl                  print                  xdigit
  48480.  
  48481.      These stand for the character classes defined in the `ctype(3)'
  48482.      manual page. A locale may provide others. A character class may
  48483.      not be used as an endpoint of a range.
  48484.           mysql> select "justalnums" REGEXP "[[:alnum:]]+";       -> 1
  48485.           mysql> select "!!" REGEXP "[[:alnum:]]+";               -> 0
  48486.  
  48487. `[[:<:]]'
  48488. `[[:>:]]'
  48489.      These match the null string at the beginning and end of a word
  48490.      respectively.  A word is defined as a sequence of word characters
  48491.      which is neither preceded nor followed by word characters. A word
  48492.      character is an alnum character (as defined by `ctype(3)') or an
  48493.      underscore (`_').
  48494.           mysql> select "a word a" REGEXP "[[:<:]]word[[:>:]]";      -> 1
  48495.           mysql> select "a xword a" REGEXP "[[:<:]]word[[:>:]]";     -> 0
  48496.  
  48497.      mysql> select "weeknights" REGEXP "^(wee|week)(knights|nights)$"; -> 1
  48498.  
  48499. 
  48500. File: mysql.info,  Node: Unireg,  Next: GPL license,  Prev: Regexp,  Up: Top
  48501.  
  48502. What is Unireg?
  48503. ***************
  48504.  
  48505. Unireg is our tty interface builder, but it uses a low-level connection
  48506. to our ISAM (which is used by MySQL) and because of this it is very
  48507. quick. It has existed since 1979 (on Unix in C since ~1986).
  48508.  
  48509. Unireg has the following components:
  48510.  
  48511.    * One table viewer with updates/browsing.
  48512.  
  48513.    * Multi table viewer (with one scrolling region).
  48514.  
  48515.    * Table creator. (With lots of column tags you can't create with
  48516.      MySQL) This is WYSIWYG (for a tty). You design a screen and Unireg
  48517.      prompts for the column specification.
  48518.  
  48519.    * Report generator.
  48520.  
  48521.    * A lot of utilities (quick import/export of tables to/from text
  48522.      files, analysis of table contents...).
  48523.  
  48524.    * Powerful multi-table updates (which we use a lot) with a BASIC-like
  48525.      language with LOTS of functions.
  48526.  
  48527.    * Dynamic languages (at present in Swedish and Finnish). If somebody
  48528.      wants an English version there are a few files that would have to
  48529.      be translated.
  48530.  
  48531.    * The ability to run updates interactively or in a batch.
  48532.  
  48533.    * Emacs-like key definitions with keyboard macros.
  48534.  
  48535.    * All this in a binary of 800K.
  48536.  
  48537.    * The `convform' utility. Converts `.frm' and text files between
  48538.      different character sets.
  48539.  
  48540.    * The `myisampack' utility. Packs an ISAM table (makes it 50-80%
  48541.      smaller). The table can be read by MySQL like an ordinary table.
  48542.      Only one record has to be decompressed per access. Cannot handle
  48543.      `BLOB' or `TEXT' columns or updates (yet).
  48544.  
  48545. We update most of our production databases with the Unireg interface and
  48546. serve web pages through MySQL (and in some extreme cases the Unireg
  48547. report generator).
  48548.  
  48549. Unireg takes about 3M of disk space and works on at least the following
  48550. platforms: SunOS 4.x, Solaris, Linux, HP-UX, ICL Unix, DNIX, SCO and
  48551. MS-DOS.
  48552.  
  48553. Unireg is currently only available in Swedish and Finnish.
  48554.  
  48555. The price tag for Unireg is 10,000 Swedish kr (about $1500 US), but this
  48556. includes support. Unireg is distributed as a binary. (But all the ISAM
  48557. sources can be found in MySQL). Usually we compile the binary for the
  48558. customer at their site.
  48559.  
  48560. All new development is concentrated to MySQL.
  48561.  
  48562. 
  48563. File: mysql.info,  Node: GPL license,  Next: LGPL license,  Prev: Unireg,  Up: Top
  48564.  
  48565. GNU GENERAL PUBLIC LICENSE
  48566. **************************
  48567.  
  48568.                          Version 2, June 1991
  48569.  
  48570.      Copyright (C) 1989, 1991 Free Software Foundation, Inc.
  48571.      59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
  48572.      
  48573.      Everyone is permitted to copy and distribute verbatim copies
  48574.      of this license document, but changing it is not allowed.
  48575.  
  48576. Preamble
  48577. ========
  48578.  
  48579. The licenses for most software are designed to take away your freedom
  48580. to share and change it.  By contrast, the GNU General Public License is
  48581. intended to guarantee your freedom to share and change free
  48582. software--to make sure the software is free for all its users.  This
  48583. General Public License applies to most of the Free Software
  48584. Foundation's software and to any other program whose authors commit to
  48585. using it.  (Some other Free Software Foundation software is covered by
  48586. the GNU Library General Public License instead.)  You can apply it to
  48587. your programs, too.
  48588.  
  48589. When we speak of free software, we are referring to freedom, not price.
  48590. Our General Public Licenses are designed to make sure that you have
  48591. the freedom to distribute copies of free software (and charge for this
  48592. service if you wish), that you receive source code or can get it if you
  48593. want it, that you can change the software or use pieces of it in new
  48594. free programs; and that you know you can do these things.
  48595.  
  48596. To protect your rights, we need to make restrictions that forbid anyone
  48597. to deny you these rights or to ask you to surrender the rights.  These
  48598. restrictions translate to certain responsibilities for you if you
  48599. distribute copies of the software, or if you modify it.
  48600.  
  48601. For example, if you distribute copies of such a program, whether gratis
  48602. or for a fee, you must give the recipients all the rights that you
  48603. have.  You must make sure that they, too, receive or can get the source
  48604. code.  And you must show them these terms so they know their rights.
  48605.  
  48606. We protect your rights with two steps: (1) copyright the software, and
  48607. (2) offer you this license which gives you legal permission to copy,
  48608. distribute and/or modify the software.
  48609.  
  48610. Also, for each author's protection and ours, we want to make certain
  48611. that everyone understands that there is no warranty for this free
  48612. software.  If the software is modified by someone else and passed on, we
  48613. want its recipients to know that what they have is not the original, so
  48614. that any problems introduced by others will not reflect on the original
  48615. authors' reputations.
  48616.  
  48617. Finally, any free program is threatened constantly by software patents.
  48618. We wish to avoid the danger that redistributors of a free program will
  48619. individually obtain patent licenses, in effect making the program
  48620. proprietary.  To prevent this, we have made it clear that any patent
  48621. must be licensed for everyone's free use or not licensed at all.
  48622.  
  48623. The precise terms and conditions for copying, distribution and
  48624. modification follow.
  48625.  
  48626.                       GNU GENERAL PUBLIC LICENSE
  48627.  
  48628.     TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  48629.  
  48630.   0. This License applies to any program or other work which contains a
  48631.      notice placed by the copyright holder saying it may be distributed
  48632.      under the terms of this General Public License.  The "Program",
  48633.      below, refers to any such program or work, and a "work based on
  48634.      the Program" means either the Program or any derivative work under
  48635.      copyright law: that is to say, a work containing the Program or a
  48636.      portion of it, either verbatim or with modifications and/or
  48637.      translated into another language.  (Hereinafter, translation is
  48638.      included without limitation in the term "modification".)  Each
  48639.      licensee is addressed as "you".
  48640.  
  48641.      Activities other than copying, distribution and modification are
  48642.      not covered by this License; they are outside its scope.  The act
  48643.      of running the Program is not restricted, and the output from the
  48644.      Program is covered only if its contents constitute a work based on
  48645.      the Program (independent of having been made by running the
  48646.      Program).  Whether that is true depends on what the Program does.
  48647.  
  48648.   1. You may copy and distribute verbatim copies of the Program's
  48649.      source code as you receive it, in any medium, provided that you
  48650.      conspicuously and appropriately publish on each copy an appropriate
  48651.      copyright notice and disclaimer of warranty; keep intact all the
  48652.      notices that refer to this License and to the absence of any
  48653.      warranty; and give any other recipients of the Program a copy of
  48654.      this License along with the Program.
  48655.  
  48656.      You may charge a fee for the physical act of transferring a copy,
  48657.      and you may at your option offer warranty protection in exchange
  48658.      for a fee.
  48659.  
  48660.   2. You may modify your copy or copies of the Program or any portion
  48661.      of it, thus forming a work based on the Program, and copy and
  48662.      distribute such modifications or work under the terms of Section 1
  48663.      above, provided that you also meet all of these conditions:
  48664.  
  48665.        a. You must cause the modified files to carry prominent notices
  48666.           stating that you changed the files and the date of any change.
  48667.  
  48668.        b. You must cause any work that you distribute or publish, that
  48669.           in whole or in part contains or is derived from the Program
  48670.           or any part thereof, to be licensed as a whole at no charge
  48671.           to all third parties under the terms of this License.
  48672.  
  48673.        c. If the modified program normally reads commands interactively
  48674.           when run, you must cause it, when started running for such
  48675.           interactive use in the most ordinary way, to print or display
  48676.           an announcement including an appropriate copyright notice and
  48677.           a notice that there is no warranty (or else, saying that you
  48678.           provide a warranty) and that users may redistribute the
  48679.           program under these conditions, and telling the user how to
  48680.           view a copy of this License.  (Exception: if the Program
  48681.           itself is interactive but does not normally print such an
  48682.           announcement, your work based on the Program is not required
  48683.           to print an announcement.)
  48684.  
  48685.      These requirements apply to the modified work as a whole.  If
  48686.      identifiable sections of that work are not derived from the
  48687.      Program, and can be reasonably considered independent and separate
  48688.      works in themselves, then this License, and its terms, do not
  48689.      apply to those sections when you distribute them as separate
  48690.      works.  But when you distribute the same sections as part of a
  48691.      whole which is a work based on the Program, the distribution of
  48692.      the whole must be on the terms of this License, whose permissions
  48693.      for other licensees extend to the entire whole, and thus to each
  48694.      and every part regardless of who wrote it.
  48695.  
  48696.      Thus, it is not the intent of this section to claim rights or
  48697.      contest your rights to work written entirely by you; rather, the
  48698.      intent is to exercise the right to control the distribution of
  48699.      derivative or collective works based on the Program.
  48700.  
  48701.      In addition, mere aggregation of another work not based on the
  48702.      Program with the Program (or with a work based on the Program) on
  48703.      a volume of a storage or distribution medium does not bring the
  48704.      other work under the scope of this License.
  48705.  
  48706.   3. You may copy and distribute the Program (or a work based on it,
  48707.      under Section 2) in object code or executable form under the terms
  48708.      of Sections 1 and 2 above provided that you also do one of the
  48709.      following:
  48710.  
  48711.        a. Accompany it with the complete corresponding machine-readable
  48712.           source code, which must be distributed under the terms of
  48713.           Sections 1 and 2 above on a medium customarily used for
  48714.           software interchange; or,
  48715.  
  48716.        b. Accompany it with a written offer, valid for at least three
  48717.           years, to give any third party, for a charge no more than your
  48718.           cost of physically performing source distribution, a complete
  48719.           machine-readable copy of the corresponding source code, to be
  48720.           distributed under the terms of Sections 1 and 2 above on a
  48721.           medium customarily used for software interchange; or,
  48722.  
  48723.        c. Accompany it with the information you received as to the offer
  48724.           to distribute corresponding source code.  (This alternative is
  48725.           allowed only for noncommercial distribution and only if you
  48726.           received the program in object code or executable form with
  48727.           such an offer, in accord with Subsection b above.)
  48728.  
  48729.      The source code for a work means the preferred form of the work for
  48730.      making modifications to it.  For an executable work, complete
  48731.      source code means all the source code for all modules it contains,
  48732.      plus any associated interface definition files, plus the scripts
  48733.      used to control compilation and installation of the executable.
  48734.      However, as a special exception, the source code distributed need
  48735.      not include anything that is normally distributed (in either
  48736.      source or binary form) with the major components (compiler,
  48737.      kernel, and so on) of the operating system on which the executable
  48738.      runs, unless that component itself accompanies the executable.
  48739.  
  48740.      If distribution of executable or object code is made by offering
  48741.      access to copy from a designated place, then offering equivalent
  48742.      access to copy the source code from the same place counts as
  48743.      distribution of the source code, even though third parties are not
  48744.      compelled to copy the source along with the object code.
  48745.  
  48746.   4. You may not copy, modify, sublicense, or distribute the Program
  48747.      except as expressly provided under this License.  Any attempt
  48748.      otherwise to copy, modify, sublicense or distribute the Program is
  48749.      void, and will automatically terminate your rights under this
  48750.      License.  However, parties who have received copies, or rights,
  48751.      from you under this License will not have their licenses
  48752.      terminated so long as such parties remain in full compliance.
  48753.  
  48754.   5. You are not required to accept this License, since you have not
  48755.      signed it.  However, nothing else grants you permission to modify
  48756.      or distribute the Program or its derivative works.  These actions
  48757.      are prohibited by law if you do not accept this License.
  48758.      Therefore, by modifying or distributing the Program (or any work
  48759.      based on the Program), you indicate your acceptance of this
  48760.      License to do so, and all its terms and conditions for copying,
  48761.      distributing or modifying the Program or works based on it.
  48762.  
  48763.   6. Each time you redistribute the Program (or any work based on the
  48764.      Program), the recipient automatically receives a license from the
  48765.      original licensor to copy, distribute or modify the Program
  48766.      subject to these terms and conditions.  You may not impose any
  48767.      further restrictions on the recipients' exercise of the rights
  48768.      granted herein.  You are not responsible for enforcing compliance
  48769.      by third parties to this License.
  48770.  
  48771.   7. If, as a consequence of a court judgment or allegation of patent
  48772.      infringement or for any other reason (not limited to patent
  48773.      issues), conditions are imposed on you (whether by court order,
  48774.      agreement or otherwise) that contradict the conditions of this
  48775.      License, they do not excuse you from the conditions of this
  48776.      License.  If you cannot distribute so as to satisfy simultaneously
  48777.      your obligations under this License and any other pertinent
  48778.      obligations, then as a consequence you may not distribute the
  48779.      Program at all.  For example, if a patent license would not permit
  48780.      royalty-free redistribution of the Program by all those who
  48781.      receive copies directly or indirectly through you, then the only
  48782.      way you could satisfy both it and this License would be to refrain
  48783.      entirely from distribution of the Program.
  48784.  
  48785.      If any portion of this section is held invalid or unenforceable
  48786.      under any particular circumstance, the balance of the section is
  48787.      intended to apply and the section as a whole is intended to apply
  48788.      in other circumstances.
  48789.  
  48790.      It is not the purpose of this section to induce you to infringe any
  48791.      patents or other property right claims or to contest validity of
  48792.      any such claims; this section has the sole purpose of protecting
  48793.      the integrity of the free software distribution system, which is
  48794.      implemented by public license practices.  Many people have made
  48795.      generous contributions to the wide range of software distributed
  48796.      through that system in reliance on consistent application of that
  48797.      system; it is up to the author/donor to decide if he or she is
  48798.      willing to distribute software through any other system and a
  48799.      licensee cannot impose that choice.
  48800.  
  48801.      This section is intended to make thoroughly clear what is believed
  48802.      to be a consequence of the rest of this License.
  48803.  
  48804.   8. If the distribution and/or use of the Program is restricted in
  48805.      certain countries either by patents or by copyrighted interfaces,
  48806.      the original copyright holder who places the Program under this
  48807.      License may add an explicit geographical distribution limitation
  48808.      excluding those countries, so that distribution is permitted only
  48809.      in or among countries not thus excluded.  In such case, this
  48810.      License incorporates the limitation as if written in the body of
  48811.      this License.
  48812.  
  48813.   9. The Free Software Foundation may publish revised and/or new
  48814.      versions of the General Public License from time to time.  Such
  48815.      new versions will be similar in spirit to the present version, but
  48816.      may differ in detail to address new problems or concerns.
  48817.  
  48818.      Each version is given a distinguishing version number.  If the
  48819.      Program specifies a version number of this License which applies
  48820.      to it and "any later version", you have the option of following
  48821.      the terms and conditions either of that version or of any later
  48822.      version published by the Free Software Foundation.  If the Program
  48823.      does not specify a version number of this License, you may choose
  48824.      any version ever published by the Free Software Foundation.
  48825.  
  48826.  10. If you wish to incorporate parts of the Program into other free
  48827.      programs whose distribution conditions are different, write to the
  48828.      author to ask for permission.  For software which is copyrighted
  48829.      by the Free Software Foundation, write to the Free Software
  48830.      Foundation; we sometimes make exceptions for this.  Our decision
  48831.      will be guided by the two goals of preserving the free status of
  48832.      all derivatives of our free software and of promoting the sharing
  48833.      and reuse of software generally.
  48834.  
  48835.                                 NO WARRANTY
  48836.  
  48837.  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
  48838.      WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE
  48839.      LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
  48840.      HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
  48841.      WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
  48842.      NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  48843.      FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE
  48844.      QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
  48845.      PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
  48846.      SERVICING, REPAIR OR CORRECTION.
  48847.  
  48848.  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
  48849.      WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
  48850.      MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
  48851.      LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
  48852.      INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
  48853.      INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
  48854.      DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU
  48855.      OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY
  48856.      OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
  48857.      ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  48858.  
  48859.                       END OF TERMS AND CONDITIONS
  48860.  
  48861. How to Apply These Terms to Your New Programs
  48862. =============================================
  48863.  
  48864. If you develop a new program, and you want it to be of the greatest
  48865. possible use to the public, the best way to achieve this is to make it
  48866. free software which everyone can redistribute and change under these
  48867. terms.
  48868.  
  48869. To do so, attach the following notices to the program.  It is safest to
  48870. attach them to the start of each source file to most effectively convey
  48871. the exclusion of warranty; and each file should have at least the
  48872. "copyright" line and a pointer to where the full notice is found.
  48873.  
  48874.      ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES.
  48875.      Copyright (C) YYYY  NAME OF AUTHOR
  48876.      
  48877.      This program is free software; you can redistribute it and/or modify
  48878.      it under the terms of the GNU General Public License as published by
  48879.      the Free Software Foundation; either version 2 of the License, or
  48880.      (at your option) any later version.
  48881.      
  48882.      This program is distributed in the hope that it will be useful,
  48883.      but WITHOUT ANY WARRANTY; without even the implied warranty of
  48884.      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  48885.      GNU General Public License for more details.
  48886.      
  48887.      You should have received a copy of the GNU General Public License
  48888.      along with this program; if not, write to the Free Software
  48889.      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  48890.  
  48891. Also add information on how to contact you by electronic and paper mail.
  48892.  
  48893. If the program is interactive, make it output a short notice like this
  48894. when it starts in an interactive mode:
  48895.  
  48896.      Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR
  48897.      Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
  48898.      This is free software, and you are welcome to redistribute it
  48899.      under certain conditions; type `show c' for details.
  48900.  
  48901. The hypothetical commands `show w' and `show c' should show the
  48902. appropriate parts of the General Public License.  Of course, the
  48903. commands you use may be called something other than `show w' and `show
  48904. c'; they could even be mouse-clicks or menu items--whatever suits your
  48905. program.
  48906.  
  48907. You should also get your employer (if you work as a programmer) or your
  48908. school, if any, to sign a "copyright disclaimer" for the program, if
  48909. necessary.  Here is a sample; alter the names:
  48910.  
  48911.      Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  48912.      `Gnomovision' (which makes passes at compilers) written by James Hacker.
  48913.      
  48914.      SIGNATURE OF TY COON, 1 April 1989
  48915.      Ty Coon, President of Vice
  48916.  
  48917. This General Public License does not permit incorporating your program
  48918. into proprietary programs.  If your program is a subroutine library,
  48919. you may consider it more useful to permit linking proprietary
  48920. applications with the library.  If this is what you want to do, use the
  48921. GNU Library General Public License instead of this License.
  48922.  
  48923. 
  48924. File: mysql.info,  Node: LGPL license,  Next: Placeholder,  Prev: GPL license,  Up: Top
  48925.  
  48926. GNU LESSER GENERAL PUBLIC LICENSE
  48927. *********************************
  48928.  
  48929.                       Version 2.1, February 1999
  48930.  
  48931.      Copyright (C) 1991, 1999 Free Software Foundation, Inc.
  48932.      59 Temple Place -- Suite 330, Boston, MA 02111-1307, USA
  48933.      
  48934.      Everyone is permitted to copy and distribute verbatim copies
  48935.      of this license document, but changing it is not allowed.
  48936.      
  48937.      [This is the first released version of the Lesser GPL.  It also counts
  48938.      as the successor of the GNU Library Public License, version 2, hence the
  48939.      version number 2.1.]
  48940.  
  48941. Preamble
  48942. ========
  48943.  
  48944. The licenses for most software are designed to take away your freedom
  48945. to share and change it.  By contrast, the GNU General Public Licenses
  48946. are intended to guarantee your freedom to share and change free
  48947. software--to make sure the software is free for all its users.
  48948.  
  48949. This license, the Lesser General Public License, applies to some
  48950. specially designated software--typically libraries--of the Free
  48951. Software Foundation and other authors who decide to use it.  You can use
  48952. it too, but we suggest you first think carefully about whether this
  48953. license or the ordinary General Public License is the better strategy to
  48954. use in any particular case, based on the explanations below.
  48955.  
  48956. When we speak of free software, we are referring to freedom of use, not
  48957. price.  Our General Public Licenses are designed to make sure that you
  48958. have the freedom to distribute copies of free software (and charge for
  48959. this service if you wish); that you receive source code or can get it
  48960. if you want it; that you can change the software and use pieces of it
  48961. in new free programs; and that you are informed that you can do these
  48962. things.
  48963.  
  48964. To protect your rights, we need to make restrictions that forbid
  48965. distributors to deny you these rights or to ask you to surrender these
  48966. rights.  These restrictions translate to certain responsibilities for
  48967. you if you distribute copies of the library or if you modify it.
  48968.  
  48969. For example, if you distribute copies of the library, whether gratis or
  48970. for a fee, you must give the recipients all the rights that we gave
  48971. you.  You must make sure that they, too, receive or can get the source
  48972. code.  If you link other code with the library, you must provide
  48973. complete object files to the recipients, so that they can relink them
  48974. with the library after making changes to the library and recompiling
  48975. it.  And you must show them these terms so they know their rights.
  48976.  
  48977. We protect your rights with a two-step method: (1) we copyright the
  48978. library, and (2) we offer you this license, which gives you legal
  48979. permission to copy, distribute and/or modify the library.
  48980.  
  48981. To protect each distributor, we want to make it very clear that there
  48982. is no warranty for the free library.  Also, if the library is modified
  48983. by someone else and passed on, the recipients should know that what
  48984. they have is not the original version, so that the original author's
  48985. reputation will not be affected by problems that might be introduced by
  48986. others.
  48987.  
  48988. Finally, software patents pose a constant threat to the existence of
  48989. any free program.  We wish to make sure that a company cannot
  48990. effectively restrict the users of a free program by obtaining a
  48991. restrictive license from a patent holder.  Therefore, we insist that
  48992. any patent license obtained for a version of the library must be
  48993. consistent with the full freedom of use specified in this license.
  48994.  
  48995. Most GNU software, including some libraries, is covered by the ordinary
  48996. GNU General Public License.  This license, the GNU Lesser General
  48997. Public License, applies to certain designated libraries, and is quite
  48998. different from the ordinary General Public License.  We use this
  48999. license for certain libraries in order to permit linking those
  49000. libraries into non-free programs.
  49001.  
  49002. When a program is linked with a library, whether statically or using a
  49003. shared library, the combination of the two is legally speaking a
  49004. combined work, a derivative of the original library.  The ordinary
  49005. General Public License therefore permits such linking only if the
  49006. entire combination fits its criteria of freedom.  The Lesser General
  49007. Public License permits more lax criteria for linking other code with
  49008. the library.
  49009.  
  49010. We call this license the "Lesser" General Public License because it
  49011. does _Less_ to protect the user's freedom than the ordinary General
  49012. Public License.  It also provides other free software developers Less
  49013. of an advantage over competing non-free programs.  These disadvantages
  49014. are the reason we use the ordinary General Public License for many
  49015. libraries.  However, the Lesser license provides advantages in certain
  49016. special circumstances.
  49017.  
  49018. For example, on rare occasions, there may be a special need to
  49019. encourage the widest possible use of a certain library, so that it
  49020. becomes a de-facto standard.  To achieve this, non-free programs must be
  49021. allowed to use the library.  A more frequent case is that a free
  49022. library does the same job as widely used non-free libraries.  In this
  49023. case, there is little to gain by limiting the free library to free
  49024. software only, so we use the Lesser General Public License.
  49025.  
  49026. In other cases, permission to use a particular library in non-free
  49027. programs enables a greater number of people to use a large body of free
  49028. software.  For example, permission to use the GNU C Library in non-free
  49029. programs enables many more people to use the whole GNU operating
  49030. system, as well as its variant, the GNU/Linux operating system.
  49031.  
  49032. Although the Lesser General Public License is Less protective of the
  49033. users' freedom, it does ensure that the user of a program that is
  49034. linked with the Library has the freedom and the wherewithal to run that
  49035. program using a modified version of the Library.
  49036.  
  49037. The precise terms and conditions for copying, distribution and
  49038. modification follow.  Pay close attention to the difference between a
  49039. "work based on the library" and a "work that uses the library".  The
  49040. former contains code derived from the library, whereas the latter must
  49041. be combined with the library in order to run.
  49042.  
  49043.                    GNU LESSER GENERAL PUBLIC LICENSE
  49044.  
  49045.     TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  49046.  
  49047.   0. This License Agreement applies to any software library or other
  49048.      program which contains a notice placed by the copyright holder or
  49049.      other authorized party saying it may be distributed under the
  49050.      terms of this Lesser General Public License (also called "this
  49051.      License").  Each licensee is addressed as "you".
  49052.  
  49053.      A "library" means a collection of software functions and/or data
  49054.      prepared so as to be conveniently linked with application programs
  49055.      (which use some of those functions and data) to form executables.
  49056.  
  49057.      The "Library", below, refers to any such software library or work
  49058.      which has been distributed under these terms.  A "work based on the
  49059.      Library" means either the Library or any derivative work under
  49060.      copyright law: that is to say, a work containing the Library or a
  49061.      portion of it, either verbatim or with modifications and/or
  49062.      translated straightforwardly into another language.  (Hereinafter,
  49063.      translation is included without limitation in the term
  49064.      "modification".)
  49065.  
  49066.      "Source code" for a work means the preferred form of the work for
  49067.      making modifications to it.  For a library, complete source code
  49068.      means all the source code for all modules it contains, plus any
  49069.      associated interface definition files, plus the scripts used to
  49070.      control compilation and installation of the library.
  49071.  
  49072.      Activities other than copying, distribution and modification are
  49073.      not covered by this License; they are outside its scope.  The act
  49074.      of running a program using the Library is not restricted, and
  49075.      output from such a program is covered only if its contents
  49076.      constitute a work based on the Library (independent of the use of
  49077.      the Library in a tool for writing it).  Whether that is true
  49078.      depends on what the Library does and what the program that uses
  49079.      the Library does.
  49080.  
  49081.   1. You may copy and distribute verbatim copies of the Library's
  49082.      complete source code as you receive it, in any medium, provided
  49083.      that you conspicuously and appropriately publish on each copy an
  49084.      appropriate copyright notice and disclaimer of warranty; keep
  49085.      intact all the notices that refer to this License and to the
  49086.      absence of any warranty; and distribute a copy of this License
  49087.      along with the Library.
  49088.  
  49089.      You may charge a fee for the physical act of transferring a copy,
  49090.      and you may at your option offer warranty protection in exchange
  49091.      for a fee.
  49092.  
  49093.   2. You may modify your copy or copies of the Library or any portion
  49094.      of it, thus forming a work based on the Library, and copy and
  49095.      distribute such modifications or work under the terms of Section 1
  49096.      above, provided that you also meet all of these conditions:
  49097.  
  49098.        a. The modified work must itself be a software library.
  49099.  
  49100.        b. You must cause the files modified to carry prominent notices
  49101.           stating that you changed the files and the date of any change.
  49102.  
  49103.        c. You must cause the whole of the work to be licensed at no
  49104.           charge to all third parties under the terms of this License.
  49105.  
  49106.        d. If a facility in the modified Library refers to a function or
  49107.           a table of data to be supplied by an application program that
  49108.           uses the facility, other than as an argument passed when the
  49109.           facility is invoked, then you must make a good faith effort
  49110.           to ensure that, in the event an application does not supply
  49111.           such function or table, the facility still operates, and
  49112.           performs whatever part of its purpose remains meaningful.
  49113.  
  49114.           (For example, a function in a library to compute square roots
  49115.           has a purpose that is entirely well-defined independent of the
  49116.           application.  Therefore, Subsection 2d requires that any
  49117.           application-supplied function or table used by this function
  49118.           must be optional: if the application does not supply it, the
  49119.           square root function must still compute square roots.)
  49120.  
  49121.      These requirements apply to the modified work as a whole.  If
  49122.      identifiable sections of that work are not derived from the
  49123.      Library, and can be reasonably considered independent and separate
  49124.      works in themselves, then this License, and its terms, do not
  49125.      apply to those sections when you distribute them as separate
  49126.      works.  But when you distribute the same sections as part of a
  49127.      whole which is a work based on the Library, the distribution of
  49128.      the whole must be on the terms of this License, whose permissions
  49129.      for other licensees extend to the entire whole, and thus to each
  49130.      and every part regardless of who wrote it.
  49131.  
  49132.      Thus, it is not the intent of this section to claim rights or
  49133.      contest your rights to work written entirely by you; rather, the
  49134.      intent is to exercise the right to control the distribution of
  49135.      derivative or collective works based on the Library.
  49136.  
  49137.      In addition, mere aggregation of another work not based on the
  49138.      Library with the Library (or with a work based on the Library) on
  49139.      a volume of a storage or distribution medium does not bring the
  49140.      other work under the scope of this License.
  49141.  
  49142.   3. You may opt to apply the terms of the ordinary GNU General Public
  49143.      License instead of this License to a given copy of the Library.
  49144.      To do this, you must alter all the notices that refer to this
  49145.      License, so that they refer to the ordinary GNU General Public
  49146.      License, version 2, instead of to this License.  (If a newer
  49147.      version than version 2 of the ordinary GNU General Public License
  49148.      has appeared, then you can specify that version instead if you
  49149.      wish.)  Do not make any other change in these notices.
  49150.  
  49151.      Once this change is made in a given copy, it is irreversible for
  49152.      that copy, so the ordinary GNU General Public License applies to
  49153.      all subsequent copies and derivative works made from that copy.
  49154.  
  49155.      This option is useful when you wish to copy part of the code of
  49156.      the Library into a program that is not a library.
  49157.  
  49158.   4. You may copy and distribute the Library (or a portion or
  49159.      derivative of it, under Section 2) in object code or executable
  49160.      form under the terms of Sections 1 and 2 above provided that you
  49161.      accompany it with the complete corresponding machine-readable
  49162.      source code, which must be distributed under the terms of Sections
  49163.      1 and 2 above on a medium customarily used for software
  49164.      interchange.
  49165.  
  49166.      If distribution of object code is made by offering access to copy
  49167.      from a designated place, then offering equivalent access to copy
  49168.      the source code from the same place satisfies the requirement to
  49169.      distribute the source code, even though third parties are not
  49170.      compelled to copy the source along with the object code.
  49171.  
  49172.   5. A program that contains no derivative of any portion of the
  49173.      Library, but is designed to work with the Library by being
  49174.      compiled or linked with it, is called a "work that uses the
  49175.      Library".  Such a work, in isolation, is not a derivative work of
  49176.      the Library, and therefore falls outside the scope of this License.
  49177.  
  49178.      However, linking a "work that uses the Library" with the Library
  49179.      creates an executable that is a derivative of the Library (because
  49180.      it contains portions of the Library), rather than a "work that
  49181.      uses the library".  The executable is therefore covered by this
  49182.      License.  Section 6 states terms for distribution of such
  49183.      executables.
  49184.  
  49185.      When a "work that uses the Library" uses material from a header
  49186.      file that is part of the Library, the object code for the work may
  49187.      be a derivative work of the Library even though the source code is
  49188.      not.  Whether this is true is especially significant if the work
  49189.      can be linked without the Library, or if the work is itself a
  49190.      library.  The threshold for this to be true is not precisely
  49191.      defined by law.
  49192.  
  49193.      If such an object file uses only numerical parameters, data
  49194.      structure layouts and accessors, and small macros and small inline
  49195.      functions (ten lines or less in length), then the use of the object
  49196.      file is unrestricted, regardless of whether it is legally a
  49197.      derivative work.  (Executables containing this object code plus
  49198.      portions of the Library will still fall under Section 6.)
  49199.  
  49200.      Otherwise, if the work is a derivative of the Library, you may
  49201.      distribute the object code for the work under the terms of Section
  49202.      6.  Any executables containing that work also fall under Section 6,
  49203.      whether or not they are linked directly with the Library itself.
  49204.  
  49205.   6. As an exception to the Sections above, you may also combine or
  49206.      link a "work that uses the Library" with the Library to produce a
  49207.      work containing portions of the Library, and distribute that work
  49208.      under terms of your choice, provided that the terms permit
  49209.      modification of the work for the customer's own use and reverse
  49210.      engineering for debugging such modifications.
  49211.  
  49212.      You must give prominent notice with each copy of the work that the
  49213.      Library is used in it and that the Library and its use are covered
  49214.      by this License.  You must supply a copy of this License.  If the
  49215.      work during execution displays copyright notices, you must include
  49216.      the copyright notice for the Library among them, as well as a
  49217.      reference directing the user to the copy of this License.  Also,
  49218.      you must do one of these things:
  49219.  
  49220.        a. Accompany the work with the complete corresponding
  49221.           machine-readable source code for the Library including
  49222.           whatever changes were used in the work (which must be
  49223.           distributed under Sections 1 and 2 above); and, if the work
  49224.           is an executable linked with the Library, with the complete
  49225.           machine-readable "work that uses the Library", as object code
  49226.           and/or source code, so that the user can modify the Library
  49227.           and then relink to produce a modified executable containing
  49228.           the modified Library.  (It is understood that the user who
  49229.           changes the contents of definitions files in the Library will
  49230.           not necessarily be able to recompile the application to use
  49231.           the modified definitions.)
  49232.  
  49233.        b. Use a suitable shared library mechanism for linking with the
  49234.           Library.  A suitable mechanism is one that (1) uses at run
  49235.           time a copy of the library already present on the user's
  49236.           computer system, rather than copying library functions into
  49237.           the executable, and (2) will operate properly with a modified
  49238.           version of the library, if the user installs one, as long as
  49239.           the modified version is interface-compatible with the version
  49240.           that the work was made with.
  49241.  
  49242.        c. Accompany the work with a written offer, valid for at least
  49243.           three years, to give the same user the materials specified in
  49244.           Subsection 6a, above, for a charge no more than the cost of
  49245.           performing this distribution.
  49246.  
  49247.        d. If distribution of the work is made by offering access to copy
  49248.           from a designated place, offer equivalent access to copy the
  49249.           above specified materials from the same place.
  49250.  
  49251.        e. Verify that the user has already received a copy of these
  49252.           materials or that you have already sent this user a copy.
  49253.  
  49254.      For an executable, the required form of the "work that uses the
  49255.      Library" must include any data and utility programs needed for
  49256.      reproducing the executable from it.  However, as a special
  49257.      exception, the materials to be distributed need not include
  49258.      anything that is normally distributed (in either source or binary
  49259.      form) with the major components (compiler, kernel, and so on) of
  49260.      the operating system on which the executable runs, unless that
  49261.      component itself accompanies the executable.
  49262.  
  49263.      It may happen that this requirement contradicts the license
  49264.      restrictions of other proprietary libraries that do not normally
  49265.      accompany the operating system.  Such a contradiction means you
  49266.      cannot use both them and the Library together in an executable
  49267.      that you distribute.
  49268.  
  49269.   7. You may place library facilities that are a work based on the
  49270.      Library side-by-side in a single library together with other
  49271.      library facilities not covered by this License, and distribute
  49272.      such a combined library, provided that the separate distribution
  49273.      of the work based on the Library and of the other library
  49274.      facilities is otherwise permitted, and provided that you do these
  49275.      two things:
  49276.  
  49277.        a. Accompany the combined library with a copy of the same work
  49278.           based on the Library, uncombined with any other library
  49279.           facilities.  This must be distributed under the terms of the
  49280.           Sections above.
  49281.  
  49282.        b. Give prominent notice with the combined library of the fact
  49283.           that part of it is a work based on the Library, and explaining
  49284.           where to find the accompanying uncombined form of the same
  49285.           work.
  49286.  
  49287.   8. You may not copy, modify, sublicense, link with, or distribute the
  49288.      Library except as expressly provided under this License.  Any
  49289.      attempt otherwise to copy, modify, sublicense, link with, or
  49290.      distribute the Library is void, and will automatically terminate
  49291.      your rights under this License.  However, parties who have
  49292.      received copies, or rights, from you under this License will not
  49293.      have their licenses terminated so long as such parties remain in
  49294.      full compliance.
  49295.  
  49296.   9. You are not required to accept this License, since you have not
  49297.      signed it.  However, nothing else grants you permission to modify
  49298.      or distribute the Library or its derivative works.  These actions
  49299.      are prohibited by law if you do not accept this License.
  49300.      Therefore, by modifying or distributing the Library (or any work
  49301.      based on the Library), you indicate your acceptance of this
  49302.      License to do so, and all its terms and conditions for copying,
  49303.      distributing or modifying the Library or works based on it.
  49304.  
  49305.  10. Each time you redistribute the Library (or any work based on the
  49306.      Library), the recipient automatically receives a license from the
  49307.      original licensor to copy, distribute, link with or modify the
  49308.      Library subject to these terms and conditions.  You may not impose
  49309.      any further restrictions on the recipients' exercise of the rights
  49310.      granted herein.  You are not responsible for enforcing compliance
  49311.      by third parties with this License.
  49312.  
  49313.  11. If, as a consequence of a court judgment or allegation of patent
  49314.      infringement or for any other reason (not limited to patent
  49315.      issues), conditions are imposed on you (whether by court order,
  49316.      agreement or otherwise) that contradict the conditions of this
  49317.      License, they do not excuse you from the conditions of this
  49318.      License.  If you cannot distribute so as to satisfy simultaneously
  49319.      your obligations under this License and any other pertinent
  49320.      obligations, then as a consequence you may not distribute the
  49321.      Library at all.  For example, if a patent license would not permit
  49322.      royalty-free redistribution of the Library by all those who
  49323.      receive copies directly or indirectly through you, then the only
  49324.      way you could satisfy both it and this License would be to refrain
  49325.      entirely from distribution of the Library.
  49326.  
  49327.      If any portion of this section is held invalid or unenforceable
  49328.      under any particular circumstance, the balance of the section is
  49329.      intended to apply, and the section as a whole is intended to apply
  49330.      in other circumstances.
  49331.  
  49332.      It is not the purpose of this section to induce you to infringe any
  49333.      patents or other property right claims or to contest validity of
  49334.      any such claims; this section has the sole purpose of protecting
  49335.      the integrity of the free software distribution system which is
  49336.      implemented by public license practices.  Many people have made
  49337.      generous contributions to the wide range of software distributed
  49338.      through that system in reliance on consistent application of that
  49339.      system; it is up to the author/donor to decide if he or she is
  49340.      willing to distribute software through any other system and a
  49341.      licensee cannot impose that choice.
  49342.  
  49343.      This section is intended to make thoroughly clear what is believed
  49344.      to be a consequence of the rest of this License.
  49345.  
  49346.  12. If the distribution and/or use of the Library is restricted in
  49347.      certain countries either by patents or by copyrighted interfaces,
  49348.      the original copyright holder who places the Library under this
  49349.      License may add an explicit geographical distribution limitation
  49350.      excluding those countries, so that distribution is permitted only
  49351.      in or among countries not thus excluded.  In such case, this
  49352.      License incorporates the limitation as if written in the body of
  49353.      this License.
  49354.  
  49355.  13. The Free Software Foundation may publish revised and/or new
  49356.      versions of the Lesser General Public License from time to time.
  49357.      Such new versions will be similar in spirit to the present version,
  49358.      but may differ in detail to address new problems or concerns.
  49359.  
  49360.      Each version is given a distinguishing version number.  If the
  49361.      Library specifies a version number of this License which applies
  49362.      to it and "any later version", you have the option of following
  49363.      the terms and conditions either of that version or of any later
  49364.      version published by the Free Software Foundation.  If the Library
  49365.      does not specify a license version number, you may choose any
  49366.      version ever published by the Free Software Foundation.
  49367.  
  49368.  14. If you wish to incorporate parts of the Library into other free
  49369.      programs whose distribution conditions are incompatible with these,
  49370.      write to the author to ask for permission.  For software which is
  49371.      copyrighted by the Free Software Foundation, write to the Free
  49372.      Software Foundation; we sometimes make exceptions for this.  Our
  49373.      decision will be guided by the two goals of preserving the free
  49374.      status of all derivatives of our free software and of promoting
  49375.      the sharing and reuse of software generally.
  49376.  
  49377.                                 NO WARRANTY
  49378.  
  49379.  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
  49380.      WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE
  49381.      LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
  49382.      HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT
  49383.      WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT
  49384.      NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  49385.      FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE
  49386.      QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU.  SHOULD THE
  49387.      LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
  49388.      SERVICING, REPAIR OR CORRECTION.
  49389.  
  49390.  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
  49391.      WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY
  49392.      MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE
  49393.      LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
  49394.      INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
  49395.      INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF
  49396.      DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU
  49397.      OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY
  49398.      OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
  49399.      ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  49400.  
  49401.                       END OF TERMS AND CONDITIONS
  49402.  
  49403. How to Apply These Terms to Your New Libraries
  49404. ==============================================
  49405.  
  49406. If you develop a new library, and you want it to be of the greatest
  49407. possible use to the public, we recommend making it free software that
  49408. everyone can redistribute and change.  You can do so by permitting
  49409. redistribution under these terms (or, alternatively, under the terms of
  49410. the ordinary General Public License).
  49411.  
  49412. To apply these terms, attach the following notices to the library.  It
  49413. is safest to attach them to the start of each source file to most
  49414. effectively convey the exclusion of warranty; and each file should have
  49415. at least the "copyright" line and a pointer to where the full notice is
  49416. found.
  49417.  
  49418.      ONE LINE TO GIVE THE LIBRARY'S NAME AND AN IDEA OF WHAT IT DOES.
  49419.      Copyright (C) YEAR  NAME OF AUTHOR
  49420.      
  49421.      This library is free software; you can redistribute it and/or modify it
  49422.      under the terms of the GNU Lesser General Public License as published by
  49423.      the Free Software Foundation; either version 2.1 of the License, or (at
  49424.      your option) any later version.
  49425.      
  49426.      This library is distributed in the hope that it will be useful, but
  49427.      WITHOUT ANY WARRANTY; without even the implied warranty of
  49428.      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  49429.      Lesser General Public License for more details.
  49430.      
  49431.      You should have received a copy of the GNU Lesser General Public
  49432.      License along with this library; if not, write to the Free Software
  49433.      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
  49434.      USA.
  49435.  
  49436. Also add information on how to contact you by electronic and paper mail.
  49437.  
  49438. You should also get your employer (if you work as a programmer) or your
  49439. school, if any, to sign a "copyright disclaimer" for the library, if
  49440. necessary.  Here is a sample; alter the names:
  49441.  
  49442.      Yoyodyne, Inc., hereby disclaims all copyright interest in the library
  49443.      `Frob' (a library for tweaking knobs) written by James Random Hacker.
  49444.      
  49445.      SIGNATURE OF TY COON, 1 April 1990
  49446.      Ty Coon, President of Vice
  49447.  
  49448. That's all there is to it!
  49449.  
  49450. 
  49451. File: mysql.info,  Node: Placeholder,  Next: Function Index,  Prev: LGPL license,  Up: Top
  49452.  
  49453. Pieces of the manual in transit
  49454. *******************************
  49455.  
  49456. * Menu:
  49457.  
  49458. * Installing binary::           Installing a MySQL Binary Distribution
  49459. * Perl support::                Perl Installation Comments
  49460. * Group by functions::          Functions for Use with `GROUP BY' Clauses
  49461.  
  49462. 
  49463. File: mysql.info,  Node: Installing binary,  Next: Perl support,  Prev: Placeholder,  Up: Placeholder
  49464.  
  49465. Installing a MySQL Binary Distribution
  49466. ======================================
  49467.  
  49468. * Menu:
  49469.  
  49470. * Linux-RPM::                   Linux RPM files
  49471. * Building clients::            Building client programs
  49472.  
  49473. You need the following tools to install a MySQL binary distribution:
  49474.  
  49475.    * GNU `gunzip' to uncompress the distribution.
  49476.  
  49477.    * A reasonable `tar' to unpack the distribution. GNU `tar' is known
  49478.      to work.  Sun `tar' is known to have problems.
  49479.  
  49480. An alternative installation method under Linux is to use RPM (RedHat
  49481. Package Manager) distributions.  *Note Linux-RPM::.
  49482.  
  49483. If you run into problems, *PLEASE ALWAYS USE* `mysqlbug' when posting
  49484. questions to <mysql@lists.mysql.com>.  Even if the problem isn't a bug,
  49485. `mysqlbug' gathers system information that will help others solve your
  49486. problem.  By not using `mysqlbug', you lessen the likelihood of getting
  49487. a solution to your problem!  You will find `mysqlbug' in the `bin'
  49488. directory after you unpack the distribution.  *Note Bug reports::.
  49489.  
  49490. The basic commands you must execute to install and use a MySQL binary
  49491. distribution are:
  49492.  
  49493.      shell> groupadd mysql
  49494.      shell> useradd -g mysql mysql
  49495.      shell> cd /usr/local
  49496.      shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
  49497.      shell> ln -s mysql-VERSION-OS mysql
  49498.      shell> cd mysql
  49499.      shell> scripts/mysql_install_db
  49500.      shell> chown -R root  /usr/local/mysql
  49501.      shell> chown -R mysql /usr/local/mysql/data
  49502.      shell> chgrp -R mysql /usr/local/mysql
  49503.      shell> chown -R root /usr/local/mysql/bin
  49504.      shell> bin/safe_mysqld --user=mysql &
  49505.  
  49506. You can add new users using the `bin/mysql_setpermission' script if you
  49507. install the `DBI' and `Msql-Mysql-modules' Perl modules.
  49508.  
  49509. A more detailed description follows.
  49510.  
  49511. To install a binary distribution, follow the steps below, then proceed
  49512. to *Note Post-installation::, for post-installation setup and testing:
  49513.  
  49514.   1. Pick the directory under which you want to unpack the
  49515.      distribution, and move into it.  In the example below, we unpack
  49516.      the distribution under `/usr/local' and create a directory
  49517.      `/usr/local/mysql' into which MySQL is installed.  (The following
  49518.      instructions therefore assume you have permission to create files
  49519.      in `/usr/local'.  If that directory is protected, you will need to
  49520.      perform the installation as `root'.)
  49521.  
  49522.   2. Obtain a distribution file from one of the sites listed in *Note
  49523.      Getting MySQL: Getting MySQL.
  49524.  
  49525.      MySQL binary distributions are provided as compressed `tar'
  49526.      archives and have names like `mysql-VERSION-OS.tar.gz', where
  49527.      `VERSION' is a number (for example, `3.21.15'), and `OS' indicates
  49528.      the type of operating system for which the distribution is intended
  49529.      (for example, `pc-linux-gnu-i586').
  49530.  
  49531.   3. If you see a binary distribution marked with the `-max' prefix,
  49532.      this means that the binary has support for transaction-safe tables
  49533.      and other features. *Note `mysqld-max': mysqld-max.  Note that all
  49534.      binaries are built from the same MySQL source distribution.
  49535.  
  49536.   4. Add a user and group for `mysqld' to run as:
  49537.  
  49538.           shell> groupadd mysql
  49539.           shell> useradd -g mysql mysql
  49540.  
  49541.      These commands add the `mysql' group and the `mysql' user.  The
  49542.      syntax for `useradd' and `groupadd' may differ slightly on
  49543.      different versions of Unix.  They may also be called `adduser' and
  49544.      `addgroup'.  You may wish to call the user and group something
  49545.      else instead of `mysql'.
  49546.  
  49547.   5. Change into the intended installation directory:
  49548.  
  49549.           shell> cd /usr/local
  49550.  
  49551.   6. Unpack the distribution and create the installation directory:
  49552.  
  49553.           shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
  49554.           shell> ln -s mysql-VERSION-OS mysql
  49555.  
  49556.      The first command creates a directory named `mysql-VERSION-OS'.
  49557.      The second command makes a symbolic link to that directory.  This
  49558.      lets you refer more easily to the installation directory as
  49559.      `/usr/local/mysql'.
  49560.  
  49561.   7. Change into the installation directory:
  49562.  
  49563.           shell> cd mysql
  49564.  
  49565.      You will find several files and subdirectories in the `mysql'
  49566.      directory.  The most important for installation purposes are the
  49567.      `bin' and `scripts' subdirectories.
  49568.  
  49569.     `bin'
  49570.           This directory contains client programs and the server You
  49571.           should add the full pathname of this directory to your `PATH'
  49572.           environment variable so that your shell finds the MySQL
  49573.           programs properly. *Note Environment variables::.
  49574.  
  49575.     `scripts'
  49576.           This directory contains the `mysql_install_db' script used to
  49577.           initialize the `mysql' database containing the grant tables
  49578.           that store the server access permissions.
  49579.  
  49580.   8. If you would like to use `mysqlaccess' and have the MySQL
  49581.      distribution in some non-standard place, you must change the
  49582.      location where `mysqlaccess' expects to find the `mysql' client.
  49583.      Edit the `bin/mysqlaccess' script at approximately line 18.
  49584.      Search for a line that looks like this:
  49585.  
  49586.           $MYSQL     = '/usr/local/bin/mysql';    # path to mysql executable
  49587.  
  49588.      Change the path to reflect the location where `mysql' actually is
  49589.      stored on your system.  If you do not do this, you will get a
  49590.      `Broken pipe' error when you run `mysqlaccess'.
  49591.  
  49592.   9. Create the MySQL grant tables (necessary only if you haven't
  49593.      installed MySQL before):
  49594.           shell> scripts/mysql_install_db
  49595.  
  49596.      Note that MySQL versions older than Version 3.22.10 started the
  49597.      MySQL server when you run `mysql_install_db'.  This is no longer
  49598.      true!
  49599.  
  49600.  10. Change ownership of binaries to `root' and ownership of the data
  49601.      directory to the user that you will run `mysqld' as:
  49602.  
  49603.           shell> chown -R root  /usr/local/mysql
  49604.           shell> chown -R mysql /usr/local/mysql/data
  49605.           shell> chgrp -R mysql /usr/local/mysql
  49606.  
  49607.      The first command changes the `owner' attribute of the files to the
  49608.      `root' user, the second one changes the `owner' attribute of the
  49609.      data directory to the `mysql' user, and the third one changes the
  49610.      `group' attribute to the `mysql' group.
  49611.  
  49612.  11. If you want to install support for the Perl `DBI'/`DBD' interface,
  49613.      see *Note Perl support::.
  49614.  
  49615.  12. If you would like MySQL to start automatically when you boot your
  49616.      machine, you can copy `support-files/mysql.server' to the location
  49617.      where your system has its startup files.  More information can be
  49618.      found in the `support-files/mysql.server' script itself and in
  49619.      *Note Automatic start::.
  49620.  
  49621.  
  49622. After everything has been unpacked and installed, you should initialize
  49623. and test your distribution.
  49624.  
  49625. You can start the MySQL server with the following command:
  49626.  
  49627.      shell> bin/safe_mysqld --user=mysql &
  49628.  
  49629. *Note `safe_mysqld': safe_mysqld.
  49630.  
  49631. *Note Post-installation::.
  49632.  
  49633. 
  49634. File: mysql.info,  Node: Perl support,  Next: Group by functions,  Prev: Installing binary,  Up: Placeholder
  49635.  
  49636. Perl Installation Comments
  49637. ==========================
  49638.  
  49639. * Menu:
  49640.  
  49641. * Perl installation::           Installing Perl on Unix
  49642. * ActiveState Perl::            Installing ActiveState Perl on Windows
  49643. * Windows Perl::                Installing the MySQL Perl distribution on Windows
  49644. * Perl support problems::       Problems using the Perl `DBI'/`DBD' interface
  49645.  
  49646. 
  49647. File: mysql.info,  Node: Perl installation,  Next: ActiveState Perl,  Prev: Perl support,  Up: Perl support
  49648.  
  49649. Installing Perl on Unix
  49650. -----------------------
  49651.  
  49652. Perl support for MySQL is provided by means of the `DBI'/`DBD' client
  49653. interface.  *Note Perl::.  The Perl `DBD'/`DBI' client code requires
  49654. Perl Version 5.004 or later.  The interface *will not work* if you have
  49655. an older version of Perl.
  49656.  
  49657. MySQL Perl support also requires that you've installed MySQL client
  49658. programming support.  If you installed MySQL from RPM files, client
  49659. programs are in the client RPM, but client programming support is in
  49660. the developer RPM.  Make sure you've installed the latter RPM.
  49661.  
  49662. As of Version 3.22.8, Perl support is distributed separately from the
  49663. main MySQL distribution.  If you want to install Perl support, the files
  49664. you will need can be obtained from
  49665. `http://www.mysql.com/Downloads/Contrib/'.
  49666.  
  49667. The Perl distributions are provided as compressed `tar' archives and
  49668. have names like `MODULE-VERSION.tar.gz', where `MODULE' is the module
  49669. name and `VERSION' is the version number.  You should get the
  49670. `Data-Dumper', `DBI', and `Msql-Mysql-modules' distributions and
  49671. install them in that order.  The installation procedure is shown below.
  49672. The example shown is for the `Data-Dumper' module, but the procedure is
  49673. the same for all three distributions:
  49674.  
  49675.   1. Unpack the distribution into the current directory:
  49676.           shell> gunzip < Data-Dumper-VERSION.tar.gz | tar xvf -
  49677.      This command creates a directory named `Data-Dumper-VERSION'.
  49678.  
  49679.   2. Change into the top-level directory of the unpacked distribution:
  49680.           shell> cd Data-Dumper-VERSION
  49681.  
  49682.   3. Build the distribution and compile everything:
  49683.           shell> perl Makefile.PL
  49684.           shell> make
  49685.           shell> make test
  49686.           shell> make install
  49687.  
  49688. The `make test' command is important because it verifies that the
  49689. module is working.  Note that when you run that command during the
  49690. `Msql-Mysql-modules' installation to exercise the interface code, the
  49691. MySQL server must be running or the test will fail.
  49692.  
  49693. It is a good idea to rebuild and reinstall the `Msql-Mysql-modules'
  49694. distribution whenever you install a new release of MySQL, particularly
  49695. if you notice symptoms such as all your `DBI' scripts dumping core
  49696. after you upgrade MySQL.
  49697.  
  49698. If you don't have the right to install Perl modules in the system
  49699. directory or if you to install local Perl modules, the following
  49700. reference may help you:
  49701.  
  49702.      `http://www.iserver.com/support/contrib/perl5/modules.html'
  49703.  
  49704. Look under the heading `Installing New Modules that Require Locally
  49705. Installed Modules'.
  49706.  
  49707. 
  49708. File: mysql.info,  Node: ActiveState Perl,  Next: Windows Perl,  Prev: Perl installation,  Up: Perl support
  49709.  
  49710. Installing ActiveState Perl on Windows
  49711. --------------------------------------
  49712.  
  49713. To install the MySQL `DBD' module with ActiveState Perl on Windows, you
  49714. should do the following:
  49715.  
  49716.    * Get ActiveState Perl from
  49717.      `http://www.activestate.com/Products/ActivePerl/index.html' and
  49718.      install it.
  49719.  
  49720.    * Open a DOS shell.
  49721.  
  49722.    * If required, set the HTTP_proxy variable. For example, you might
  49723.      try:
  49724.  
  49725.           set HTTP_proxy=my.proxy.com:3128
  49726.  
  49727.    * Start the PPM program:
  49728.  
  49729.           C:\> c:\perl\bin\ppm.pl
  49730.  
  49731.    * If you have not already done so, install `DBI':
  49732.  
  49733.           ppm> install DBI
  49734.  
  49735.    * If this succeeds, run the following command:
  49736.  
  49737.           install ftp://ftp.de.uu.net/pub/CPAN/authors/id/JWIED/DBD-mysql-1.2212.x86.ppd
  49738.  
  49739. The above should work at least with ActiveState Perl Version 5.6.
  49740.  
  49741. If you can't get the above to work, you should instead install the
  49742. *MyODBC* driver and connect to MySQL server through ODBC:
  49743.  
  49744.      use DBI;
  49745.      $dbh= DBI->connect("DBI:ODBC:$dsn","$user","$password") ||
  49746.        die "Got error $DBI::errstr when connecting to $dsn\n";
  49747.  
  49748. 
  49749. File: mysql.info,  Node: Windows Perl,  Next: Perl support problems,  Prev: ActiveState Perl,  Up: Perl support
  49750.  
  49751. Installing the MySQL Perl Distribution on Windows
  49752. -------------------------------------------------
  49753.  
  49754. The MySQL Perl distribution contains `DBI', `DBD:MySQL' and `DBD:ODBC'.
  49755.  
  49756.    * Get the Perl distribution for Windows from
  49757.      `http://www.mysql.com/download.html'.
  49758.  
  49759.    * Unzip the distribution in `C:' so that you get a `C:\PERL'
  49760.      directory.
  49761.  
  49762.    * Add the directory `C:\PERL\BIN' to your path.
  49763.  
  49764.    * Add the directory `C:\PERL\BIN\MSWIN32-x86-thread' or
  49765.      `C:\PERL\BIN\MSWIN32-x86' to your path.
  49766.  
  49767.    * Test that `perl' works by executing `perl -v' in a DOS shell.
  49768.  
  49769. 
  49770. File: mysql.info,  Node: Perl support problems,  Prev: Windows Perl,  Up: Perl support
  49771.  
  49772. Problems Using the Perl `DBI'/`DBD' Interface
  49773. ---------------------------------------------
  49774.  
  49775. If Perl reports that it can't find the `../mysql/mysql.so' module, then
  49776. the problem is probably that Perl can't locate the shared library
  49777. `libmysqlclient.so'.
  49778.  
  49779. You can fix this by any of the following methods:
  49780.  
  49781.    * Compile the `Msql-Mysql-modules' distribution with `perl
  49782.      Makefile.PL -static -config' rather than `perl Makefile.PL'.
  49783.  
  49784.    * Copy `libmysqlclient.so' to the directory where your other shared
  49785.      libraries are located (probably `/usr/lib' or `/lib').
  49786.  
  49787.    * On Linux you can add the pathname of the directory where
  49788.      `libmysqlclient.so' is located to the `/etc/ld.so.conf' file.
  49789.  
  49790.    * Add the pathname of the directory where `libmysqlclient.so' is
  49791.      located to the `LD_RUN_PATH' environment variable.
  49792.  
  49793. If you get the following errors from `DBD-mysql', you are probably
  49794. using `gcc' (or using an old binary compiled with `gcc'):
  49795.  
  49796.      /usr/bin/perl: can't resolve symbol '__moddi3'
  49797.      /usr/bin/perl: can't resolve symbol '__divdi3'
  49798.  
  49799. Add `-L/usr/lib/gcc-lib/... -lgcc' to the link command when the
  49800. `mysql.so' library gets built (check the output from `make' for
  49801. `mysql.so' when you compile the Perl client).  The `-L' option should
  49802. specify the pathname of the directory where `libgcc.a' is located on
  49803. your system.
  49804.  
  49805. Another cause of this problem may be that Perl and MySQL aren't both
  49806. compiled with `gcc'.  In this case, you can solve the mismatch by
  49807. compiling both with `gcc'.
  49808.  
  49809. If you get the following error from `Msql-Mysql-modules' when you run
  49810. the tests:
  49811.  
  49812.      t/00base............install_driver(mysql) failed: Can't load '../blib/arch/auto/DBD/mysql/mysql.so' for module DBD::mysql: ../blib/arch/auto/DBD/mysql/mysql.so: undefined symbol: uncompress at /usr/lib/perl5/5.00503/i586-linux/DynaLoader.pm line 169.
  49813.  
  49814. it means that you need to include the compression library, -lz, to the
  49815. link line. This can be doing the following change in the file
  49816. `lib/DBD/mysql/Install.pm':
  49817.  
  49818.      $sysliblist .= " -lm";
  49819.      
  49820.      to
  49821.      
  49822.      $sysliblist .= " -lm -lz";
  49823.  
  49824. After this, you MUST run 'make realclean' and then proceed with the
  49825. installation from the beginning.
  49826.  
  49827. If you want to use the Perl module on a system that doesn't support
  49828. dynamic linking (like SCO) you can generate a static version of Perl
  49829. that includes `DBI' and `DBD-mysql'.  The way this works is that you
  49830. generate a version of Perl with the `DBI' code linked in and install it
  49831. on top of your current Perl.  Then you use that to build a version of
  49832. Perl that additionally has the `DBD' code linked in, and install that.
  49833.  
  49834. On SCO, you must have the following environment variables set:
  49835.  
  49836.      shell> LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/usr/progressive/lib
  49837.      or
  49838.      shell> LD_LIBRARY_PATH=/usr/lib:/lib:/usr/local/lib:/usr/ccs/lib:/usr/progressive/lib:/usr/skunk/lib
  49839.      shell> LIBPATH=/usr/lib:/lib:/usr/local/lib:/usr/ccs/lib:/usr/progressive/lib:/usr/skunk/lib
  49840.      shell> MANPATH=scohelp:/usr/man:/usr/local1/man:/usr/local/man:/usr/skunk/man:
  49841.  
  49842. First, create a Perl that includes a statically linked `DBI' by running
  49843. these commands in the directory where your `DBI' distribution is
  49844. located:
  49845.  
  49846.      shell> perl Makefile.PL -static -config
  49847.      shell> make
  49848.      shell> make install
  49849.      shell> make perl
  49850.  
  49851. Then you must install the new Perl. The output of `make perl' will
  49852. indicate the exact `make' command you will need to execute to perform
  49853. the installation.  On SCO, this is `make -f Makefile.aperl inst_perl
  49854. MAP_TARGET=perl'.
  49855.  
  49856. Next, use the just-created Perl to create another Perl that also
  49857. includes a statically-linked `DBD::mysql' by running these commands in
  49858. the directory where your `Msql-Mysql-modules' distribution is located:
  49859.  
  49860.      shell> perl Makefile.PL -static -config
  49861.      shell> make
  49862.      shell> make install
  49863.      shell> make perl
  49864.  
  49865. Finally, you should install this new Perl.  Again, the output of `make
  49866. perl' indicates the command to use.
  49867.  
  49868. 
  49869. File: mysql.info,  Node: Group by functions,  Prev: Perl support,  Up: Placeholder
  49870.  
  49871. Functions for Use with `GROUP BY' Clauses
  49872. =========================================
  49873.  
  49874. If you use a group function in a statement containing no `GROUP BY'
  49875. clause, it is equivalent to grouping on all rows.
  49876.  
  49877. `COUNT(expr)'
  49878.      Returns a count of the number of non-`NULL' values in the rows
  49879.      retrieved by a `SELECT' statement:
  49880.  
  49881.           mysql> select student.student_name,COUNT(*)
  49882.                      from student,course
  49883.                      where student.student_id=course.student_id
  49884.                      GROUP BY student_name;
  49885.  
  49886.      `COUNT(*)' is somewhat different in that it returns a count of the
  49887.      number of rows retrieved, whether or not they contain `NULL'
  49888.      values.
  49889.  
  49890.      `COUNT(*)' is optimized to return very quickly if the `SELECT'
  49891.      retrieves from one table, no other columns are retrieved, and
  49892.      there is no `WHERE' clause.  For example:
  49893.  
  49894.           mysql> select COUNT(*) from student;
  49895.  
  49896. `COUNT(DISTINCT expr,[expr...])'
  49897.      Returns a count of the number of different non-`NULL' values:
  49898.  
  49899.           mysql> select COUNT(DISTINCT results) from student;
  49900.  
  49901.      In MySQL you can get the number of distinct expression
  49902.      combinations that don't contain NULL by giving a list of
  49903.      expressions.  In ANSI SQL you would have to do a concatenation of
  49904.      all expressions inside `CODE(DISTINCT ..)'.
  49905.  
  49906. `AVG(expr)'
  49907.      Returns the average value of `expr':
  49908.  
  49909.           mysql> select student_name, AVG(test_score)
  49910.                      from student
  49911.                      GROUP BY student_name;
  49912.  
  49913. `MIN(expr)'
  49914. `MAX(expr)'
  49915.      Returns the minimum or maximum value of `expr'.  `MIN()' and
  49916.      `MAX()' may take a string argument; in such cases they return the
  49917.      minimum or maximum string value. *Note MySQL indexes::.
  49918.  
  49919.           mysql> select student_name, MIN(test_score), MAX(test_score)
  49920.                      from student
  49921.                      GROUP BY student_name;
  49922.  
  49923. `SUM(expr)'
  49924.      Returns the sum of `expr'.  Note that if the return set has no
  49925.      rows, it returns NULL!
  49926.  
  49927. `STD(expr)'
  49928. `STDDEV(expr)'
  49929.      Returns the standard deviation of `expr'. This is an extension to
  49930.      ANSI SQL. The `STDDEV()' form of this function is provided for
  49931.      Oracle compatibility.
  49932.  
  49933. `BIT_OR(expr)'
  49934.      Returns the bitwise `OR' of all bits in `expr'. The calculation is
  49935.      performed with 64-bit (`BIGINT') precision.
  49936.  
  49937. `BIT_AND(expr)'
  49938.      Returns the bitwise `AND' of all bits in `expr'. The calculation is
  49939.      performed with 64-bit (`BIGINT') precision.
  49940.  
  49941. MySQL has extended the use of `GROUP BY'. You can use columns or
  49942. calculations in the `SELECT' expressions that don't appear in the
  49943. `GROUP BY' part. This stands for _any possible value for this group_.
  49944. You can use this to get better performance by avoiding sorting and
  49945. grouping on unnecessary items.  For example, you don't need to group on
  49946. `customer.name' in the following query:
  49947.  
  49948.      mysql> select order.custid,customer.name,max(payments)
  49949.             from order,customer
  49950.             where order.custid = customer.custid
  49951.             GROUP BY order.custid;
  49952.  
  49953. In ANSI SQL, you would have to add `customer.name' to the `GROUP BY'
  49954. clause.  In MySQL, the name is redundant if you don't run in ANSI mode.
  49955.  
  49956. *Don't use this feature* if the columns you omit from the `GROUP BY'
  49957. part aren't unique in the group!  You will get unpredictable results.
  49958.  
  49959. In some cases, you can use `MIN()' and `MAX()' to obtain a specific
  49960. column value even if it isn't unique. The following gives the value of
  49961. `column' from the row containing the smallest value in the `sort'
  49962. column:
  49963.  
  49964.      substr(MIN(concat(rpad(sort,6,' '),column)),7)
  49965.  
  49966. *Note example-Maximum-column-group-row::.
  49967.  
  49968. Note that if you are using MySQL Version 3.22 (or earlier) or if you
  49969. are trying to follow ANSI SQL, you can't use expressions in `GROUP BY'
  49970. or `ORDER BY' clauses.  You can work around this limitation by using an
  49971. alias for the expression:
  49972.  
  49973.      mysql> SELECT id,FLOOR(value/100) AS val FROM tbl_name
  49974.                 GROUP BY id,val ORDER BY val;
  49975.  
  49976. In MySQL Version 3.23 you can do:
  49977.  
  49978.      mysql> SELECT id,FLOOR(value/100) FROM tbl_name ORDER BY RAND();
  49979.  
  49980. 
  49981. File: mysql.info,  Node: Function Index,  Next: Concept Index,  Prev: Placeholder,  Up: Top
  49982.  
  49983. SQL command, type and function index
  49984. ************************************
  49985.  
  49986. * Menu:
  49987.  
  49988. * ! (logical NOT):                       Logical Operators.
  49989. * != (not equal):                        Comparison Operators.
  49990. * ":                                     Legal names.
  49991. * % (modulo):                            Mathematical functions.
  49992. * % (wild card character):               String syntax.
  49993. * & (bitwise AND):                       Bit functions.
  49994. * && (logical AND):                      Logical Operators.
  49995. * () (parentheses):                      Parenthesis.
  49996. * (Control-Z) \z:                        String syntax.
  49997. * * (multiplication):                    Arithmetic functions.
  49998. * + (addition):                          Arithmetic functions.
  49999. * - (subtraction):                       Arithmetic functions.
  50000. * - (unary minus):                       Mathematical functions.
  50001. * -p option:                             Password security.
  50002. * -password option:                      Password security.
  50003. * .my.cnf file <1>:                      Password security.
  50004. * .my.cnf file <2>:                      Access denied.
  50005. * .my.cnf file <3>:                      Connecting.
  50006. * .my.cnf file <4>:                      Multiple servers.
  50007. * .my.cnf file <5>:                      Option files.
  50008. * .my.cnf file:                          Windows vs Unix.
  50009. * .mysql_history file <1>:               Client-Side Overview.
  50010. * .mysql_history file:                   Server-Side Overview.
  50011. * .pid (process ID) file:                Maintenance regimen.
  50012. * / (division):                          Arithmetic functions.
  50013. * /etc/passwd <1>:                       SELECT.
  50014. * /etc/passwd:                           Security.
  50015. * < (less than):                         Comparison Operators.
  50016. * <<:                                    Calculating days.
  50017. * << (left shift):                       Bit functions.
  50018. * <= (less than or equal):               Comparison Operators.
  50019. * <=> (Equal to):                        Comparison Operators.
  50020. * <> (not equal):                        Comparison Operators.
  50021. * = (equal):                             Comparison Operators.
  50022. * > (greater than):                      Comparison Operators.
  50023. * >= (greater than or equal):            Comparison Operators.
  50024. * >> (right shift):                      Bit functions.
  50025. * \" (double quote):                     String syntax.
  50026. * \' (single quote):                     String syntax.
  50027. * \0 (ASCII 0):                          String syntax.
  50028. * \\ (escape):                           String syntax.
  50029. * \b (backspace):                        String syntax.
  50030. * \n (newline):                          String syntax.
  50031. * \r (carriage return):                  String syntax.
  50032. * \t (tab):                              String syntax.
  50033. * \z (Control-Z) ASCII(26):              String syntax.
  50034. * _ (wild card character):               String syntax.
  50035. * `:                                     Legal names.
  50036. * ABS():                                 Mathematical functions.
  50037. * ACOS():                                Mathematical functions.
  50038. * ADDDATE():                             Date and time functions.
  50039. * addition (+):                          Arithmetic functions.
  50040. * alias:                                 Problems with alias.
  50041. * ALTER COLUMN:                          ALTER TABLE.
  50042. * ALTER TABLE <1>:                       ALTER TABLE problems.
  50043. * ALTER TABLE:                           ALTER TABLE.
  50044. * ANALYZE TABLE:                         ANALYZE TABLE.
  50045. * AND, bitwise:                          Bit functions.
  50046. * AND, logical:                          Logical Operators.
  50047. * arithmetic functions:                  Bit functions.
  50048. * ASCII():                               String functions.
  50049. * ASIN():                                Mathematical functions.
  50050. * ATAN():                                Mathematical functions.
  50051. * ATAN2():                               Mathematical functions.
  50052. * AUTO_INCREMENT, using with DBI:        Perl DBI Class.
  50053. * AVG():                                 Group by functions.
  50054. * backspace (\b):                        String syntax.
  50055. * BACKUP TABLE:                          BACKUP TABLE.
  50056. * BEGIN:                                 COMMIT.
  50057. * BENCHMARK():                           Miscellaneous functions.
  50058. * BETWEEN ... AND:                       Comparison Operators.
  50059. * BIGINT:                                Column types.
  50060. * BIN():                                 String functions.
  50061. * BINARY:                                Case Sensitivity Operators.
  50062. * BIT:                                   Column types.
  50063. * bit functions:                         Bit functions.
  50064. * BIT_AND():                             Group by functions.
  50065. * BIT_COUNT:                             Calculating days.
  50066. * BIT_COUNT():                           Bit functions.
  50067. * BIT_OR:                                Calculating days.
  50068. * BIT_OR():                              Group by functions.
  50069. * BLOB <1>:                              BLOB.
  50070. * BLOB:                                  Column types.
  50071. * BOOL:                                  Column types.
  50072. * carriage return (\r):                  String syntax.
  50073. * CASE:                                  Control flow functions.
  50074. * casts:                                 Case Sensitivity Operators.
  50075. * CC environment variable <1>:           Environment variables.
  50076. * CC environment variable <2>:           Compilation problems.
  50077. * CC environment variable:               configure options.
  50078. * CCX environment variable:              Environment variables.
  50079. * CEILING():                             Mathematical functions.
  50080. * CFLAGS environment variable <1>:       Environment variables.
  50081. * CFLAGS environment variable:           Compilation problems.
  50082. * CHAR <1>:                              String types.
  50083. * CHAR:                                  Column types.
  50084. * CHAR VARYING:                          Column types.
  50085. * CHAR():                                String functions.
  50086. * CHAR_LENGTH():                         String functions.
  50087. * CHARACTER:                             Column types.
  50088. * CHARACTER VARYING:                     Column types.
  50089. * CHARACTER_LENGTH():                    String functions.
  50090. * CHECK TABLE:                           CHECK TABLE.
  50091. * ChopBlanks DBI method:                 Perl DBI Class.
  50092. * COALESCE():                            Comparison Operators.
  50093. * command-line options:                  Command-line options.
  50094. * Comment syntax:                        Comments.
  50095. * COMMIT <1>:                            COMMIT.
  50096. * COMMIT:                                Commit-rollback.
  50097. * comparison operators:                  Comparison Operators.
  50098. * CONCAT():                              String functions.
  50099. * CONCAT_WS():                           String functions.
  50100. * configure option, --with-charset:      configure options.
  50101. * configure option, --with-extra-charset: configure options.
  50102. * connect() DBI method:                  Perl DBI Class.
  50103. * CONNECTION_ID():                       Miscellaneous functions.
  50104. * control flow functions:                Control flow functions.
  50105. * CONV():                                String functions.
  50106. * COS():                                 Mathematical functions.
  50107. * COT():                                 Mathematical functions.
  50108. * COUNT():                               Group by functions.
  50109. * COUNT(DISTINCT):                       Group by functions.
  50110. * CREATE DATABASE:                       CREATE DATABASE.
  50111. * CREATE FUNCTION:                       CREATE FUNCTION.
  50112. * CREATE INDEX:                          CREATE INDEX.
  50113. * CREATE TABLE:                          CREATE TABLE.
  50114. * CROSS JOIN:                            JOIN.
  50115. * CURDATE():                             Date and time functions.
  50116. * CURRENT_DATE:                          Date and time functions.
  50117. * CURRENT_TIME:                          Date and time functions.
  50118. * CURRENT_TIMESTAMP:                     Date and time functions.
  50119. * CURTIME():                             Date and time functions.
  50120. * CXX environment variable <1>:          Compilation problems.
  50121. * CXX environment variable:              configure options.
  50122. * CXXFLAGS environment variable <1>:     Environment variables.
  50123. * CXXFLAGS environment variable <2>:     Compilation problems.
  50124. * CXXFLAGS environment variable:         configure options.
  50125. * data_sources() DBI method:             Perl DBI Class.
  50126. * DATABASE():                            Miscellaneous functions.
  50127. * DATE <1>:                              Using DATE.
  50128. * DATE <2>:                              DATETIME.
  50129. * DATE:                                  Column types.
  50130. * date and time functions:               Date and time functions.
  50131. * DATE_ADD():                            Date and time functions.
  50132. * DATE_FORMAT():                         Date and time functions.
  50133. * DATE_SUB():                            Date and time functions.
  50134. * DATETIME <1>:                          DATETIME.
  50135. * DATETIME:                              Column types.
  50136. * DAYNAME():                             Date and time functions.
  50137. * DAYOFMONTH():                          Date and time functions.
  50138. * DAYOFWEEK():                           Date and time functions.
  50139. * DAYOFYEAR():                           Date and time functions.
  50140. * DBI->connect():                        Perl DBI Class.
  50141. * DBI->data_sources():                   Perl DBI Class.
  50142. * DBI->disconnect:                       Perl DBI Class.
  50143. * DBI->do():                             Perl DBI Class.
  50144. * DBI->execute:                          Perl DBI Class.
  50145. * DBI->fetchall_arrayref:                Perl DBI Class.
  50146. * DBI->fetchrow_array:                   Perl DBI Class.
  50147. * DBI->fetchrow_arrayref:                Perl DBI Class.
  50148. * DBI->fetchrow_hashref:                 Perl DBI Class.
  50149. * DBI->finish:                           Perl DBI Class.
  50150. * DBI->prepare():                        Perl DBI Class.
  50151. * DBI->quote:                            String syntax.
  50152. * DBI->quote():                          Perl DBI Class.
  50153. * DBI->rows:                             Perl DBI Class.
  50154. * DBI->trace <1>:                        Using gdb on mysqld.
  50155. * DBI->trace:                            Perl DBI Class.
  50156. * DBI->{ChopBlanks}:                     Perl DBI Class.
  50157. * DBI->{insertid}:                       Perl DBI Class.
  50158. * DBI->{is_blob}:                        Perl DBI Class.
  50159. * DBI->{is_key}:                         Perl DBI Class.
  50160. * DBI->{is_not_null}:                    Perl DBI Class.
  50161. * DBI->{is_num}:                         Perl DBI Class.
  50162. * DBI->{is_pri_key}:                     Perl DBI Class.
  50163. * DBI->{length}:                         Perl DBI Class.
  50164. * DBI->{max_length}:                     Perl DBI Class.
  50165. * DBI->{NAME}:                           Perl DBI Class.
  50166. * DBI->{NULLABLE}:                       Perl DBI Class.
  50167. * DBI->{NUM_OF_FIELDS}:                  Perl DBI Class.
  50168. * DBI->{table}:                          Perl DBI Class.
  50169. * DBI->{type}:                           Perl DBI Class.
  50170. * DBI_TRACE environment variable <1>:    Environment variables.
  50171. * DBI_TRACE environment variable <2>:    Using gdb on mysqld.
  50172. * DBI_TRACE environment variable:        Perl DBI Class.
  50173. * DBI_USER environment variable:         Environment variables.
  50174. * DECIMAL:                               Column types.
  50175. * DECODE():                              Miscellaneous functions.
  50176. * DEGREES():                             Mathematical functions.
  50177. * DELAYED:                               INSERT DELAYED.
  50178. * DELETE:                                DELETE.
  50179. * DESC:                                  DESCRIBE.
  50180. * DESCRIBE <1>:                          DESCRIBE.
  50181. * DESCRIBE:                              Getting information.
  50182. * disconnect DBI method:                 Perl DBI Class.
  50183. * DISTINCT <1>:                          Group by functions.
  50184. * DISTINCT <2>:                          DISTINCT optimization.
  50185. * DISTINCT:                              Selecting columns.
  50186. * division (/):                          Arithmetic functions.
  50187. * DO:                                    DO.
  50188. * do() DBI method:                       Perl DBI Class.
  50189. * DOUBLE:                                Column types.
  50190. * DOUBLE PRECISION:                      Column types.
  50191. * double quote (\"):                     String syntax.
  50192. * DROP DATABASE:                         DROP DATABASE.
  50193. * DROP FUNCTION:                         CREATE FUNCTION.
  50194. * DROP INDEX <1>:                        DROP INDEX.
  50195. * DROP INDEX:                            ALTER TABLE.
  50196. * DROP PRIMARY KEY:                      ALTER TABLE.
  50197. * DROP TABLE:                            DROP TABLE.
  50198. * DUMPFILE:                              SELECT.
  50199. * ELT():                                 String functions.
  50200. * ENCODE():                              Miscellaneous functions.
  50201. * ENCRYPT():                             Miscellaneous functions.
  50202. * ENUM <1>:                              ENUM.
  50203. * ENUM:                                  Column types.
  50204. * Environment variable, CC:              Environment variables.
  50205. * environment variable, CC <1>:          Compilation problems.
  50206. * environment variable, CC:              configure options.
  50207. * Environment variable, CCX:             Environment variables.
  50208. * Environment variable, CFLAGS:          Environment variables.
  50209. * environment variable, CFLAGS:          Compilation problems.
  50210. * environment variable, CXX:             Compilation problems.
  50211. * Environment variable, CXX:             Compilation problems.
  50212. * environment variable, CXX:             configure options.
  50213. * Environment variable, CXXFLAGS:        Environment variables.
  50214. * environment variable, CXXFLAGS <1>:    Compilation problems.
  50215. * environment variable, CXXFLAGS:        configure options.
  50216. * Environment variable, DBI_TRACE <1>:   Environment variables.
  50217. * Environment variable, DBI_TRACE:       Using gdb on mysqld.
  50218. * environment variable, DBI_TRACE:       Perl DBI Class.
  50219. * Environment variable, DBI_USER:        Environment variables.
  50220. * Environment variable, HOME:            Environment variables.
  50221. * environment variable, HOME <1>:        Client-Side Overview.
  50222. * environment variable, HOME:            Server-Side Overview.
  50223. * Environment variable, LD_RUN_PATH <1>: Perl support problems.
  50224. * Environment variable, LD_RUN_PATH <2>: Environment variables.
  50225. * Environment variable, LD_RUN_PATH:     Solaris.
  50226. * environment variable, LD_RUN_PATH:     Linux.
  50227. * Environment variable, MYSQL_DEBUG <1>: Environment variables.
  50228. * Environment variable, MYSQL_DEBUG:     Debugging client.
  50229. * environment variable, MYSQL_DEBUG <1>: Client-Side Overview.
  50230. * environment variable, MYSQL_DEBUG:     Server-Side Overview.
  50231. * Environment variable, MYSQL_HISTFILE:  Environment variables.
  50232. * environment variable, MYSQL_HISTFILE <1>: Client-Side Overview.
  50233. * environment variable, MYSQL_HISTFILE:  Server-Side Overview.
  50234. * Environment variable, MYSQL_HOST:      Environment variables.
  50235. * environment variable, MYSQL_HOST:      Connecting.
  50236. * Environment variable, MYSQL_PWD:       Environment variables.
  50237. * environment variable, MYSQL_PWD <1>:   Client-Side Overview.
  50238. * environment variable, MYSQL_PWD <2>:   Server-Side Overview.
  50239. * environment variable, MYSQL_PWD:       Connecting.
  50240. * Environment variable, MYSQL_TCP_PORT:  Environment variables.
  50241. * environment variable, MYSQL_TCP_PORT <1>: Client-Side Overview.
  50242. * environment variable, MYSQL_TCP_PORT <2>: Server-Side Overview.
  50243. * environment variable, MYSQL_TCP_PORT <3>: Multiple servers.
  50244. * environment variable, MYSQL_TCP_PORT:  Installing many servers.
  50245. * Environment variable, MYSQL_UNIX_PORT: Environment variables.
  50246. * environment variable, MYSQL_UNIX_PORT <1>: Client-Side Overview.
  50247. * environment variable, MYSQL_UNIX_PORT <2>: Server-Side Overview.
  50248. * environment variable, MYSQL_UNIX_PORT <3>: Multiple servers.
  50249. * environment variable, MYSQL_UNIX_PORT: Installing many servers.
  50250. * Environment variable, MYSQL_UNIX_PORT: mysql_install_db.
  50251. * environment variable, PATH:            Installing binary.
  50252. * Environment variable, PATH:            Environment variables.
  50253. * Environment variable, TMPDIR <1>:      Environment variables.
  50254. * Environment variable, TMPDIR:          mysql_install_db.
  50255. * Environment variable, TZ <1>:          Environment variables.
  50256. * Environment variable, TZ:              Timezone problems.
  50257. * Environment variable, UMASK <1>:       Environment variables.
  50258. * Environment variable, UMASK:           File permissions.
  50259. * Environment variable, UMASK_DIR <1>:   Environment variables.
  50260. * Environment variable, UMASK_DIR:       File permissions.
  50261. * Environment variable, USER:            Environment variables.
  50262. * environment variable, USER:            Connecting.
  50263. * Environment variables, CXX:            Compilation problems.
  50264. * equal (=):                             Comparison Operators.
  50265. * escape (\\):                           String syntax.
  50266. * execute DBI method:                    Perl DBI Class.
  50267. * EXP():                                 Mathematical functions.
  50268. * EXPLAIN:                               EXPLAIN.
  50269. * EXPORT_SET():                          String functions.
  50270. * EXTRACT():                             Date and time functions.
  50271. * fetchall_arrayref DBI method:          Perl DBI Class.
  50272. * fetchrow_array DBI method:             Perl DBI Class.
  50273. * fetchrow_arrayref DBI method:          Perl DBI Class.
  50274. * fetchrow_hashref DBI method:           Perl DBI Class.
  50275. * FIELD():                               String functions.
  50276. * FILE:                                  String functions.
  50277. * FIND_IN_SET():                         String functions.
  50278. * finish DBI method:                     Perl DBI Class.
  50279. * FLOAT:                                 Column types.
  50280. * FLOAT(M,D):                            Column types.
  50281. * FLOAT(precision):                      Column types.
  50282. * FLOOR():                               Mathematical functions.
  50283. * FLUSH:                                 FLUSH.
  50284. * FORMAT():                              Miscellaneous functions.
  50285. * FROM_DAYS():                           Date and time functions.
  50286. * FROM_UNIXTIME():                       Date and time functions.
  50287. * functions, arithmetic:                 Bit functions.
  50288. * functions, bit:                        Bit functions.
  50289. * functions, control flow:               Control flow functions.
  50290. * functions, date and time:              Date and time functions.
  50291. * functions, GROUP BY:                   Group by functions.
  50292. * Functions, logical:                    Logical Operators.
  50293. * functions, mathematical:               Mathematical functions.
  50294. * functions, miscellaneous:              Miscellaneous functions.
  50295. * functions, string:                     String functions.
  50296. * functions, string comparison:          String comparison functions.
  50297. * Functions, user-defined:               CREATE FUNCTION.
  50298. * GET_LOCK():                            Miscellaneous functions.
  50299. * GRANT:                                 GRANT.
  50300. * GRANT statement:                       Adding users.
  50301. * greater than (>):                      Comparison Operators.
  50302. * greater than or equal (>=):            Comparison Operators.
  50303. * GREATEST():                            Mathematical functions.
  50304. * GROUP BY functions:                    Group by functions.
  50305. * HEX():                                 String functions.
  50306. * hexadecimal values:                    Hexadecimal values.
  50307. * HOME environment variable <1>:         Environment variables.
  50308. * HOME environment variable <2>:         Client-Side Overview.
  50309. * HOME environment variable:             Server-Side Overview.
  50310. * host.frm, problems finding:            Post-installation.
  50311. * HOUR():                                Date and time functions.
  50312. * identifiers, quoting:                  Legal names.
  50313. * IF():                                  Control flow functions.
  50314. * IFNULL():                              Control flow functions.
  50315. * IN:                                    Comparison Operators.
  50316. * INET_ATON():                           Miscellaneous functions.
  50317. * INET_NTOA():                           Miscellaneous functions.
  50318. * INNER JOIN:                            JOIN.
  50319. * INSERT <1>:                            INSERT.
  50320. * INSERT:                                Insert speed.
  50321. * INSERT ... SELECT:                     INSERT.
  50322. * INSERT DELAYED:                        INSERT DELAYED.
  50323. * INSERT statement, grant privileges:    Adding users.
  50324. * INSERT():                              String functions.
  50325. * insertid DBI method:                   Perl DBI Class.
  50326. * INSTR():                               String functions.
  50327. * INT:                                   Column types.
  50328. * INTEGER:                               Column types.
  50329. * INTERVAL():                            Comparison Operators.
  50330. * IS NOT NULL:                           Comparison Operators.
  50331. * IS NULL:                               Comparison Operators.
  50332. * IS NULL, and indexes:                  MySQL indexes.
  50333. * is_blob DBI method:                    Perl DBI Class.
  50334. * is_key DBI method:                     Perl DBI Class.
  50335. * is_not_null DBI method:                Perl DBI Class.
  50336. * is_num DBI method:                     Perl DBI Class.
  50337. * is_pri_key DBI method:                 Perl DBI Class.
  50338. * ISNULL():                              Comparison Operators.
  50339. * ISOLATION LEVEL:                       SET TRANSACTION.
  50340. * JOIN:                                  JOIN.
  50341. * KILL:                                  KILL.
  50342. * LAST_INSERT_ID():                      Commit-rollback.
  50343. * LAST_INSERT_ID([expr]):                Miscellaneous functions.
  50344. * LCASE():                               String functions.
  50345. * LD_RUN_PATH environment variable <1>:  Perl support problems.
  50346. * LD_RUN_PATH environment variable <2>:  Environment variables.
  50347. * LD_RUN_PATH environment variable <3>:  Solaris.
  50348. * LD_RUN_PATH environment variable:      Linux.
  50349. * LEAST():                               Mathematical functions.
  50350. * LEFT JOIN <1>:                         JOIN.
  50351. * LEFT JOIN:                             LEFT JOIN optimization.
  50352. * LEFT OUTER JOIN:                       JOIN.
  50353. * LEFT():                                String functions.
  50354. * length DBI method:                     Perl DBI Class.
  50355. * LENGTH():                              String functions.
  50356. * less than (<):                         Comparison Operators.
  50357. * less than or equal (<=):               Comparison Operators.
  50358. * LIKE:                                  String comparison functions.
  50359. * LIKE, and indexes:                     MySQL indexes.
  50360. * LIKE, and wildcards:                   MySQL indexes.
  50361. * LIMIT:                                 LIMIT optimization.
  50362. * LOAD DATA INFILE <1>:                  Problems with NULL.
  50363. * LOAD DATA INFILE:                      LOAD DATA.
  50364. * LOAD_FILE():                           String functions.
  50365. * LOCATE():                              String functions.
  50366. * LOCK TABLES:                           LOCK TABLES.
  50367. * LOG():                                 Mathematical functions.
  50368. * LOG10():                               Mathematical functions.
  50369. * Logical functions:                     Logical Operators.
  50370. * LONGBLOB:                              Column types.
  50371. * LONGTEXT:                              Column types.
  50372. * LOWER():                               String functions.
  50373. * LPAD():                                String functions.
  50374. * LTRIM():                               String functions.
  50375. * MAKE_SET():                            String functions.
  50376. * MASTER_POS_WAIT():                     Miscellaneous functions.
  50377. * MATCH ... AGAINST():                   String comparison functions.
  50378. * mathematical functions:                Mathematical functions.
  50379. * MAX():                                 Group by functions.
  50380. * max_length DBI method:                 Perl DBI Class.
  50381. * MD5():                                 Miscellaneous functions.
  50382. * MEDIUMBLOB:                            Column types.
  50383. * MEDIUMINT:                             Column types.
  50384. * MEDIUMTEXT:                            Column types.
  50385. * MID():                                 String functions.
  50386. * MIN():                                 Group by functions.
  50387. * minus, unary (-):                      Mathematical functions.
  50388. * MINUTE():                              Date and time functions.
  50389. * miscellaneous functions:               Miscellaneous functions.
  50390. * MOD():                                 Mathematical functions.
  50391. * modulo (%):                            Mathematical functions.
  50392. * MONTH():                               Date and time functions.
  50393. * MONTHNAME():                           Date and time functions.
  50394. * multiplication (*):                    Arithmetic functions.
  50395. * my_init():                             my_init.
  50396. * my_thread_end():                       my_thread_end().
  50397. * my_thread_init():                      my_thread_init().
  50398. * my_ulonglong C type:                   C API datatypes.
  50399. * my_ulonglong values, printing:         C API datatypes.
  50400. * MYSQL C type:                          C API datatypes.
  50401. * mysql_affected_rows():                 mysql_affected_rows.
  50402. * mysql_change_user():                   mysql_change_user.
  50403. * mysql_character_set_name():            mysql_character_set_name.
  50404. * mysql_close():                         mysql_close.
  50405. * mysql_connect():                       mysql_connect.
  50406. * mysql_create_db():                     mysql_create_db.
  50407. * mysql_data_seek():                     mysql_data_seek.
  50408. * MYSQL_DEBUG environment variable <1>:  Environment variables.
  50409. * MYSQL_DEBUG environment variable <2>:  Debugging client.
  50410. * MYSQL_DEBUG environment variable <3>:  Client-Side Overview.
  50411. * MYSQL_DEBUG environment variable:      Server-Side Overview.
  50412. * mysql_debug():                         mysql_debug.
  50413. * mysql_drop_db():                       mysql_drop_db.
  50414. * mysql_dump_debug_info():               mysql_dump_debug_info.
  50415. * mysql_eof():                           mysql_eof.
  50416. * mysql_errno():                         mysql_errno.
  50417. * mysql_error():                         mysql_error.
  50418. * mysql_escape_string() <1>:             mysql_escape_string.
  50419. * mysql_escape_string():                 String syntax.
  50420. * mysql_fetch_field():                   mysql_fetch_field.
  50421. * mysql_fetch_field_direct():            mysql_fetch_field_direct.
  50422. * mysql_fetch_fields():                  mysql_fetch_fields.
  50423. * mysql_fetch_lengths():                 mysql_fetch_lengths.
  50424. * mysql_fetch_row():                     mysql_fetch_row.
  50425. * MYSQL_FIELD C type:                    C API datatypes.
  50426. * mysql_field_count() <1>:               mysql_num_fields.
  50427. * mysql_field_count():                   mysql_field_count.
  50428. * MYSQL_FIELD_OFFSET C type:             C API datatypes.
  50429. * mysql_field_seek():                    mysql_field_seek.
  50430. * mysql_field_tell():                    mysql_field_tell.
  50431. * mysql_free_result():                   mysql_free_result.
  50432. * mysql_get_client_info():               mysql_get_client_info.
  50433. * mysql_get_host_info():                 mysql_get_host_info.
  50434. * mysql_get_proto_info():                mysql_get_proto_info.
  50435. * mysql_get_server_info():               mysql_get_server_info.
  50436. * MYSQL_HISTFILE environment variable <1>: Environment variables.
  50437. * MYSQL_HISTFILE environment variable <2>: Client-Side Overview.
  50438. * MYSQL_HISTFILE environment variable:   Server-Side Overview.
  50439. * MYSQL_HOST environment variable <1>:   Environment variables.
  50440. * MYSQL_HOST environment variable:       Connecting.
  50441. * mysql_info() <1>:                      mysql_info.
  50442. * mysql_info() <2>:                      ALTER TABLE.
  50443. * mysql_info() <3>:                      LOAD DATA.
  50444. * mysql_info() <4>:                      UPDATE.
  50445. * mysql_info():                          INSERT.
  50446. * mysql_init():                          mysql_init.
  50447. * mysql_insert_id() <1>:                 mysql_insert_id.
  50448. * mysql_insert_id():                     Commit-rollback.
  50449. * mysql_kill():                          mysql_kill.
  50450. * mysql_list_dbs():                      mysql_list_dbs.
  50451. * mysql_list_fields():                   mysql_list_fields.
  50452. * mysql_list_processes():                mysql_list_processes.
  50453. * mysql_list_tables():                   mysql_list_tables.
  50454. * mysql_num_fields():                    mysql_num_fields.
  50455. * mysql_num_rows():                      mysql_num_rows.
  50456. * mysql_options():                       mysql_options.
  50457. * mysql_ping():                          mysql_ping.
  50458. * MYSQL_PWD environment variable <1>:    Environment variables.
  50459. * MYSQL_PWD environment variable <2>:    Client-Side Overview.
  50460. * MYSQL_PWD environment variable <3>:    Server-Side Overview.
  50461. * MYSQL_PWD environment variable:        Connecting.
  50462. * mysql_query() <1>:                     C API problems.
  50463. * mysql_query():                         mysql_query.
  50464. * mysql_real_connect():                  mysql_real_connect.
  50465. * mysql_real_escape_string():            mysql_real_escape_string.
  50466. * mysql_real_query():                    mysql_real_query.
  50467. * mysql_reload():                        mysql_reload.
  50468. * MYSQL_RES C type:                      C API datatypes.
  50469. * MYSQL_ROW C type:                      C API datatypes.
  50470. * mysql_row_seek():                      mysql_row_seek.
  50471. * mysql_row_tell():                      mysql_row_tell.
  50472. * mysql_select_db():                     mysql_select_db.
  50473. * mysql_shutdown():                      mysql_shutdown.
  50474. * mysql_stat():                          mysql_stat.
  50475. * mysql_store_result() <1>:              C API problems.
  50476. * mysql_store_result():                  mysql_store_result.
  50477. * MYSQL_TCP_PORT environment variable <1>: Environment variables.
  50478. * MYSQL_TCP_PORT environment variable <2>: Client-Side Overview.
  50479. * MYSQL_TCP_PORT environment variable <3>: Server-Side Overview.
  50480. * MYSQL_TCP_PORT environment variable <4>: Multiple servers.
  50481. * MYSQL_TCP_PORT environment variable:   Installing many servers.
  50482. * mysql_thread_id():                     mysql_thread_id.
  50483. * MYSQL_UNIX_PORT environment variable <1>: Environment variables.
  50484. * MYSQL_UNIX_PORT environment variable <2>: Client-Side Overview.
  50485. * MYSQL_UNIX_PORT environment variable <3>: Server-Side Overview.
  50486. * MYSQL_UNIX_PORT environment variable <4>: Multiple servers.
  50487. * MYSQL_UNIX_PORT environment variable <5>: Installing many servers.
  50488. * MYSQL_UNIX_PORT environment variable:  mysql_install_db.
  50489. * mysql_use_result():                    mysql_use_result.
  50490. * NAME DBI method:                       Perl DBI Class.
  50491. * NATIONAL CHAR:                         Column types.
  50492. * NATURAL LEFT JOIN:                     JOIN.
  50493. * NATURAL LEFT OUTER JOIN:               JOIN.
  50494. * NATURAL RIGHT JOIN:                    JOIN.
  50495. * NATURAL RIGHT OUTER JOIN:              JOIN.
  50496. * NCHAR:                                 Column types.
  50497. * newline (\n):                          String syntax.
  50498. * not equal (!=):                        Comparison Operators.
  50499. * not equal (<>):                        Comparison Operators.
  50500. * NOT IN:                                Comparison Operators.
  50501. * NOT LIKE:                              String comparison functions.
  50502. * NOT REGEXP:                            String comparison functions.
  50503. * NOT, logical:                          Logical Operators.
  50504. * NOW():                                 Date and time functions.
  50505. * NUL:                                   String syntax.
  50506. * NULL <1>:                              Problems with NULL.
  50507. * NULL:                                  Working with NULL.
  50508. * NULL value:                            NULL values.
  50509. * NULLABLE DBI method:                   Perl DBI Class.
  50510. * NULLIF():                              Control flow functions.
  50511. * NUM_OF_FIELDS DBI method:              Perl DBI Class.
  50512. * NUMERIC:                               Column types.
  50513. * OCT():                                 String functions.
  50514. * OCTET_LENGTH():                        String functions.
  50515. * OPTIMIZE TABLE:                        OPTIMIZE TABLE.
  50516. * OR, bitwise:                           Bit functions.
  50517. * OR, logical:                           Logical Operators.
  50518. * ORD():                                 String functions.
  50519. * ORDER BY:                              ALTER TABLE.
  50520. * parentheses ( and ):                   Parenthesis.
  50521. * PASSWORD() <1>:                        Ignoring user.
  50522. * PASSWORD() <2>:                        Miscellaneous functions.
  50523. * PASSWORD() <3>:                        Passwords.
  50524. * PASSWORD():                            Connection access.
  50525. * PATH environment variable <1>:         Installing binary.
  50526. * PATH environment variable:             Environment variables.
  50527. * PERIOD_ADD():                          Date and time functions.
  50528. * PERIOD_DIFF():                         Date and time functions.
  50529. * PI():                                  Mathematical functions.
  50530. * POSITION():                            String functions.
  50531. * POW():                                 Mathematical functions.
  50532. * POWER():                               Mathematical functions.
  50533. * prepare() DBI method:                  Perl DBI Class.
  50534. * PRIMARY KEY <1>:                       ALTER TABLE.
  50535. * PRIMARY KEY:                           CREATE TABLE.
  50536. * PROCESSLIST:                           SHOW PROCESSLIST.
  50537. * QUARTER():                             Date and time functions.
  50538. * quote() DBI method:                    Perl DBI Class.
  50539. * quoting of identifiers:                Legal names.
  50540. * RADIANS():                             Mathematical functions.
  50541. * RAND():                                Mathematical functions.
  50542. * REAL:                                  Column types.
  50543. * REGEXP:                                String comparison functions.
  50544. * RELEASE_LOCK():                        Miscellaneous functions.
  50545. * RENAME TABLE:                          RENAME TABLE.
  50546. * REPAIR TABLE:                          REPAIR TABLE.
  50547. * REPEAT():                              String functions.
  50548. * REPLACE:                               REPLACE.
  50549. * REPLACE ... SELECT:                    INSERT.
  50550. * REPLACE():                             String functions.
  50551. * RESTORE TABLE:                         RESTORE TABLE.
  50552. * return (\r):                           String syntax.
  50553. * REVERSE():                             String functions.
  50554. * REVOKE:                                GRANT.
  50555. * RIGHT JOIN:                            JOIN.
  50556. * RIGHT OUTER JOIN:                      JOIN.
  50557. * RIGHT():                               String functions.
  50558. * RLIKE:                                 String comparison functions.
  50559. * ROLLBACK <1>:                          COMMIT.
  50560. * ROLLBACK:                              Commit-rollback.
  50561. * ROUND():                               Mathematical functions.
  50562. * rows DBI method:                       Perl DBI Class.
  50563. * RPAD():                                String functions.
  50564. * RTRIM():                               String functions.
  50565. * SEC_TO_TIME():                         Date and time functions.
  50566. * SECOND():                              Date and time functions.
  50567. * SELECT:                                SELECT.
  50568. * SELECT INTO TABLE:                     Missing SELECT INTO TABLE.
  50569. * SELECT speed:                          SELECT speed.
  50570. * SELECT, optimizing:                    EXPLAIN.
  50571. * SESSION_USER():                        Miscellaneous functions.
  50572. * SET <1>:                               SET.
  50573. * SET:                                   Column types.
  50574. * SET OPTION:                            SET OPTION.
  50575. * SET PASSWORD statement:                Passwords.
  50576. * SHOW COLUMNS:                          SHOW.
  50577. * SHOW CREATE TABLE:                     SHOW.
  50578. * SHOW DATABASE INFO:                    SHOW.
  50579. * SHOW DATABASES:                        SHOW.
  50580. * SHOW FIELDS:                           SHOW.
  50581. * SHOW GRANTS:                           SHOW.
  50582. * SHOW INDEX:                            SHOW.
  50583. * SHOW KEYS:                             SHOW.
  50584. * SHOW MASTER LOGS:                      SHOW.
  50585. * SHOW MASTER STATUS:                    SHOW.
  50586. * SHOW PROCESSLIST:                      SHOW.
  50587. * SHOW SLAVE STATUS:                     SHOW.
  50588. * SHOW STATUS:                           SHOW.
  50589. * SHOW TABLE STATUS:                     SHOW.
  50590. * SHOW TABLES:                           SHOW.
  50591. * SHOW VARIABLES:                        SHOW.
  50592. * SIGN():                                Mathematical functions.
  50593. * SIN():                                 Mathematical functions.
  50594. * single quote (\'):                     String syntax.
  50595. * SMALLINT:                              Column types.
  50596. * SOUNDEX():                             String functions.
  50597. * SPACE():                               String functions.
  50598. * SQRT():                                Mathematical functions.
  50599. * statements, GRANT:                     Adding users.
  50600. * statements, INSERT:                    Adding users.
  50601. * STD():                                 Group by functions.
  50602. * STDDEV():                              Group by functions.
  50603. * STRAIGHT_JOIN:                         JOIN.
  50604. * STRCMP():                              String comparison functions.
  50605. * string comparison functions:           String comparison functions.
  50606. * string functions:                      String functions.
  50607. * SUBDATE():                             Date and time functions.
  50608. * SUBSTRING():                           String functions.
  50609. * SUBSTRING_INDEX():                     String functions.
  50610. * subtraction (-):                       Arithmetic functions.
  50611. * SUM():                                 Group by functions.
  50612. * SYSDATE():                             Date and time functions.
  50613. * SYSTEM_USER():                         Miscellaneous functions.
  50614. * tab (\t):                              String syntax.
  50615. * table DBI method:                      Perl DBI Class.
  50616. * table_cache:                           Table cache.
  50617. * TAN():                                 Mathematical functions.
  50618. * TEXT <1>:                              BLOB.
  50619. * TEXT:                                  Column types.
  50620. * threads:                               SHOW PROCESSLIST.
  50621. * TIME <1>:                              TIME.
  50622. * TIME:                                  Column types.
  50623. * TIME_FORMAT():                         Date and time functions.
  50624. * TIME_TO_SEC():                         Date and time functions.
  50625. * TIMESTAMP <1>:                         DATETIME.
  50626. * TIMESTAMP:                             Column types.
  50627. * TINYBLOB:                              Column types.
  50628. * TINYINT:                               Column types.
  50629. * TINYTEXT:                              Column types.
  50630. * TMPDIR environment variable <1>:       Environment variables.
  50631. * TMPDIR environment variable:           mysql_install_db.
  50632. * TO_DAYS():                             Date and time functions.
  50633. * trace DBI method <1>:                  Using gdb on mysqld.
  50634. * trace DBI method:                      Perl DBI Class.
  50635. * TRIM():                                String functions.
  50636. * TRUNCATE:                              TRUNCATE.
  50637. * TRUNCATE():                            Mathematical functions.
  50638. * type DBI method:                       Perl DBI Class.
  50639. * Types:                                 Column types.
  50640. * TZ environment variable <1>:           Environment variables.
  50641. * TZ environment variable:               Timezone problems.
  50642. * UCASE():                               String functions.
  50643. * UDF functions:                         CREATE FUNCTION.
  50644. * ulimit:                                Not enough file handles.
  50645. * UMASK environment variable <1>:        Environment variables.
  50646. * UMASK environment variable:            File permissions.
  50647. * UMASK_DIR environment variable <1>:    Environment variables.
  50648. * UMASK_DIR environment variable:        File permissions.
  50649. * unary minus (-):                       Mathematical functions.
  50650. * UNION:                                 Searching on two keys.
  50651. * UNIQUE:                                ALTER TABLE.
  50652. * UNIX_TIMESTAMP():                      Date and time functions.
  50653. * UNLOCK TABLES:                         LOCK TABLES.
  50654. * UPDATE:                                UPDATE.
  50655. * UPPER():                               String functions.
  50656. * USE:                                   USE.
  50657. * USER environment variable <1>:         Environment variables.
  50658. * USER environment variable:             Connecting.
  50659. * USER():                                Miscellaneous functions.
  50660. * User-defined functions:                CREATE FUNCTION.
  50661. * VARCHAR <1>:                           String types.
  50662. * VARCHAR:                               Column types.
  50663. * VERSION():                             Miscellaneous functions.
  50664. * WEEK():                                Date and time functions.
  50665. * WEEKDAY():                             Date and time functions.
  50666. * WHERE:                                 Where optimizations.
  50667. * Wild card character (%):               String syntax.
  50668. * Wild card character (_):               String syntax.
  50669. * without-server option:                 configure options.
  50670. * YEAR <1>:                              YEAR.
  50671. * YEAR:                                  Column types.
  50672. * YEAR():                                Date and time functions.
  50673. * | (bitwise OR):                        Bit functions.
  50674. * || (logical OR):                       Logical Operators.
  50675. * ~:                                     Bit functions.
  50676.  
  50677. 
  50678. File: mysql.info,  Node: Concept Index,  Prev: Function Index,  Up: Top
  50679.  
  50680. Concept Index
  50681. *************
  50682.  
  50683. * Menu:
  50684.  
  50685. * aborted clients:                       Communication errors.
  50686. * aborted connection:                    Communication errors.
  50687. * access control:                        Connection access.
  50688. * access denied errors:                  Error Access denied.
  50689. * access privileges:                     Privilege system.
  50690. * Access program:                        MyODBC clients.
  50691. * ACLs:                                  Privilege system.
  50692. * ActiveState Perl:                      ActiveState Perl.
  50693. * adding, character sets:                Adding character set.
  50694. * adding, native functions:              Adding native function.
  50695. * adding, new functions:                 Adding functions.
  50696. * adding, new user privileges:           Adding users.
  50697. * adding, new users:                     Installing binary.
  50698. * adding, procedures:                    Adding procedures.
  50699. * adding, user-definable functions:      Adding UDF.
  50700. * administration, server:                mysqladmin.
  50701. * ADO program:                           MyODBC clients.
  50702. * advertising, contact information:      Contact information.
  50703. * age, calculating:                      Date calculations.
  50704. * alias names, case sensitivity:         Name case sensitivity.
  50705. * aliases, for expressions:              Group by functions.
  50706. * aliases, for tables:                   SELECT.
  50707. * aliases, in GROUP BY clauses:          Group by functions.
  50708. * aliases, in ORDER BY clauses:          Group by functions.
  50709. * aliases, names:                        Legal names.
  50710. * aliases, on expressions:               SELECT.
  50711. * anonymous user <1>:                    Default privileges.
  50712. * anonymous user <2>:                    Request access.
  50713. * anonymous user:                        Connection access.
  50714. * ANSI mode, running:                    ANSI mode.
  50715. * ANSI SQL, differences from:            GRANT.
  50716. * ANSI SQL92, extensions to:             Compatibility.
  50717. * answering questions, etiquette:        Answering questions.
  50718. * Apache:                                Apache.
  50719. * APIs:                                  Clients.
  50720. * APIs, Perl:                            Perl.
  50721. * applying, patches:                     Applying patches.
  50722. * argument processing:                   UDF arguments.
  50723. * arithmetic expressions:                Arithmetic functions.
  50724. * authentication tools:                  Contrib.
  50725. * AUTO-INCREMENT, ODBC:                  ODBC and last_insert_id.
  50726. * AUTO_INCREMENT, and NULL values:       Problems with NULL.
  50727. * backing up, databases <1>:             mysqlhotcopy.
  50728. * backing up, databases:                 mysqldump.
  50729. * backslash, escape character:           Literals.
  50730. * backups:                               Backup.
  50731. * backups, database:                     BACKUP TABLE.
  50732. * batch mode:                            Batch mode.
  50733. * batch, mysql option:                   mysql.
  50734. * BDB table type:                        Table types.
  50735. * BDB tables:                            Commit-rollback.
  50736. * benchmark suite:                       MySQL Benchmarks.
  50737. * benchmarking, tools:                   Contrib.
  50738. * benchmarks:                            Custom Benchmarks.
  50739. * Berkeley_db table type:                Table types.
  50740. * Big5 Chinese character encoding:       Case sensitivity.
  50741. * binary distributions:                  MySQL binaries.
  50742. * binary distributions, installing:      Installing binary.
  50743. * binary distributions, on HP-UX:        Binary notes-HP-UX.
  50744. * binary distributions, on Linux:        Binary notes-Linux.
  50745. * binary log:                            Binary log.
  50746. * Binlog_Dump:                           Replication FAQ.
  50747. * bit_functions, example:                Calculating days.
  50748. * BitKeeper tree:                        Installing source tree.
  50749. * BLOB columns, default values:          BLOB.
  50750. * BLOB columns, indexing:                CREATE TABLE.
  50751. * BLOB, inserting binary data:           String syntax.
  50752. * BLOB, size:                            Storage requirements.
  50753. * books, about MySQL:                    MySQL Information Sources.
  50754. * Borland Builder 4 program:             MyODBC clients.
  50755. * Borland C++ compiler:                  Borland C++.
  50756. * brackets, square:                      Column types.
  50757. * buffer sizes, client:                  Clients.
  50758. * buffer sizes, mysqld server:           Server parameters.
  50759. * bug reports, criteria for:             Bug reports.
  50760. * bug reports, email address:            Bug reports.
  50761. * bugs, known:                           Bugs.
  50762. * bugs, reporting:                       Bug reports.
  50763. * building, client programs:             Building clients.
  50764. * C API, datatypes:                      C.
  50765. * C API, functions:                      C API function overview.
  50766. * C API, linking problems:               C API linking problems.
  50767. * C++:                                   Contrib.
  50768. * C++ APIs:                              Cplusplus.
  50769. * C++ Builder:                           MyODBC clients.
  50770. * C++ compiler cannot create executables: Compilation problems.
  50771. * C++ compiler, gcc:                     configure options.
  50772. * caches, clearing:                      FLUSH.
  50773. * calculating, dates:                    Date calculations.
  50774. * calling sequences, UDF:                UDF calling sequences.
  50775. * can't create/write to file:            Cannot create.
  50776. * case sensitivity, in access checking:  Privileges.
  50777. * case sensitivity, in searches:         Case sensitivity.
  50778. * case sensitivity, in string comparisons: String comparison functions.
  50779. * case sensitivity, of database names:   Extensions to ANSI.
  50780. * case sensitivity, of table names:      Extensions to ANSI.
  50781. * case-sensitivity, in names:            Name case sensitivity.
  50782. * cast operators:                        Case Sensitivity Operators.
  50783. * casts:                                 Comparison Operators.
  50784. * cc1plus problems:                      Compilation problems.
  50785. * ChangeLog:                             News.
  50786. * changes to privileges:                 Request access.
  50787. * changes, log:                          News.
  50788. * changes, version 3.19:                 News-3.19.x.
  50789. * changes, version 3.20:                 News-3.20.x.
  50790. * changes, version 3.21:                 News-3.21.x.
  50791. * changes, version 3.22:                 News-3.22.x.
  50792. * changes, version 3.23:                 News-3.23.x.
  50793. * changes, version 4.0:                  News-4.0.0.
  50794. * changing socket location <1>:          Problems with mysql.sock.
  50795. * changing socket location <2>:          Automatic start.
  50796. * changing socket location:              configure options.
  50797. * changing, column order:                Change column order.
  50798. * character sets <1>:                    Character sets.
  50799. * character sets:                        configure options.
  50800. * character sets, adding:                Adding character set.
  50801. * character-sets-dir, mysql option:      mysql.
  50802. * characters, multi-byte:                Multi-byte characters.
  50803. * check options, myisamchk:              myisamchk check options.
  50804. * checking, tables for errors:           Check.
  50805. * checksum errors:                       Solaris.
  50806. * Chinese:                               Case sensitivity.
  50807. * choosing types:                        Choosing types.
  50808. * choosing, a MySQL version:             Which version.
  50809. * clearing, caches:                      FLUSH.
  50810. * client programs, building:             Building clients.
  50811. * client tools:                          Clients.
  50812. * clients, debugging:                    Debugging client.
  50813. * clients, threaded:                     Threaded clients.
  50814. * closing, tables:                       Table cache.
  50815. * ColdFusion program:                    MyODBC clients.
  50816. * collating, strings:                    String collating.
  50817. * column names, case sensitivity:        Name case sensitivity.
  50818. * columns, changing:                     Change column order.
  50819. * columns, displaying:                   mysqlshow.
  50820. * columns, indexes:                      Indexes.
  50821. * columns, names:                        Legal names.
  50822. * columns, other types:                  Other-vendor column types.
  50823. * columns, selecting:                    Selecting columns.
  50824. * columns, storage requirements:         Storage requirements.
  50825. * columns, types:                        Column types.
  50826. * command line history <1>:              Client-Side Overview.
  50827. * command line history:                  Server-Side Overview.
  50828. * command line options, mysql:           mysql.
  50829. * command line tool:                     mysql.
  50830. * command syntax:                        Manual conventions.
  50831. * commands out of sync:                  Commands out of sync.
  50832. * commands, for binary distribution:     Installing binary.
  50833. * commands, list of:                     mysql.
  50834. * commands, replication:                 Replication SQL.
  50835. * comments, adding:                      Comments.
  50836. * comments, starting:                    Missing comments.
  50837. * commercial support, types:             Support.
  50838. * communications protocols:              Protocol differences.
  50839. * comparisons, MySQL vs. others:         Comparisons.
  50840. * compatibility, between MySQL versions <1>: Upgrading-from-3.21.
  50841. * compatibility, between MySQL versions: Upgrading-from-3.22.
  50842. * compatibility, with ANSI SQL:          Compatibility.
  50843. * compatibility, with mSQL:              String comparison functions.
  50844. * compatibility, with ODBC <1>:          News-3.21.15.
  50845. * compatibility, with ODBC <2>:          CREATE TABLE.
  50846. * compatibility, with ODBC <3>:          JOIN.
  50847. * compatibility, with ODBC <4>:          Comparison Operators.
  50848. * compatibility, with ODBC <5>:          Column types.
  50849. * compatibility, with ODBC:              Legal names.
  50850. * compatibility, with Oracle <1>:        Group by functions.
  50851. * compatibility, with Oracle <2>:        DESCRIBE.
  50852. * compatibility, with Oracle:            Extensions to ANSI.
  50853. * compatibility, with PostgreSQL:        Extensions to ANSI.
  50854. * compatibility, with Sybase:            USE.
  50855. * compiler, C++ gcc:                     configure options.
  50856. * compiling, on Windows:                 Windows compiling.
  50857. * compiling, optimizing:                 System.
  50858. * compiling, problems:                   Compilation problems.
  50859. * compiling, speed:                      Compile and link options.
  50860. * compiling, statically:                 configure options.
  50861. * compiling, user-defined functions:     UDF compiling.
  50862. * compliance, Y2K:                       Year 2000 compliance.
  50863. * compress, mysql option:                mysql.
  50864. * compressed tables:                     myisampack.
  50865. * config-file option:                    mysqld_multi.
  50866. * config.cache:                          Compilation problems.
  50867. * config.cache file:                     Compilation problems.
  50868. * configuration files:                   Access denied.
  50869. * configuration options:                 configure options.
  50870. * configure option, -with-low-memory:    Compilation problems.
  50871. * configure script:                      configure options.
  50872. * configure, running after prior invocation: Compilation problems.
  50873. * connect_timeout variable:              mysql.
  50874. * connecting, remotely with SSH:         Windows and SSH.
  50875. * connecting, to the server <1>:         Connecting.
  50876. * connecting, to the server:             Connecting-disconnecting.
  50877. * connecting, verification:              Connection access.
  50878. * connection, aborted:                   Communication errors.
  50879. * constant table <1>:                    Where optimizations.
  50880. * constant table:                        EXPLAIN.
  50881. * consultants, list of:                  Users.
  50882. * contact information:                   Contact information.
  50883. * Contrib directory:                     Useful Links.
  50884. * contributed programs:                  Contrib.
  50885. * contributing companies, list of:       Supporters.
  50886. * contributors, list of:                 Contributors.
  50887. * control access:                        Connection access.
  50888. * conventions, typographical:            Manual conventions.
  50889. * converters:                            Contrib.
  50890. * converting, tools:                     Using mSQL tools.
  50891. * copyrights:                            Copyright.
  50892. * costs, licensing and support:          Cost.
  50893. * counting, table rows:                  Counting rows.
  50894. * crackers, security against:            Security.
  50895. * crash:                                 Debugging server.
  50896. * crash, recovery:                       Crash recovery.
  50897. * crash, repeated:                       Crashing.
  50898. * crash-me:                              MySQL Benchmarks.
  50899. * crash-me program <1>:                  MySQL Benchmarks.
  50900. * crash-me program:                      Portability.
  50901. * creating, bug reports:                 Bug reports.
  50902. * creating, databases:                   Database use.
  50903. * creating, default startup options:     Option files.
  50904. * creating, tables:                      Creating tables.
  50905. * customer support, mailing address:     Bug reports.
  50906. * customers, of MySQL:                   Internal use.
  50907. * cvs tree:                              Installing source tree.
  50908. * data, character sets:                  Character sets.
  50909. * data, importing:                       mysqlimport.
  50910. * data, ISAM table handler:              Stability.
  50911. * data, loading into tables:             Loading tables.
  50912. * data, retrieving:                      Retrieving data.
  50913. * data, size:                            Data size.
  50914. * database design:                       Design.
  50915. * database names, case sensitivity <1>:  Name case sensitivity.
  50916. * database names, case sensitivity:      Extensions to ANSI.
  50917. * database, mysql option:                mysql.
  50918. * databases, backups:                    Backup.
  50919. * databases, creating:                   Database use.
  50920. * databases, defined:                    What-is.
  50921. * databases, displaying:                 mysqlshow.
  50922. * databases, dumping <1>:                mysqlhotcopy.
  50923. * databases, dumping:                    mysqldump.
  50924. * databases, information about:          Getting information.
  50925. * databases, MySQL vs. others:           Comparisons.
  50926. * databases, names:                      Legal names.
  50927. * databases, replicating:                Replication.
  50928. * databases, selecting:                  Creating database.
  50929. * databases, symbolic links <1>:         Symbolic links to tables.
  50930. * databases, symbolic links:             Symbolic links.
  50931. * databases, using:                      Database use.
  50932. * DataJunction:                          MyODBC clients.
  50933. * datatypes, C API:                      C.
  50934. * Date and Time types:                   Date and time types.
  50935. * date calculations:                     Date calculations.
  50936. * DATE columns, problems:                Using DATE.
  50937. * date functions, Y2K compliance:        Year 2000 compliance.
  50938. * date types:                            Storage requirements.
  50939. * date types, Y2K issues:                Y2K issues.
  50940. * date values, problems:                 DATETIME.
  50941. * db table, sorting:                     Request access.
  50942. * DBI interface:                         DBI with DBD.
  50943. * DBI Perl module:                       Perl DBI Class.
  50944. * DBI/DBD:                               DBI-info.
  50945. * dbServ:                                Useful Links.
  50946. * DBUG package:                          The DBUG package.
  50947. * debug, mysql option:                   mysql.
  50948. * debug-info, mysql option:              mysql.
  50949. * debugging, client:                     Debugging client.
  50950. * debugging, server:                     Debugging server.
  50951. * decimal point:                         Column types.
  50952. * default hostname:                      Connecting.
  50953. * default installation location:         Installation layouts.
  50954. * default options:                       Option files.
  50955. * default values, BLOB and TEXT columns: BLOB.
  50956. * default values, suppression:           configure options.
  50957. * default, privileges:                   Default privileges.
  50958. * default-character-set, mysql option:   mysql.
  50959. * delayed_insert_limit:                  INSERT DELAYED.
  50960. * deleting, rows:                        Deleting from related tables.
  50961. * deletion, mysql.sock:                  Problems with mysql.sock.
  50962. * Delphi:                                Contrib.
  50963. * Delphi program:                        MyODBC clients.
  50964. * design, choices:                       Design.
  50965. * design, issues:                        Bugs.
  50966. * design, limitations:                   Design Limitations.
  50967. * developers, list of:                   Credits.
  50968. * development source tree:               Installing source tree.
  50969. * digits:                                Column types.
  50970. * directory structure, default:          Installation layouts.
  50971. * disconnecting, from the server:        Connecting-disconnecting.
  50972. * disk full:                             Full disk.
  50973. * disk issues:                           Disk issues.
  50974. * disks, splitting data across:          Windows symbolic links.
  50975. * display size:                          Column types.
  50976. * displaying, database information:      mysqlshow.
  50977. * displaying, information, SHOW:         SHOW DATABASE INFO.
  50978. * displaying, table status:              SHOW TABLE STATUS.
  50979. * DNS:                                   DNS.
  50980. * downgrading:                           Upgrade.
  50981. * downloading:                           Getting MySQL.
  50982. * dumping, databases <1>:                mysqlhotcopy.
  50983. * dumping, databases:                    mysqldump.
  50984. * dynamic table characteristics:         Dynamic format.
  50985. * Eiffel Wrapper:                        Eiffel.
  50986. * email lists:                           Mailing-list.
  50987. * email, technical support:              Basic email support.
  50988. * employment with MySQL:                 Contact information.
  50989. * employment, contact information:       Contact information.
  50990. * enable-named-commands, mysql option:   mysql.
  50991. * entering, queries:                     Entering queries.
  50992. * ENUM, size:                            Storage requirements.
  50993. * environment variables <1>:             Client-Side Overview.
  50994. * environment variables <2>:             Server-Side Overview.
  50995. * environment variables <3>:             Access denied.
  50996. * environment variables:                 Option files.
  50997. * environment variables, list of:        Environment variables.
  50998. * error mesaages, can't find file:       File permissions.
  50999. * error messages, displaying:            perror.
  51000. * error messages, languages:             Languages.
  51001. * errors, access denied:                 Error Access denied.
  51002. * errors, checking tables for:           Check.
  51003. * errors, common:                        Problems.
  51004. * errors, directory checksum:            Solaris.
  51005. * errors, handling for UDFs:             UDF return values.
  51006. * errors, known:                         Bugs.
  51007. * errors, linking:                       Link errors.
  51008. * errors, list of:                       Common errors.
  51009. * errors, reporting <1>:                 Bug reports.
  51010. * errors, reporting:                     Introduction.
  51011. * escape characters:                     Literals.
  51012. * estimating, query performance:         Estimating performance.
  51013. * example option:                        mysqld_multi.
  51014. * examples, compressed tables:           myisampack.
  51015. * examples, myisamchk output:            Table-info.
  51016. * examples, queries:                     Examples.
  51017. * Excel:                                 MyODBC clients.
  51018. * execute, mysql option:                 mysql.
  51019. * expression aliases <1>:                Group by functions.
  51020. * expression aliases:                    SELECT.
  51021. * expressions, extended:                 Pattern matching.
  51022. * extended email support:                Extended email support.
  51023. * extensions, to ANSI SQL:               Compatibility.
  51024. * extracting, dates:                     Date calculations.
  51025. * fatal signal 11:                       Compilation problems.
  51026. * features of MySQL:                     Features.
  51027. * files, binary log:                     Binary log.
  51028. * files, config.cache:                   Compilation problems.
  51029. * files, error messages:                 Languages.
  51030. * files, log <1>:                        Log file maintenance.
  51031. * files, log:                            configure options.
  51032. * files, not found message:              File permissions.
  51033. * files, permissions:                    File permissions.
  51034. * files, query log:                      Query log.
  51035. * files, repairing:                      myisamchk repair options.
  51036. * files, script:                         Batch mode.
  51037. * files, size limits:                    Table size.
  51038. * files, slow query log:                 Slow query log.
  51039. * files, text:                           mysqlimport.
  51040. * files, tmp:                            mysql_install_db.
  51041. * files, update log:                     Update log.
  51042. * files,my.cnf:                          Replication Features.
  51043. * floating-point number:                 Column types.
  51044. * floats:                                Number syntax.
  51045. * flush tables:                          mysqladmin.
  51046. * force, mysql option:                   mysql.
  51047. * foreign keys <1>:                      ALTER TABLE.
  51048. * foreign keys <2>:                      example-Foreign keys.
  51049. * foreign keys:                          Missing Foreign Keys.
  51050. * foreign keys, reasons not to use:      Broken Foreign KEY.
  51051. * forums, Tek-Tips:                      Useful Links.
  51052. * free licensing:                        Copyright.
  51053. * FreeBSD troubleshooting:               Compilation problems.
  51054. * full disk:                             Full disk.
  51055. * full-text search:                      Fulltext Search.
  51056. * FULLTEXT:                              Fulltext Search.
  51057. * functionality, missing:                Missing functions.
  51058. * functions for SELECT and WHERE clauses: Functions.
  51059. * functions, C API:                      C API function overview.
  51060. * functions, grouping:                   Parenthesis.
  51061. * functions, native, adding:             Adding native function.
  51062. * functions, new:                        Adding functions.
  51063. * functions, useful:                     Contrib.
  51064. * functions, user-definable, adding:     Adding UDF.
  51065. * functions, user-defined:               Adding functions.
  51066. * gcc:                                   configure options.
  51067. * gdb, using:                            Using gdb on mysqld.
  51068. * general information:                   Introduction.
  51069. * General Public License:                What-is.
  51070. * General Public License, MySQL:         Licensing policy.
  51071. * getting MySQL:                         Getting MySQL.
  51072. * global privileges:                     GRANT.
  51073. * goals of MySQL:                        What-is.
  51074. * GPL, General Public License:           GPL license.
  51075. * GPL, GNU General Public License:       GPL license.
  51076. * grant tables:                          Request access.
  51077. * grant tables, re-creating:             Default privileges.
  51078. * grant tables, sorting <1>:             Request access.
  51079. * grant tables, sorting:                 Connection access.
  51080. * granting, privleges:                   GRANT.
  51081. * GROUP BY, aliases in:                  Group by functions.
  51082. * GROUP BY, extensions to ANSI SQL <1>:  Group by functions.
  51083. * GROUP BY, extensions to ANSI SQL:      SELECT.
  51084. * grouping, expressions:                 Parenthesis.
  51085. * handling, errors:                      UDF return values.
  51086. * HEAP table type:                       Table types.
  51087. * help option:                           mysqld_multi.
  51088. * help, mysql option:                    mysql.
  51089. * history file <1>:                      Client-Side Overview.
  51090. * history file:                          Server-Side Overview.
  51091. * history of MySQL:                      History.
  51092. * host table:                            Request access.
  51093. * host table, sorting:                   Request access.
  51094. * host, mysql option:                    mysql.
  51095. * hostname caching:                      DNS.
  51096. * hostname, default:                     Connecting.
  51097. * HP-UX, binary distribution:            Binary notes-HP-UX.
  51098. * html, mysql option:                    mysql.
  51099. * ID, unique:                            Getting unique ID.
  51100. * ignore-space, mysql option:            mysql.
  51101. * importing, data:                       mysqlimport.
  51102. * increasing, performance:               Replication FAQ.
  51103. * increasing, speed:                     Replication.
  51104. * indexes:                               CREATE INDEX.
  51105. * indexes, and BLOB columns:             CREATE TABLE.
  51106. * indexes, and IS NULL:                  MySQL indexes.
  51107. * indexes, and LIKE:                     MySQL indexes.
  51108. * indexes, and NULL values:              CREATE TABLE.
  51109. * indexes, and TEXT columns:             CREATE TABLE.
  51110. * indexes, block size:                   SHOW VARIABLES.
  51111. * indexes, columns:                      Indexes.
  51112. * indexes, leftmost prefix of:           MySQL indexes.
  51113. * indexes, multi-column:                 Multiple-column indexes.
  51114. * indexes, multi-part:                   CREATE INDEX.
  51115. * indexes, names:                        Legal names.
  51116. * indexes, use of:                       MySQL indexes.
  51117. * InnoDB table type:                     Table types.
  51118. * InnoDB tables:                         Commit-rollback.
  51119. * INSERT DELAYED:                        INSERT DELAYED.
  51120. * inserting, speed of:                   Insert speed.
  51121. * installation layouts:                  Installation layouts.
  51122. * installation overview:                 Installing source.
  51123. * Installing many servers:               Installing many servers.
  51124. * installing, binary distribution:       Installing binary.
  51125. * installing, overview:                  Installing.
  51126. * installing, Perl:                      Perl support.
  51127. * installing, Perl on Windows:           ActiveState Perl.
  51128. * installing, source distribution:       Installing source.
  51129. * installing, user-defined functions:    UDF compiling.
  51130. * integers:                              Number syntax.
  51131. * interface builder:                     Unireg.
  51132. * internal compiler errors:              Compilation problems.
  51133. * internal locking:                      Internal locking.
  51134. * internals:                             MySQL internals.
  51135. * Internet Service Providers:            ISP.
  51136. * ISAM table handler:                    Stability.
  51137. * ISAM table type:                       Table types.
  51138. * ISP services:                          ISP.
  51139. * Java connectivity:                     Java.
  51140. * JDBC <1>:                              Contrib.
  51141. * JDBC:                                  Java.
  51142. * jobs at MySQL:                         Contact information.
  51143. * key space, MyISAM:                     Key space.
  51144. * keys:                                  Indexes.
  51145. * keys, foreign <1>:                     example-Foreign keys.
  51146. * keys, foreign:                         Missing Foreign Keys.
  51147. * keys, multi-column:                    Multiple-column indexes.
  51148. * keys, searching on two:                Searching on two keys.
  51149. * keywords:                              Reserved words.
  51150. * known errors:                          Bugs.
  51151. * language support:                      Languages.
  51152. * last row, unique ID:                   Getting unique ID.
  51153. * layout of installation:                Installation layouts.
  51154. * leftmost prefix of indexes:            MySQL indexes.
  51155. * legal names:                           Legal names.
  51156. * LGPL, GNU Library General Public License: LGPL license.
  51157. * LGPL, Lesser General Public License:   LGPL license.
  51158. * library, mysqlclient:                  Clients.
  51159. * licensing costs:                       Cost.
  51160. * licensing policy:                      Licensing policy.
  51161. * licensing terms:                       Licensing and Support.
  51162. * licensing, contact information:        Contact information.
  51163. * licensing, examples:                   Licensing examples.
  51164. * licensing, free:                       Copyright.
  51165. * limitations, design:                   Design Limitations.
  51166. * limits, file size:                     Table size.
  51167. * linking:                               Building clients.
  51168. * linking, errors:                       Link errors.
  51169. * linking, problems:                     C API linking problems.
  51170. * linking, speed:                        Compile and link options.
  51171. * links, symbolic:                       Symbolic links.
  51172. * Linux, binary distribution:            Binary notes-Linux.
  51173. * literals:                              Literals.
  51174. * loading, tables:                       Loading tables.
  51175. * locking:                               System.
  51176. * locking methods:                       Locking methods.
  51177. * locking, tables:                       Internal locking.
  51178. * Log files:                             Log Files.
  51179. * log files:                             configure options.
  51180. * log files, maintaining:                Log file maintenance.
  51181. * log files, names:                      Backup.
  51182. * log option:                            mysqld_multi.
  51183. * log, changes:                          News.
  51184. * login support:                         Login support.
  51185. * magazines, online:                     Users.
  51186. * mailing address, for customer support: Bug reports.
  51187. * mailing list address:                  Introduction.
  51188. * mailing lists:                         Mailing-list.
  51189. * mailing lists, archive location:       Asking questions.
  51190. * mailing lists, guidelines:             Answering questions.
  51191. * main features of MySQL:                Features.
  51192. * maintaining, log files:                Log file maintenance.
  51193. * maintaining, tables:                   Maintenance regimen.
  51194. * make_binary_distribution <1>:          Client-Side Overview.
  51195. * make_binary_distribution:              Server-Side Overview.
  51196. * manual, available formats:             Manual-info.
  51197. * manual, online location:               Introduction.
  51198. * manual, typographical conventions:     Manual conventions.
  51199. * manuals, about MySQL:                  MySQL Information Sources.
  51200. * master-slave setup:                    Replication Implementation.
  51201. * matching, patterns:                    Pattern matching.
  51202. * max memory used:                       mysqladmin.
  51203. * max_allowed_packet:                    mysql.
  51204. * max_join_size:                         mysql.
  51205. * memory usage, myisamchk:               myisamchk memory.
  51206. * memory use <1>:                        Memory use.
  51207. * memory use:                            mysqladmin.
  51208. * MERGE table type:                      Table types.
  51209. * MERGE tables, defined:                 MERGE.
  51210. * messages, languages:                   Languages.
  51211. * methods, locking:                      Locking methods.
  51212. * mirror sites:                          Getting MySQL.
  51213. * missing functionality:                 Missing functions.
  51214. * MIT-pthreads:                          MIT-pthreads.
  51215. * modes, batch:                          Batch mode.
  51216. * modules, list of:                      Stability.
  51217. * monitor, terminal:                     Tutorial.
  51218. * mSQL compatibility:                    String comparison functions.
  51219. * mSQL vs. MySQL:                        Protocol differences.
  51220. * msql2mysql <1>:                        Client-Side Overview.
  51221. * msql2mysql:                            Server-Side Overview.
  51222. * multi mysqld:                          mysqld_multi.
  51223. * multi-byte characters:                 Multi-byte characters.
  51224. * multi-column indexes:                  Multiple-column indexes.
  51225. * multi-part index:                      CREATE INDEX.
  51226. * multibyte character sets:              Cannot initialize character set.
  51227. * multiple servers:                      Multiple servers.
  51228. * My, derivation:                        History.
  51229. * my.cnf file:                           Replication Features.
  51230. * MyISAM table type:                     Table types.
  51231. * MyISAM, compressed tables:             myisampack.
  51232. * myisamchk <1>:                         Client-Side Overview.
  51233. * myisamchk <2>:                         Server-Side Overview.
  51234. * myisamchk:                             configure options.
  51235. * myisamchk, example output:             Table-info.
  51236. * myisamchk, options:                    myisamchk general options.
  51237. * myisampack <1>:                        Silent column changes.
  51238. * myisampack:                            myisampack.
  51239. * MyODBC:                                ODBC.
  51240. * MyODBC, reporting problems:            MyODBC bug report.
  51241. * mysladmn:                              mysqladmin.
  51242. * mysql:                                 mysql.
  51243. * MySQL AB, defined:                     What is MySQL AB.
  51244. * MySQL binary distribution:             Which version.
  51245. * mysql command line options:            mysql.
  51246. * MySQL history:                         History.
  51247. * MySQL mailing lists:                   Questions.
  51248. * MySQL name:                            History.
  51249. * MySQL source distribution:             Which version.
  51250. * MySQL table types:                     Table types.
  51251. * MySQL tools, conversion:               Using mSQL tools.
  51252. * MySQL usage:                           MySQL customer usage.
  51253. * MySQL version:                         Getting MySQL.
  51254. * MySQL, defined:                        What-is.
  51255. * MySQL, introduction:                   What-is.
  51256. * MySQL, pronunciation:                  What-is.
  51257. * mysql.sock, changing location of:      configure options.
  51258. * mysql.sock, protection:                Problems with mysql.sock.
  51259. * mysql_fix_privilege_tables:            Access denied.
  51260. * mysql_install_db <1>:                  Client-Side Overview.
  51261. * mysql_install_db:                      Server-Side Overview.
  51262. * mysql_install_db script:               mysql_install_db.
  51263. * mysqlaccess <1>:                       Client-Side Overview.
  51264. * mysqlaccess:                           Server-Side Overview.
  51265. * mysqladmin <1>:                        DROP DATABASE.
  51266. * mysqladmin <2>:                        CREATE DATABASE.
  51267. * mysqladmin <3>:                        Client-Side Overview.
  51268. * mysqladmin <4>:                        Server-Side Overview.
  51269. * mysqladmin <5>:                        SHOW STATUS.
  51270. * mysqladmin <6>:                        KILL.
  51271. * mysqladmin:                            FLUSH.
  51272. * mysqladmin option:                     mysqld_multi.
  51273. * mysqlbug <1>:                          Client-Side Overview.
  51274. * mysqlbug:                              Server-Side Overview.
  51275. * mysqlbug script:                       Bug reports.
  51276. * mysqlbug script, location:             Introduction.
  51277. * mysqlclient library:                   Clients.
  51278. * mysqld <1>:                            Client-Side Overview.
  51279. * mysqld:                                Server-Side Overview.
  51280. * mysqld option:                         mysqld_multi.
  51281. * mysqld options <1>:                    Server parameters.
  51282. * mysqld options:                        Command-line options.
  51283. * mysqld server, buffer sizes:           Server parameters.
  51284. * mysqld, starting:                      Changing MySQL user.
  51285. * mysqld-max:                            mysqld-max.
  51286. * mysqld_multi:                          mysqld_multi.
  51287. * mysqldump <1>:                         mysqldump.
  51288. * mysqldump <2>:                         Client-Side Overview.
  51289. * mysqldump <3>:                         Server-Side Overview.
  51290. * mysqldump:                             Upgrading-to-arch.
  51291. * mysqlimport <1>:                       LOAD DATA.
  51292. * mysqlimport <2>:                       mysqlimport.
  51293. * mysqlimport <3>:                       Client-Side Overview.
  51294. * mysqlimport <4>:                       Server-Side Overview.
  51295. * mysqlimport:                           Upgrading-to-arch.
  51296. * mysqlshow <1>:                         Client-Side Overview.
  51297. * mysqlshow:                             Server-Side Overview.
  51298. * mysqltest, MySQL Test Suite:           MySQL test suite.
  51299. * named pipes:                           Windows running.
  51300. * names:                                 Legal names.
  51301. * names, case-sensitivity:               Name case sensitivity.
  51302. * names, variables:                      Variables.
  51303. * naming, releases of MySQL:             Which version.
  51304. * native functions, adding:              Adding native function.
  51305. * native thread support:                 Which OS.
  51306. * negative values:                       Number syntax.
  51307. * net etiquette <1>:                     Answering questions.
  51308. * net etiquette:                         Asking questions.
  51309. * net_buffer_length:                     mysql.
  51310. * netmask notation, in mysql.user table: Connection access.
  51311. * new procedures, adding:                Adding procedures.
  51312. * new users, adding:                     Installing binary.
  51313. * news sites:                            Users.
  51314. * no matching rows:                      No matching rows.
  51315. * no-auto-rehash, mysql option:          mysql.
  51316. * no-log option:                         mysqld_multi.
  51317. * no-named-commands, mysql option:       mysql.
  51318. * no-pager, mysql option:                mysql.
  51319. * no-tee, mysql option:                  mysql.
  51320. * non-delimited strings:                 DATETIME.
  51321. * Non-transactional tables:              Non-transactional tables.
  51322. * NULL value:                            Working with NULL.
  51323. * NULL values, and AUTO_INCREMENT columns: Problems with NULL.
  51324. * NULL values, and indexes:              CREATE TABLE.
  51325. * NULL values, and TIMESTAMP columns:    Problems with NULL.
  51326. * NULL values, vs. empty values:         Problems with NULL.
  51327. * NULL, testing for null <1>:            Control flow functions.
  51328. * NULL, testing for null:                Comparison Operators.
  51329. * numbers:                               Number syntax.
  51330. * numeric types:                         Storage requirements.
  51331. * ODBC:                                  ODBC.
  51332. * ODBC compatibility <1>:                News-3.21.15.
  51333. * ODBC compatibility <2>:                CREATE TABLE.
  51334. * ODBC compatibility <3>:                JOIN.
  51335. * ODBC compatibility <4>:                Comparison Operators.
  51336. * ODBC compatibility <5>:                Column types.
  51337. * ODBC compatibility:                    Legal names.
  51338. * ODBC, administrator:                   ODBC administrator.
  51339. * odbcadmin program:                     MyODBC clients.
  51340. * Old Photo Album:                       Useful Links.
  51341. * OLEDB:                                 Contrib.
  51342. * one-database, mysql option:            mysql.
  51343. * online location of manual:             Introduction.
  51344. * online magazines:                      Users.
  51345. * open source, defined:                  What-is.
  51346. * open tables <1>:                       Open tables.
  51347. * open tables:                           mysqladmin.
  51348. * opening, tables:                       Table cache.
  51349. * opens:                                 mysqladmin.
  51350. * operating systems, file size limits:   Table size.
  51351. * operating systems, supported:          Which OS.
  51352. * operating systems, Windows versus Unix: Windows vs Unix.
  51353. * operations, arithmetic:                Arithmetic functions.
  51354. * operators, cast:                       Case Sensitivity Operators.
  51355. * optimization, tips:                    Tips.
  51356. * optimizations:                         Where optimizations.
  51357. * optimizing, DISTINCT:                  DISTINCT optimization.
  51358. * optimizing, LEFT JOIN:                 LEFT JOIN optimization.
  51359. * optimizing, LIMIT:                     LIMIT optimization.
  51360. * optimizing, tables:                    Optimization.
  51361. * option files:                          Option files.
  51362. * options, command line, mysql:          mysql.
  51363. * options, command-line:                 Command-line options.
  51364. * options, configure:                    configure options.
  51365. * options, myisamchk:                    myisamchk general options.
  51366. * options, provided by MySQL:            Tutorial.
  51367. * options, replication:                  Replication Features.
  51368. * Oracle compatibility <1>:              Group by functions.
  51369. * Oracle compatibility <2>:              DESCRIBE.
  51370. * Oracle compatibility:                  Extensions to ANSI.
  51371. * ORDER BY, aliases in:                  Group by functions.
  51372. * overview:                              Introduction.
  51373. * pack_isam:                             myisampack.
  51374. * pager, mysql option:                   mysql.
  51375. * parameters, server:                    Server parameters.
  51376. * partnering with MySQL:                 Contact information.
  51377. * password encryption, reversibility of: Miscellaneous functions.
  51378. * password option:                       mysqld_multi.
  51379. * password, mysql option:                mysql.
  51380. * password, root user:                   Default privileges.
  51381. * passwords, for users:                  User names.
  51382. * passwords, forgotten:                  Resetting permissions.
  51383. * passwords, resetting:                  Resetting permissions.
  51384. * passwords, security:                   What Privileges.
  51385. * passwords, setting <1>:                SET OPTION.
  51386. * passwords, setting <2>:                Passwords.
  51387. * passwords, setting:                    GRANT.
  51388. * patches, applying:                     Applying patches.
  51389. * pattern matching:                      Pattern matching.
  51390. * payment information:                   Payment information.
  51391. * performance, benchmarks:               Custom Benchmarks.
  51392. * performance, disk issues:              Disk issues.
  51393. * performance, estimating:               Estimating performance.
  51394. * performance, improving <1>:            Data size.
  51395. * performance, improving:                Replication FAQ.
  51396. * Perl API:                              Perl.
  51397. * Perl DBI/DBD, installation problems:   Perl support problems.
  51398. * Perl, installing:                      Perl support.
  51399. * Perl, installing on Windows:           ActiveState Perl.
  51400. * Perl, modules:                         Contrib.
  51401. * permission checks, effect on speed:    Query Speed.
  51402. * perror:                                perror.
  51403. * PhoneSweep:                            Useful Links.
  51404. * PHP API:                               PHP.
  51405. * PHP, web sites:                        Users.
  51406. * Pluribus:                              Useful Links.
  51407. * port, mysql option:                    mysql.
  51408. * portability:                           Portability.
  51409. * portability, types:                    Other-vendor column types.
  51410. * porting, to other systems:             Porting.
  51411. * post-install, many servers:            Installing many servers.
  51412. * post-installation, setup and testing:  Post-installation.
  51413. * PostgreSQL compatibility:              Extensions to ANSI.
  51414. * PostgreSQL vs. MySQL, benchmarks:      MySQL-PostgreSQL benchmarks.
  51415. * PostgreSQL vs. MySQL, overview:        Compare PostgreSQL.
  51416. * PostgreSQL/MySQL, features:            MySQL-PostgreSQL features.
  51417. * PostgreSQL/MySQL, strategies:          Compare PostgreSQL.
  51418. * prices, licensing and support:         Cost.
  51419. * privilege information, location:       Privileges provided.
  51420. * privilege system:                      What Privileges.
  51421. * privilege system, described:           Privileges.
  51422. * privilege, changes:                    Request access.
  51423. * privileges, access:                    Privilege system.
  51424. * privileges, adding:                    Adding users.
  51425. * privileges, default:                   Default privileges.
  51426. * privileges, display:                   SHOW GRANTS.
  51427. * privileges, granting:                  GRANT.
  51428. * privileges, revoking:                  GRANT.
  51429. * problems, access denied errors:        Error Access denied.
  51430. * problems, common errors:               Problems.
  51431. * problems, compiling:                   Compilation problems.
  51432. * problems, DATE columns:                Using DATE.
  51433. * problems, date values:                 DATETIME.
  51434. * problems, installing on IBM-AIX:       IBM-AIX.
  51435. * problems, installing on Solaris:       Solaris.
  51436. * problems, installing Perl:             Perl support problems.
  51437. * problems, linking:                     Link errors.
  51438. * problems, ODBC:                        MyODBC bug report.
  51439. * problems, reporting:                   Bug reports.
  51440. * problems, starting the server:         Starting server.
  51441. * problems, table locking:               Table locking.
  51442. * problems, timezone:                    Timezone problems.
  51443. * procedures, adding:                    Adding procedures.
  51444. * procedures, stored:                    Missing Triggers.
  51445. * process support:                       Which OS.
  51446. * processes, display:                    SHOW PROCESSLIST.
  51447. * processing, arguments:                 UDF arguments.
  51448. * products, selling:                     Licensing examples.
  51449. * programs, client:                      Building clients.
  51450. * programs, contributed:                 Contrib.
  51451. * programs, crash-me:                    Portability.
  51452. * programs, list of <1>:                 Client-Side Overview.
  51453. * programs, list of:                     Server-Side Overview.
  51454. * prompts, meanings:                     Entering queries.
  51455. * pronunciation, MySQL:                  What-is.
  51456. * Protocol mismatch:                     Upgrading-from-3.20.
  51457. * pwPage:                                Useful Links.
  51458. * Python APIs:                           Python.
  51459. * queries, C API results:                NULL mysql_store_result.
  51460. * queries, entering:                     Entering queries.
  51461. * queries, estimating performance:       Estimating performance.
  51462. * queries, examples:                     Examples.
  51463. * queries, speed of:                     Query Speed.
  51464. * queries, Twin Studeis project:         Twin.
  51465. * query log:                             Query log.
  51466. * questions:                             mysqladmin.
  51467. * questions, answering:                  Answering questions.
  51468. * quick, mysql option:                   mysql.
  51469. * quotes, in strings:                    String syntax.
  51470. * quoting:                               String syntax.
  51471. * quoting binary data:                   String syntax.
  51472. * quoting strings:                       Perl DBI Class.
  51473. * raw, mysql option:                     mysql.
  51474. * re-creating, grant tables:             Default privileges.
  51475. * reconfiguring:                         Compilation problems.
  51476. * recovery, from crash:                  Crash recovery.
  51477. * RedHat Package Manager <1>:            Installing binary.
  51478. * RedHat Package Manager:                Linux-RPM.
  51479. * reducing, data size:                   Data size.
  51480. * references:                            ALTER TABLE.
  51481. * regex:                                 Regexp.
  51482. * regular expression syntax, described:  Regexp.
  51483. * related information URLs:              Useful Links.
  51484. * relational databases, defined:         What-is.
  51485. * release numbers:                       Which version.
  51486. * releases, naming scheme:               Which version.
  51487. * releases, testing:                     Which version.
  51488. * releases, updating:                    Many versions.
  51489. * reordering, columns:                   Change column order.
  51490. * repair options, myisamchk:             myisamchk repair options.
  51491. * repairing, tables:                     Repair.
  51492. * replace <1>:                           Client-Side Overview.
  51493. * replace:                               Server-Side Overview.
  51494. * replication:                           Replication.
  51495. * replication, commands:                 Replication SQL.
  51496. * replication, two-way:                  Replication FAQ.
  51497. * reporting, bugs:                       Bug reports.
  51498. * reporting, errors <1>:                 Questions.
  51499. * reporting, errors:                     Introduction.
  51500. * reporting, MyODBC problems:            MyODBC bug report.
  51501. * reserved words, exceptions:            Reserved words.
  51502. * restarting, the server:                Post-installation.
  51503. * retrieving, data:                      Stability.
  51504. * retrieving, data from tables:          Retrieving data.
  51505. * return values, UDFs:                   UDF return values.
  51506. * revoking, privleges:                   GRANT.
  51507. * root password:                         Default privileges.
  51508. * root user, password resetting:         Resetting permissions.
  51509. * rounding errors <1>:                   Mathematical functions.
  51510. * rounding errors:                       Column types.
  51511. * rows, counting:                        Counting rows.
  51512. * rows, deleting:                        Deleting from related tables.
  51513. * rows, locking:                         Commit-rollback.
  51514. * rows, matching problems:               No matching rows.
  51515. * rows, selecting:                       Selecting rows.
  51516. * rows, sorting:                         Sorting rows.
  51517. * RPM file:                              Linux-RPM.
  51518. * RPM, defined:                          Installing binary.
  51519. * RPMs, for common tools:                Contrib.
  51520. * RTS-threads:                           RTS-threads.
  51521. * running configure after prior invocation: Compilation problems.
  51522. * running, a web server:                 Web server.
  51523. * running, ANSI mode:                    ANSI mode.
  51524. * running, batch mode:                   Batch mode.
  51525. * running, multiple servers:             Multiple servers.
  51526. * running, queries:                      Entering queries.
  51527. * safe-mode command:                     mysql.
  51528. * safe-updates, mysql option:            mysql.
  51529. * safe_mysqld:                           safe_mysqld.
  51530. * SCMDB:                                 Useful Links.
  51531. * script files:                          Batch mode.
  51532. * scripts <1>:                           mysql.
  51533. * scripts <2>:                           mysqld_multi.
  51534. * scripts:                               safe_mysqld.
  51535. * scripts, mysql_install_db:             mysql_install_db.
  51536. * scripts, mysqlbug:                     Bug reports.
  51537. * search engines, web:                   Users.
  51538. * searching, and case-sensitivity:       Case sensitivity.
  51539. * searching, full-text:                  Fulltext Search.
  51540. * searching, MySQL webpages:             Asking questions.
  51541. * searching, two keys:                   Searching on two keys.
  51542. * security system:                       Privilege system.
  51543. * security, against crackers:            Security.
  51544. * select_limit:                          mysql.
  51545. * selecting, databases:                  Creating database.
  51546. * selling products:                      Licensing examples.
  51547. * sequence emulation:                    Miscellaneous functions.
  51548. * server administration:                 mysqladmin.
  51549. * server, connecting <1>:                Connecting.
  51550. * server, connecting:                    Connecting-disconnecting.
  51551. * server, debugging:                     Debugging server.
  51552. * server, disconnecting:                 Connecting-disconnecting.
  51553. * server, restart:                       Post-installation.
  51554. * server, shutdown:                      Post-installation.
  51555. * server, starting:                      Post-installation.
  51556. * server, starting and stopping:         Automatic start.
  51557. * server, starting problems:             Starting server.
  51558. * servers, multiple:                     Multiple servers.
  51559. * services:                              Users.
  51560. * services, ISP:                         ISP.
  51561. * services, web:                         ISP.
  51562. * SET, size:                             Storage requirements.
  51563. * set-variable, mysql option:            mysql.
  51564. * setting, passwords:                    Passwords.
  51565. * setup, post-installation:              Post-installation.
  51566. * shell syntax:                          Manual conventions.
  51567. * showing, database information:         mysqlshow.
  51568. * shutting down, the server:             Post-installation.
  51569. * silent column changes:                 Silent column changes.
  51570. * silent, mysql option:                  mysql.
  51571. * size of tables:                        Table size.
  51572. * sizes, display:                        Column types.
  51573. * skip-column-names, mysql option:       mysql.
  51574. * skip-line-numbers, mysql option:       mysql.
  51575. * slow queries:                          mysqladmin.
  51576. * slow query log:                        Slow query log.
  51577. * socket location, changing:             configure options.
  51578. * socket, mysql option:                  mysql.
  51579. * Solaris installation problems:         Solaris.
  51580. * Solaris troubleshooting:               Compilation problems.
  51581. * sorting, character sets:               Character sets.
  51582. * sorting, data:                         Sorting rows.
  51583. * sorting, grant tables <1>:             Request access.
  51584. * sorting, grant tables:                 Connection access.
  51585. * sorting, table rows:                   Sorting rows.
  51586. * source distribution, installing:       Installing source.
  51587. * speed, compiling:                      Compile and link options.
  51588. * speed, increasing:                     Replication.
  51589. * speed, inserting:                      Insert speed.
  51590. * speed, linking:                        Compile and link options.
  51591. * speed, of queries <1>:                 SELECT speed.
  51592. * speed, of queries:                     Query Speed.
  51593. * SQL commands, replication:             Replication SQL.
  51594. * SQL, defined:                          What-is.
  51595. * sql_yacc.cc problems:                  Compilation problems.
  51596. * square brackets:                       Column types.
  51597. * SSH:                                   Windows and SSH.
  51598. * stability:                             Stability.
  51599. * standards compatibility:               Compatibility.
  51600. * Starting many servers:                 Installing many servers.
  51601. * starting, comments:                    Missing comments.
  51602. * starting, mysqld:                      Changing MySQL user.
  51603. * starting, the server:                  Post-installation.
  51604. * starting, the server automatically:    Automatic start.
  51605. * startup options, default:              Option files.
  51606. * startup parameters:                    Server parameters.
  51607. * startup parameters, mysql:             mysql.
  51608. * startup parameters, tuning:            System.
  51609. * statically, compiling:                 configure options.
  51610. * status command:                        mysql.
  51611. * status command, results:               mysqladmin.
  51612. * status, tables:                        SHOW TABLE STATUS.
  51613. * stopping, the server:                  Automatic start.
  51614. * storage of data:                       Design.
  51615. * storage requirements, column type:     Storage requirements.
  51616. * storage space, minimizing:             Data size.
  51617. * stored procedures and triggers, defined: Missing Triggers.
  51618. * storing, data:                         Stability.
  51619. * string collating:                      String collating.
  51620. * string comparisons, case sensitivity:  String comparison functions.
  51621. * string types:                          String types.
  51622. * strings, defined:                      Literals.
  51623. * strings, escaping characters:          Literals.
  51624. * strings, non-delimited:                DATETIME.
  51625. * strings, quoting:                      Perl DBI Class.
  51626. * striping, defined:                     Disk issues.
  51627. * sub-selects:                           Missing Sub-selects.
  51628. * superuser:                             Default privileges.
  51629. * support costs:                         Cost.
  51630. * support terms:                         Licensing and Support.
  51631. * support, BDB Tables:                   Table handler support.
  51632. * support, for operating systems:        Which OS.
  51633. * support, InnoDB Tables:                Table handler support.
  51634. * support, licensing:                    Licensing policy.
  51635. * support, mailing address:              Bug reports.
  51636. * support, types:                        Support.
  51637. * suppression, default values:           configure options.
  51638. * Sybase compatibility:                  USE.
  51639. * symbolic links <1>:                    Symbolic links.
  51640. * symbolic links:                        Windows symbolic links.
  51641. * syntax, regular expression:            Regexp.
  51642. * system optimization:                   System.
  51643. * system table:                          EXPLAIN.
  51644. * system, privilege:                     What Privileges.
  51645. * system, security:                      Privilege system.
  51646. * table aliases:                         SELECT.
  51647. * table cache:                           Table cache.
  51648. * table is full <1>:                     Full table.
  51649. * table is full:                         SET OPTION.
  51650. * table names, case sensitivity <1>:     Name case sensitivity.
  51651. * table names, case sensitivity:         Extensions to ANSI.
  51652. * table types, choosing:                 Table types.
  51653. * table, mysql option:                   mysql.
  51654. * tables, BDB:                           BDB.
  51655. * tables, Berkeley DB:                   BDB.
  51656. * tables, changing column order:         Change column order.
  51657. * tables, checking:                      myisamchk check options.
  51658. * tables, closing:                       Table cache.
  51659. * tables, compressed:                    myisampack.
  51660. * tables, compressed format:             Compressed format.
  51661. * tables, constant <1>:                  Where optimizations.
  51662. * tables, constant:                      EXPLAIN.
  51663. * tables, counting rows:                 Counting rows.
  51664. * tables, creating:                      Creating tables.
  51665. * tables, defragment <1>:                Dynamic format.
  51666. * tables, defragment:                    Maintenance regimen.
  51667. * tables, defragmenting:                 OPTIMIZE TABLE.
  51668. * tables, deleting rows:                 Deleting from related tables.
  51669. * tables, displaying:                    mysqlshow.
  51670. * tables, displaying status:             SHOW TABLE STATUS.
  51671. * tables, dumping <1>:                   mysqlhotcopy.
  51672. * tables, dumping:                       mysqldump.
  51673. * tables, dynamic:                       Dynamic format.
  51674. * tables, error checking:                Check.
  51675. * tables, flush:                         mysqladmin.
  51676. * tables, fragmentation:                 OPTIMIZE TABLE.
  51677. * tables, grant:                         Request access.
  51678. * tables, HEAP:                          HEAP.
  51679. * tables, host:                          Request access.
  51680. * tables, improving performance:         Data size.
  51681. * tables, information:                   Table-info.
  51682. * tables, information about:             Getting information.
  51683. * tables, ISAM:                          ISAM.
  51684. * tables, loading data:                  Loading tables.
  51685. * tables, locking:                       Internal locking.
  51686. * tables, maintenance regimen:           Maintenance regimen.
  51687. * tables, maximum size:                  Table size.
  51688. * tables, merging:                       MERGE.
  51689. * tables, multiple:                      Multiple tables.
  51690. * tables, names:                         Legal names.
  51691. * tables, open:                          Open tables.
  51692. * tables, opening:                       Table cache.
  51693. * tables, optimizing:                    Optimization.
  51694. * tables, repairing:                     Repair.
  51695. * tables, retrieving data:               Retrieving data.
  51696. * tables, selecting columns:             Selecting columns.
  51697. * tables, selecting rows:                Selecting rows.
  51698. * tables, sorting rows:                  Sorting rows.
  51699. * tables, system:                        EXPLAIN.
  51700. * tables, too many:                      Creating many tables.
  51701. * tables, unique ID for last row:        Getting unique ID.
  51702. * tables, updating:                      Commit-rollback.
  51703. * tar, problems on Solaris:              Solaris.
  51704. * Tcl APIs:                              Tcl.
  51705. * tcp-ip option:                         mysqld_multi.
  51706. * TCP/IP:                                Windows running.
  51707. * technical support, by email:           Basic email support.
  51708. * technical support, licensing:          Licensing policy.
  51709. * technical support, mailing address:    Bug reports.
  51710. * tee, mysql option:                     mysql.
  51711. * Tek-Tips forums:                       Useful Links.
  51712. * temporary file, write access:          mysql_install_db.
  51713. * temporary tables, problems:            Temporary table problems.
  51714. * terminal monitor, defined:             Tutorial.
  51715. * testing mysqld, mysqltest:             MySQL test suite.
  51716. * testing, connection to the server:     Connection access.
  51717. * testing, installation:                 Post-installation.
  51718. * testing, of MySQL releases:            Which version.
  51719. * testing, post-installation:            Post-installation.
  51720. * testing, the server:                   Post-installation.
  51721. * Texinfo:                               Manual-info.
  51722. * TEXT columns, default values:          BLOB.
  51723. * TEXT columns, indexing:                CREATE TABLE.
  51724. * text files, importing:                 mysqlimport.
  51725. * TEXT, size:                            Storage requirements.
  51726. * thread packages, differences between:  Thread packages.
  51727. * thread support:                        Which OS.
  51728. * thread support, non-native:            MIT-pthreads.
  51729. * threaded clients:                      Threaded clients.
  51730. * threads <1>:                           MySQL internals.
  51731. * threads:                               mysqladmin.
  51732. * threads, display:                      SHOW PROCESSLIST.
  51733. * threads, RTS:                          RTS-threads.
  51734. * time types:                            Storage requirements.
  51735. * timeout <1>:                           INSERT DELAYED.
  51736. * timeout <2>:                           Miscellaneous functions.
  51737. * timeout:                               SHOW VARIABLES.
  51738. * timeout, connect_timeout variable:     mysql.
  51739. * TIMESTAMP, and NULL values:            Problems with NULL.
  51740. * timezone problems:                     Timezone problems.
  51741. * tips, optimization:                    Tips.
  51742. * ToDo list for MySQL:                   TODO.
  51743. * TODO, symlinks:                        Symbolic links to tables.
  51744. * tools, authentication:                 Contrib.
  51745. * tools, benchmarking:                   Contrib.
  51746. * tools, command line:                   mysql.
  51747. * tools, converting:                     Using mSQL tools.
  51748. * tools, mysqld_multi:                   mysqld_multi.
  51749. * tools, RPMs for:                       Contrib.
  51750. * tools, safe_mysqld:                    safe_mysqld.
  51751. * tools, useful:                         Contrib.
  51752. * tools,, web:                           Contrib.
  51753. * transaction-safe tables:               Commit-rollback.
  51754. * transactions, support:                 Missing Transactions.
  51755. * triggers, stored:                      Missing Triggers.
  51756. * troubleshooting, FreeBSD:              Compilation problems.
  51757. * troubleshooting, Solaris:              Compilation problems.
  51758. * tutorial:                              Tutorial.
  51759. * Twin Studies, queries:                 Twin.
  51760. * type conversions:                      Comparison Operators.
  51761. * types, columns <1>:                    Choosing types.
  51762. * types, columns:                        Column types.
  51763. * types, date:                           Storage requirements.
  51764. * types, Date and Time:                  Date and time types.
  51765. * types, numeric:                        Storage requirements.
  51766. * types, of support:                     Support.
  51767. * types, of tables:                      Table types.
  51768. * types, portability:                    Other-vendor column types.
  51769. * types, strings:                        String types.
  51770. * types, time:                           Storage requirements.
  51771. * typographical conventions:             Manual conventions.
  51772. * UDFs, compiling:                       UDF compiling.
  51773. * UDFs, defined:                         Adding functions.
  51774. * UDFs, return values:                   UDF return values.
  51775. * unbuffered, mysql option:              mysql.
  51776. * unique ID:                             Getting unique ID.
  51777. * Unireg, described:                     Unireg.
  51778. * unloading, tables:                     Retrieving data.
  51779. * update log:                            Update log.
  51780. * updating, releases of MySQL:           Many versions.
  51781. * updating, tables:                      Commit-rollback.
  51782. * upgrading:                             Upgrade.
  51783. * upgrading, 3.20 to 3.21:               Upgrading-from-3.20.
  51784. * upgrading, 3.21 to 3.22:               Upgrading-from-3.21.
  51785. * upgrading, 3.22 to 3.23:               Upgrading-from-3.22.
  51786. * upgrading, different architecture:     Upgrading-to-arch.
  51787. * uptime:                                mysqladmin.
  51788. * URLS for downloading MySQL:            Getting MySQL.
  51789. * URLs to MySQL information:             Useful Links.
  51790. * user names, and passwords:             User names.
  51791. * user option:                           mysqld_multi.
  51792. * user privileges, adding:               Adding users.
  51793. * user table, sorting:                   Connection access.
  51794. * user variables:                        Variables.
  51795. * user, mysql option:                    mysql.
  51796. * user-defined functions, adding <1>:    Adding UDF.
  51797. * user-defined functions, adding:        Adding functions.
  51798. * users, adding:                         Installing binary.
  51799. * users, of MySQL:                       Users.
  51800. * users, root:                           Default privileges.
  51801. * uses, of MySQL:                        Internal use.
  51802. * using multiple disks to start data:    Windows symbolic links.
  51803. * valid numbers, examples:               Number syntax.
  51804. * VARCHAR, size:                         Storage requirements.
  51805. * variables, mysqld:                     Server parameters.
  51806. * variables, status:                     SHOW STATUS.
  51807. * variables, user:                       Variables.
  51808. * variables, values:                     SHOW VARIABLES.
  51809. * verbose, mysql option:                 mysql.
  51810. * version option:                        mysqld_multi.
  51811. * version, choosing:                     Which version.
  51812. * version, latest:                       Getting MySQL.
  51813. * version, mysql option:                 mysql.
  51814. * vertical, mysql option:                mysql.
  51815. * views:                                 Missing Views.
  51816. * virtual memory, problems while compiling: Compilation problems.
  51817. * Visual Basic:                          MyODBC clients.
  51818. * wait, mysql option:                    mysql.
  51819. * Web clients:                           Contrib.
  51820. * web pages, miscellaneous:              Users.
  51821. * web search engines:                    Users.
  51822. * web server, running:                   Web server.
  51823. * web sites:                             Users.
  51824. * web tools:                             Contrib.
  51825. * Web+:                                  Useful Links.
  51826. * Webmerger:                             Useful Links.
  51827. * wild cards, in mysql.columns_priv table: Request access.
  51828. * wild cards, in mysql.db table:         Request access.
  51829. * wild cards, in mysql.host table:       Request access.
  51830. * wild cards, in mysql.tables_priv table: Request access.
  51831. * wildcards, and LIKE:                   MySQL indexes.
  51832. * wildcards, in mysql.user table:        Connection access.
  51833. * Windows:                               ODBC.
  51834. * Windows, compiling on:                 Windows compiling.
  51835. * Windows, open issues:                  Windows vs Unix.
  51836. * Windows, versus Unix:                  Windows vs Unix.
  51837. * Word program:                          MyODBC clients.
  51838. * wrappers, Eiffel:                      Eiffel.
  51839. * write access, tmp:                     mysql_install_db.
  51840. * Year 2000 compliance:                  Year 2000 compliance.
  51841. * Year 2000 issues:                      Y2K issues.
  51842.  
  51843.  
  51844. 
  51845. Tag Table:
  51846. Node: Top166
  51847. Node: Introduction1802
  51848. Node: MySQL and MySQL AB5046
  51849. Node: What-is5730
  51850. Node: What is MySQL AB9306
  51851. Node: Manual-info13095
  51852. Node: Manual conventions13810
  51853. Node: History17422
  51854. Node: Features18285
  51855. Node: Stability23512
  51856. Node: Table size30114
  51857. Node: Year 2000 compliance32208
  51858. Node: MySQL Information Sources36461
  51859. Node: MySQL-Books36885
  51860. Node: General-SQL51000
  51861. Node: Useful Links51774
  51862. Node: Questions70303
  51863. Node: Mailing-list70824
  51864. Node: Asking questions77013
  51865. Node: Bug reports77959
  51866. Node: Answering questions92813
  51867. Node: Licensing and Support93616
  51868. Node: Licensing policy94452
  51869. Node: Copyright97859
  51870. Node: Copyright changes99421
  51871. Node: Licensing examples99661
  51872. Node: Products that use MySQL100393
  51873. Node: ISP102276
  51874. Node: Web server103255
  51875. Node: Cost103739
  51876. Node: Payment information107232
  51877. Node: Contact information108451
  51878. Node: Support109821
  51879. Node: Basic email support111106
  51880. Node: Extended email support114334
  51881. Node: Login support115827
  51882. Node: Extended login support117463
  51883. Node: Telephone support118823
  51884. Node: Table handler support119364
  51885. Node: Compatibility120223
  51886. Node: Extensions to ANSI121189
  51887. Node: Differences from ANSI128103
  51888. Node: ANSI mode129106
  51889. Node: Missing functions129996
  51890. Node: Missing Sub-selects130911
  51891. Node: Missing SELECT INTO TABLE133157
  51892. Node: Missing Transactions133768
  51893. Node: Missing Triggers140041
  51894. Node: Missing Foreign Keys141245
  51895. Node: Broken Foreign KEY143089
  51896. Node: Missing Views145417
  51897. Node: Missing comments146291
  51898. Node: Standards147988
  51899. Node: Commit-rollback148202
  51900. Node: Bugs153313
  51901. Node: Comparisons162878
  51902. Node: Compare mSQL163656
  51903. Node: Using mSQL tools171087
  51904. Node: Protocol differences172528
  51905. Node: Syntax differences173777
  51906. Node: Compare PostgreSQL178671
  51907. Node: MySQL-PostgreSQL goals180187
  51908. Node: MySQL-PostgreSQL features182493
  51909. Node: MySQL-PostgreSQL benchmarks192714
  51910. Node: TODO204818
  51911. Node: TODO MySQL 4.0205757
  51912. Node: TODO future209292
  51913. Node: TODO sometime219535
  51914. Node: TODO unplanned223131
  51915. Node: Installing223378
  51916. Node: Quick Standard Installation225145
  51917. Node: Linux-RPM225476
  51918. Node: Windows installation227773
  51919. Node: General Installation Issues230874
  51920. Node: Getting MySQL231440
  51921. Node: Which OS238458
  51922. Node: Which version243972
  51923. Node: Installation layouts250992
  51924. Node: Many versions253081
  51925. Node: MySQL binaries255431
  51926. Node: Installing source258634
  51927. Node: Quick install261512
  51928. Node: Applying patches267097
  51929. Node: configure options268487
  51930. Node: Installing source tree276195
  51931. Node: Compilation problems279894
  51932. Node: MIT-pthreads286463
  51933. Node: Post-installation289787
  51934. Node: mysql_install_db299553
  51935. Node: Starting server303529
  51936. Node: Automatic start309201
  51937. Node: Upgrade311717
  51938. Node: Upgrading-from-3.22313891
  51939. Node: Upgrading-from-3.21318455
  51940. Node: Upgrading-from-3.20319922
  51941. Node: Upgrading-to-arch322497
  51942. Node: Operating System Specific Notes325854
  51943. Node: Linux326456
  51944. Node: Binary notes-Linux338951
  51945. Node: Linux-x86342067
  51946. Node: Linux-SPARC344249
  51947. Node: Linux-Alpha344993
  51948. Node: Linux-PowerPC346970
  51949. Node: Linux-MIPS347195
  51950. Node: Linux-IA64347529
  51951. Node: Windows348321
  51952. Node: Win95 start349120
  51953. Node: NT start351025
  51954. Node: Windows running353871
  51955. Node: Windows and SSH357352
  51956. Node: Windows symbolic links359022
  51957. Node: Windows compiling360577
  51958. Node: Windows vs Unix361270
  51959. Node: Solaris368086
  51960. Node: Solaris 2.7373860
  51961. Node: Solaris x86376104
  51962. Node: BSD Notes376883
  51963. Node: FreeBSD377476
  51964. Node: NetBSD379980
  51965. Node: OpenBSD380213
  51966. Node: OpenBSD 2.5380439
  51967. Node: OpenBSD 2.8380737
  51968. Node: BSDI381179
  51969. Node: BSDI2381446
  51970. Node: BSDI3382309
  51971. Node: BSDI4383698
  51972. Node: Mac OS X384847
  51973. Node: Mac OS X Public Beta385107
  51974. Node: Mac OS X Server385378
  51975. Node: Other Unix Notes386171
  51976. Node: Binary notes-HP-UX386871
  51977. Node: HP-UX 10.20388742
  51978. Node: HP-UX 11.x389912
  51979. Node: IBM-AIX393957
  51980. Node: SunOS397993
  51981. Node: Alpha-DEC-UNIX398642
  51982. Node: Alpha-DEC-OSF1401353
  51983. Node: SGI-Irix404672
  51984. Node: SCO407350
  51985. Node: SCO Unixware412877
  51986. Node: OS/2413431
  51987. Node: BeOS415425
  51988. Node: Novell Netware415983
  51989. Node: Tutorial416409
  51990. Node: Connecting-disconnecting418420
  51991. Node: Entering queries420252
  51992. Node: Database use428293
  51993. Node: Creating database431321
  51994. Node: Creating tables433101
  51995. Node: Loading tables437290
  51996. Node: Retrieving data440351
  51997. Node: Selecting all441518
  51998. Node: Selecting rows444001
  51999. Node: Selecting columns447230
  52000. Node: Sorting rows449370
  52001. Node: Date calculations451776
  52002. Node: Working with NULL459447
  52003. Node: Pattern matching460925
  52004. Node: Counting rows468669
  52005. Node: Multiple tables472741
  52006. Node: Getting information477168
  52007. Node: Examples479473
  52008. Node: example-Maximum-column481511
  52009. Node: example-Maximum-row481858
  52010. Node: example-Maximum-column-group482941
  52011. Node: example-Maximum-column-group-row483467
  52012. Node: example-user-variables485555
  52013. Node: example-Foreign keys486304
  52014. Node: Searching on two keys488923
  52015. Node: Calculating days490120
  52016. Node: Batch mode491041
  52017. Node: Twin493580
  52018. Node: Twin pool494966
  52019. Node: Twin event500001
  52020. Node: Apache500973
  52021. Node: MySQL Database Administration501718
  52022. Node: Configuring MySQL502571
  52023. Node: Command-line options503034
  52024. Node: Option files513427
  52025. Node: Installing many servers519403
  52026. Node: Multiple servers521580
  52027. Node: Privilege system526510
  52028. Node: General security527567
  52029. Node: Security535454
  52030. Node: Privileges options540511
  52031. Node: What Privileges542330
  52032. Node: Privileges542906
  52033. Node: Privileges provided551697
  52034. Node: Connecting557406
  52035. Node: Connection access559719
  52036. Node: Request access567839
  52037. Node: Access denied575906
  52038. Node: User Account Management589687
  52039. Node: GRANT590333
  52040. Node: User names599681
  52041. Node: Privilege changes602280
  52042. Node: Default privileges603559
  52043. Node: Adding users607186
  52044. Node: Passwords615205
  52045. Node: Password security617801
  52046. Node: Disaster Prevention620927
  52047. Node: Backup621645
  52048. Node: BACKUP TABLE624837
  52049. Node: RESTORE TABLE625980
  52050. Node: CHECK TABLE626877
  52051. Node: REPAIR TABLE631421
  52052. Node: Table maintenance633044
  52053. Node: myisamchk syntax635228
  52054. Node: myisamchk general options638508
  52055. Node: myisamchk check options641227
  52056. Node: myisamchk repair options643097
  52057. Node: myisamchk other options646152
  52058. Node: myisamchk memory647582
  52059. Node: Crash recovery649700
  52060. Node: Check652597
  52061. Node: Repair654182
  52062. Node: Optimization660568
  52063. Node: Maintenance regimen661485
  52064. Node: Table-info664288
  52065. Node: Database Administration676805
  52066. Node: OPTIMIZE TABLE677289
  52067. Node: ANALYZE TABLE678762
  52068. Node: FLUSH679814
  52069. Node: KILL682270
  52070. Node: SHOW684120
  52071. Node: SHOW DATABASE INFO685418
  52072. Node: SHOW TABLE STATUS688646
  52073. Node: SHOW STATUS690151
  52074. Node: SHOW VARIABLES700873
  52075. Node: SHOW LOGS724574
  52076. Node: SHOW PROCESSLIST725123
  52077. Node: SHOW GRANTS725961
  52078. Node: SHOW CREATE TABLE726627
  52079. Node: Localization727250
  52080. Node: Character sets727860
  52081. Node: Languages730363
  52082. Node: Adding character set731450
  52083. Node: Character arrays734951
  52084. Node: String collating736776
  52085. Node: Multi-byte characters737495
  52086. Node: Server-Side Scripts738222
  52087. Node: Server-Side Overview738850
  52088. Node: safe_mysqld742445
  52089. Node: mysqld_multi746715
  52090. Node: myisampack754865
  52091. Node: mysqld-max769074
  52092. Node: Client-Side Scripts772619
  52093. Node: Client-Side Overview773582
  52094. Node: mysql777171
  52095. Node: mysqladmin790166
  52096. Node: Using mysqlcheck793502
  52097. Node: mysqldump798204
  52098. Node: mysqlhotcopy805304
  52099. Node: mysqlimport807498
  52100. Node: mysqlshow812275
  52101. Node: perror813511
  52102. Node: Batch Commands814149
  52103. Node: Log Files814901
  52104. Node: Error log816338
  52105. Node: Query log817196
  52106. Node: Update log818198
  52107. Node: Binary log820534
  52108. Node: Slow query log824501
  52109. Node: Log file maintenance825679
  52110. Node: Replication827462
  52111. Node: Replication Intro828407
  52112. Node: Replication Implementation829775
  52113. Node: Replication HOWTO831634
  52114. Node: Replication Features836285
  52115. Node: Replication Options843183
  52116. Node: Replication SQL855090
  52117. Node: Replication FAQ860691
  52118. Node: Replication Problems871353
  52119. Node: MySQL Optimization877097
  52120. Node: Optimize Overview878110
  52121. Node: Design Limitations879963
  52122. Node: Portability880678
  52123. Node: Internal use884033
  52124. Node: MySQL Benchmarks887263
  52125. Node: Custom Benchmarks890493
  52126. Node: Query Speed892223
  52127. Node: EXPLAIN894108
  52128. Node: Estimating performance908263
  52129. Node: SELECT speed909897
  52130. Node: Where optimizations911423
  52131. Node: DISTINCT optimization915761
  52132. Node: LEFT JOIN optimization916556
  52133. Node: LIMIT optimization918661
  52134. Node: Insert speed919986
  52135. Node: Update speed924498
  52136. Node: Delete speed925336
  52137. Node: Tips925774
  52138. Node: Locking Issues934498
  52139. Node: Internal locking934773
  52140. Node: Table locking936862
  52141. Node: Optimizing Database Structure941085
  52142. Node: Design941786
  52143. Node: Data size943316
  52144. Node: MySQL indexes946181
  52145. Node: Indexes953055
  52146. Node: Multiple-column indexes954531
  52147. Node: Table cache956676
  52148. Node: Creating many tables959131
  52149. Node: Open tables959738
  52150. Node: Optimizing the Server960462
  52151. Node: System961035
  52152. Node: Server parameters963346
  52153. Node: Compile and link options968287
  52154. Node: Memory use972189
  52155. Node: DNS977001
  52156. Node: SET OPTION978333
  52157. Node: Disk issues984688
  52158. Node: Symbolic links988754
  52159. Node: Symbolic links to databases989461
  52160. Node: Symbolic links to tables990871
  52161. Node: Reference993806
  52162. Node: Language Structure994853
  52163. Node: Literals995380
  52164. Node: String syntax995961
  52165. Node: Number syntax999585
  52166. Node: Hexadecimal values1000131
  52167. Node: NULL values1000656
  52168. Node: Legal names1001112
  52169. Node: Name case sensitivity1004815
  52170. Node: Variables1006531
  52171. Node: Comments1008745
  52172. Node: Reserved words1010386
  52173. Node: Column types1015359
  52174. Node: Numeric types1026881
  52175. Node: Date and time types1033613
  52176. Node: Y2K issues1037200
  52177. Node: DATETIME1038565
  52178. Node: TIME1049115
  52179. Node: YEAR1052091
  52180. Node: String types1053417
  52181. Node: CHAR1053970
  52182. Node: BLOB1056587
  52183. Node: ENUM1059803
  52184. Node: SET1062631
  52185. Node: Choosing types1065676
  52186. Node: Other-vendor column types1066554
  52187. Node: Storage requirements1067822
  52188. Node: Functions1071830
  52189. Node: Non-typed Operators1073499
  52190. Node: Parenthesis1073903
  52191. Node: Comparison Operators1074238
  52192. Node: Logical Operators1080236
  52193. Node: Control flow functions1081455
  52194. Node: String functions1085070
  52195. Node: String comparison functions1100706
  52196. Node: Case Sensitivity Operators1105209
  52197. Node: Numeric Functions1106195
  52198. Node: Arithmetic functions1106470
  52199. Node: Mathematical functions1107748
  52200. Node: Date and time functions1117458
  52201. Node: Other Functions1134441
  52202. Node: Bit functions1134678
  52203. Node: Miscellaneous functions1135556
  52204. Node: Data Manipulation1145256
  52205. Node: SELECT1145936
  52206. Node: JOIN1155846
  52207. Node: INSERT1160319
  52208. Node: INSERT SELECT1165184
  52209. Node: INSERT DELAYED1166523
  52210. Node: UPDATE1171991
  52211. Node: DELETE1173834
  52212. Node: TRUNCATE1175666
  52213. Node: REPLACE1176438
  52214. Node: LOAD DATA1177634
  52215. Node: DO1195486
  52216. Node: Data Definition1195902
  52217. Node: CREATE DATABASE1196544
  52218. Node: DROP DATABASE1197323
  52219. Node: CREATE TABLE1198903
  52220. Node: Silent column changes1218011
  52221. Node: ALTER TABLE1220023
  52222. Node: RENAME TABLE1229521
  52223. Node: DROP TABLE1230831
  52224. Node: CREATE INDEX1231520
  52225. Node: DROP INDEX1233451
  52226. Node: Basic User Commands1233890
  52227. Node: USE1234215
  52228. Node: DESCRIBE1235239
  52229. Node: Transactional Commands1236008
  52230. Node: COMMIT1236407
  52231. Node: LOCK TABLES1238399
  52232. Node: SET TRANSACTION1244247
  52233. Node: Fulltext Search1245044
  52234. Node: Fulltext restrictions1251895
  52235. Node: Fulltext Fine-tuning1252251
  52236. Node: Fulltext Features to Appear in MySQL 4.01253657
  52237. Node: Fulltext TODO1255074
  52238. Node: Table types1256016
  52239. Node: MyISAM1258786
  52240. Node: Key space1266555
  52241. Node: MyISAM table formats1267690
  52242. Node: Static format1268263
  52243. Node: Dynamic format1269733
  52244. Node: Compressed format1272385
  52245. Node: MyISAM table problems1273995
  52246. Node: Corrupted MyISAM tables1274449
  52247. Node: MyISAM table close1276071
  52248. Node: MERGE1278200
  52249. Node: ISAM1284138
  52250. Node: HEAP1285536
  52251. Node: BDB1288302
  52252. Node: BDB overview1288895
  52253. Node: BDB install1290318
  52254. Node: BDB start1291196
  52255. Node: BDB characteristic1293612
  52256. Node: BDB TODO1297420
  52257. Node: BDB portability1298083
  52258. Node: BDB errors1298972
  52259. Node: InnoDB1300182
  52260. Node: InnoDB overview1301168
  52261. Node: InnoDB start1303527
  52262. Node: InnoDB init1312159
  52263. Node: Error creating InnoDB1314863
  52264. Node: Using InnoDB tables1315426
  52265. Node: Adding and removing1318981
  52266. Node: Backing up1320128
  52267. Node: InnoDB checkpoints1323920
  52268. Node: Moving1325537
  52269. Node: InnoDB transaction model1326621
  52270. Node: InnoDB consistent read1328356
  52271. Node: InnoDB locking reads1329707
  52272. Node: InnoDB Next-key locking1332129
  52273. Node: InnoDB Locks set1334590
  52274. Node: InnoDB Deadlock detection1337021
  52275. Node: InnoDB Consistent read example1338057
  52276. Node: Implementation1347841
  52277. Node: Table and index1350382
  52278. Node: InnoDB physical structure1351986
  52279. Node: InnoDB Insert buffering1352789
  52280. Node: InnoDB Adaptive hash1354189
  52281. Node: InnoDB Physical record1355328
  52282. Node: File space management1357863
  52283. Node: InnoDB Disk i/o1358203
  52284. Node: InnoDB File space1360837
  52285. Node: InnoDB File Defragmenting1363228
  52286. Node: Error handling1364274
  52287. Node: InnoDB restrictions1365516
  52288. Node: InnoDB contact information1368365
  52289. Node: Clients1368841
  52290. Node: PHP1369634
  52291. Node: PHP problems1370179
  52292. Node: Perl1371179
  52293. Node: DBI with DBD1371664
  52294. Node: Perl DBI Class1372591
  52295. Node: DBI-info1386525
  52296. Node: ODBC1387010
  52297. Node: Installing MyODBC1387868
  52298. Node: ODBC administrator1391090
  52299. Node: MyODBC connect parameters1392592
  52300. Node: ODBC Problems1396094
  52301. Node: MyODBC clients1397278
  52302. Node: ODBC and last_insert_id1408834
  52303. Node: MyODBC bug report1409750
  52304. Node: C1412132
  52305. Node: C API datatypes1414841
  52306. Node: C API function overview1420945
  52307. Node: C API functions1431761
  52308. Node: mysql_affected_rows1435783
  52309. Node: mysql_close1437342
  52310. Node: mysql_connect1437804
  52311. Node: mysql_change_user1439039
  52312. Node: mysql_character_set_name1440910
  52313. Node: mysql_create_db1441314
  52314. Node: mysql_data_seek1442311
  52315. Node: mysql_debug1442947
  52316. Node: mysql_drop_db1443612
  52317. Node: mysql_dump_debug_info1444569
  52318. Node: mysql_eof1445321
  52319. Node: mysql_errno1447927
  52320. Node: mysql_error1448704
  52321. Node: mysql_escape_string1449661
  52322. Node: mysql_fetch_field1450157
  52323. Node: mysql_fetch_fields1451660
  52324. Node: mysql_fetch_field_direct1452476
  52325. Node: mysql_fetch_lengths1453480
  52326. Node: mysql_fetch_row1455132
  52327. Node: mysql_field_count1456980
  52328. Node: mysql_field_seek1459331
  52329. Node: mysql_field_tell1459985
  52330. Node: mysql_free_result1460467
  52331. Node: mysql_get_client_info1460987
  52332. Node: mysql_get_host_info1461411
  52333. Node: mysql_get_proto_info1461879
  52334. Node: mysql_get_server_info1462331
  52335. Node: mysql_info1462749
  52336. Node: mysql_init1464096
  52337. Node: mysql_insert_id1464860
  52338. Node: mysql_kill1466196
  52339. Node: mysql_list_dbs1466831
  52340. Node: mysql_list_fields1467886
  52341. Node: mysql_list_processes1469057
  52342. Node: mysql_list_tables1469920
  52343. Node: mysql_num_fields1470961
  52344. Node: mysql_num_rows1473398
  52345. Node: mysql_options1474119
  52346. Node: mysql_ping1478021
  52347. Node: mysql_query1478794
  52348. Node: mysql_real_connect1479987
  52349. Node: mysql_real_escape_string1485992
  52350. Node: mysql_real_query1488060
  52351. Node: mysql_reload1489372
  52352. Node: mysql_row_seek1490169
  52353. Node: mysql_row_tell1491086
  52354. Node: mysql_select_db1491651
  52355. Node: mysql_shutdown1492608
  52356. Node: mysql_stat1493272
  52357. Node: mysql_store_result1494082
  52358. Node: mysql_thread_id1496581
  52359. Node: mysql_use_result1497230
  52360. Node: C Thread functions1499658
  52361. Node: my_init1500000
  52362. Node: my_thread_init()1500521
  52363. Node: my_thread_end()1500898
  52364. Node: C API problems1501282
  52365. Node: NULL mysql_store_result1501853
  52366. Node: Query results1503390
  52367. Node: Getting unique ID1504899
  52368. Node: C API linking problems1506400
  52369. Node: Building clients1507061
  52370. Node: Threaded clients1507806
  52371. Node: Cplusplus1512421
  52372. Node: Borland C++1512679
  52373. Node: Java1513497
  52374. Node: Python1514042
  52375. Node: Tcl1514400
  52376. Node: Eiffel1514692
  52377. Node: Extending MySQL1514994
  52378. Node: Adding functions1515297
  52379. Node: CREATE FUNCTION1516861
  52380. Node: Adding UDF1518322
  52381. Node: UDF calling sequences1521917
  52382. Node: UDF arguments1524641
  52383. Node: UDF return values1528413
  52384. Node: UDF compiling1530366
  52385. Node: Adding native function1534496
  52386. Node: Adding procedures1538344
  52387. Node: procedure analyse1539124
  52388. Node: Writing a procedure1539900
  52389. Node: MySQL internals1540286
  52390. Node: MySQL threads1541012
  52391. Node: MySQL test suite1542530
  52392. Node: running mysqltest1544003
  52393. Node: extending mysqltest1545319
  52394. Node: Reporting mysqltest bugs1548780
  52395. Node: Problems1551501
  52396. Node: What is crashing1552263
  52397. Node: Common errors1556339
  52398. Node: Error Access denied1557722
  52399. Node: Gone away1557935
  52400. Node: Can not connect to server1559871
  52401. Node: Blocked host1564971
  52402. Node: Too many connections1566142
  52403. Node: Non-transactional tables1567239
  52404. Node: Out of memory1568424
  52405. Node: Packet too large1569273
  52406. Node: Communication errors1570468
  52407. Node: Full table1572685
  52408. Node: Cannot create1573497
  52409. Node: Commands out of sync1574332
  52410. Node: Ignoring user1574950
  52411. Node: Cannot find table1576356
  52412. Node: Cannot initialize character set1577094
  52413. Node: Not enough file handles1578540
  52414. Node: Installation Issues1580915
  52415. Node: Link errors1581310
  52416. Node: Changing MySQL user1583955
  52417. Node: File permissions1586774
  52418. Node: Administration Issues1588026
  52419. Node: Crashing1588608
  52420. Node: Resetting permissions1595895
  52421. Node: Full disk1597143
  52422. Node: Temporary files1598760
  52423. Node: Problems with mysql.sock1600285
  52424. Node: Timezone problems1601871
  52425. Node: Query Issues1602329
  52426. Node: Case sensitivity1602876
  52427. Node: Using DATE1604233
  52428. Node: Problems with NULL1606903
  52429. Node: Problems with alias1609617
  52430. Node: Deleting from related tables1610628
  52431. Node: No matching rows1611698
  52432. Node: Table Definition Issues1613594
  52433. Node: ALTER TABLE problems1613953
  52434. Node: Change column order1615445
  52435. Node: Temporary table problems1616720
  52436. Node: Users1617399
  52437. Node: MySQL customer usage1630143
  52438. Node: Contrib1631637
  52439. Node: Credits1671932
  52440. Node: Developers1672310
  52441. Node: Contributors1676292
  52442. Node: Supporters1686554
  52443. Node: News1687264
  52444. Node: News-4.0.x1688133
  52445. Node: News-4.0.01688595
  52446. Node: News-3.23.x1690024
  52447. Node: News-3.23.521694781
  52448. Node: News-3.23.511696494
  52449. Node: News-3.23.501698404
  52450. Node: News-3.23.491700699
  52451. Node: News-3.23.481701421
  52452. Node: News-3.23.471703684
  52453. Node: News-3.23.461704594
  52454. Node: News-3.23.451705532
  52455. Node: News-3.23.441706636
  52456. Node: News-3.23.431709779
  52457. Node: News-3.23.421710702
  52458. Node: News-3.23.411712733
  52459. Node: News-3.23.401714204
  52460. Node: News-3.23.391716144
  52461. Node: News-3.23.381717557
  52462. Node: News-3.23.371719178
  52463. Node: News-3.23.361721793
  52464. Node: News-3.23.351723308
  52465. Node: News-3.23.34a1723825
  52466. Node: News-3.23.341724077
  52467. Node: News-3.23.331726648
  52468. Node: News-3.23.321729832
  52469. Node: News-3.23.311731161
  52470. Node: News-3.23.301732998
  52471. Node: News-3.23.291734904
  52472. Node: News-3.23.281739366
  52473. Node: News-3.23.271744030
  52474. Node: News-3.23.261744589
  52475. Node: News-3.23.251747295
  52476. Node: News-3.23.241750164
  52477. Node: News-3.23.231751046
  52478. Node: News-3.23.221755278
  52479. Node: News-3.23.211756670
  52480. Node: News-3.23.201758093
  52481. Node: News-3.23.191758356
  52482. Node: News-3.23.181759764
  52483. Node: News-3.23.171760444
  52484. Node: News-3.23.161762418
  52485. Node: News-3.23.151763398
  52486. Node: News-3.23.141766033
  52487. Node: News-3.23.131767762
  52488. Node: News-3.23.121768696
  52489. Node: News-3.23.111770436
  52490. Node: News-3.23.101771983
  52491. Node: News-3.23.91772230
  52492. Node: News-3.23.81774720
  52493. Node: News-3.23.71775987
  52494. Node: News-3.23.61778069
  52495. Node: News-3.23.51779852
  52496. Node: News-3.23.41781786
  52497. Node: News-3.23.31782946
  52498. Node: News-3.23.21784048
  52499. Node: News-3.23.11786390
  52500. Node: News-3.23.01786580
  52501. Node: News-3.22.x1791617
  52502. Node: News-3.22.351794227
  52503. Node: News-3.22.341794626
  52504. Node: News-3.22.331795026
  52505. Node: News-3.22.321795301
  52506. Node: News-3.22.311796001
  52507. Node: News-3.22.301796206
  52508. Node: News-3.22.291796768
  52509. Node: News-3.22.281797702
  52510. Node: News-3.22.271798122
  52511. Node: News-3.22.261798526
  52512. Node: News-3.22.251799419
  52513. Node: News-3.22.241799630
  52514. Node: News-3.22.231800151
  52515. Node: News-3.22.221800973
  52516. Node: News-3.22.211801692
  52517. Node: News-3.22.201802434
  52518. Node: News-3.22.191802785
  52519. Node: News-3.22.181803127
  52520. Node: News-3.22.171803683
  52521. Node: News-3.22.161804103
  52522. Node: News-3.22.151804811
  52523. Node: News-3.22.141806151
  52524. Node: News-3.22.131807054
  52525. Node: News-3.22.121807592
  52526. Node: News-3.22.111808923
  52527. Node: News-3.22.101810338
  52528. Node: News-3.22.91812596
  52529. Node: News-3.22.81813705
  52530. Node: News-3.22.71815192
  52531. Node: News-3.22.61816979
  52532. Node: News-3.22.51817605
  52533. Node: News-3.22.41822105
  52534. Node: News-3.22.31823766
  52535. Node: News-3.22.21824185
  52536. Node: News-3.22.11825628
  52537. Node: News-3.22.01827059
  52538. Node: News-3.21.x1831704
  52539. Node: News-3.21.331834045
  52540. Node: News-3.21.321834651
  52541. Node: News-3.21.311835900
  52542. Node: News-3.21.301836533
  52543. Node: News-3.21.291838118
  52544. Node: News-3.21.281838861
  52545. Node: News-3.21.271839232
  52546. Node: News-3.21.261840466
  52547. Node: News-3.21.251841393
  52548. Node: News-3.21.241841973
  52549. Node: News-3.21.231842876
  52550. Node: News-3.21.221844321
  52551. Node: News-3.21.21a1846018
  52552. Node: News-3.21.211846229
  52553. Node: News-3.21.201846604
  52554. Node: News-3.21.191847268
  52555. Node: News-3.21.181847704
  52556. Node: News-3.21.171848498
  52557. Node: News-3.21.161849692
  52558. Node: News-3.21.151850396
  52559. Node: News-3.21.14b1852882
  52560. Node: News-3.21.14a1853112
  52561. Node: News-3.21.131854722
  52562. Node: News-3.21.121855650
  52563. Node: News-3.21.111857840
  52564. Node: News-3.21.101858898
  52565. Node: News-3.21.91859925
  52566. Node: News-3.21.81860443
  52567. Node: News-3.21.71861845
  52568. Node: News-3.21.61862583
  52569. Node: News-3.21.51862904
  52570. Node: News-3.21.41863543
  52571. Node: News-3.21.31864007
  52572. Node: News-3.21.21866162
  52573. Node: News-3.21.01868284
  52574. Node: News-3.20.x1870929
  52575. Node: News-3.20.181872207
  52576. Node: News-3.20.171873797
  52577. Node: News-3.20.161875872
  52578. Node: News-3.20.151876801
  52579. Node: News-3.20.141877552
  52580. Node: News-3.20.131878851
  52581. Node: News-3.20.111880181
  52582. Node: News-3.20.101881111
  52583. Node: News-3.20.91881808
  52584. Node: News-3.20.81882232
  52585. Node: News-3.20.71882439
  52586. Node: News-3.20.61883547
  52587. Node: News-3.20.31886487
  52588. Node: News-3.20.01888920
  52589. Node: News-3.19.x1890550
  52590. Node: News-3.19.51890986
  52591. Node: News-3.19.41891690
  52592. Node: News-3.19.31892455
  52593. Node: Porting1893103
  52594. Node: Debugging server1895910
  52595. Node: Compiling for debugging1898011
  52596. Node: Making trace files1900586
  52597. Node: Using gdb on mysqld1902271
  52598. Node: Using stack trace1904719
  52599. Node: Using log files1906958
  52600. Node: Reproduceable test case1909587
  52601. Node: Debugging client1911455
  52602. Node: The DBUG package1912631
  52603. Node: Locking methods1916671
  52604. Node: RTS-threads1920622
  52605. Node: Thread packages1923627
  52606. Node: Environment variables1926098
  52607. Node: Regexp1928222
  52608. Node: Unireg1935262
  52609. Node: GPL license1937479
  52610. Node: LGPL license1956671
  52611. Node: Placeholder1984773
  52612. Node: Installing binary1985146
  52613. Node: Perl support1992037
  52614. Node: Perl installation1992501
  52615. Node: ActiveState Perl1995106
  52616. Node: Windows Perl1996283
  52617. Node: Perl support problems1996970
  52618. Node: Group by functions2001006
  52619. Node: Function Index2005155
  52620. Node: Concept Index2045921
  52621. 
  52622. End Tag Table
  52623.